Python Input Exercises

Let’s check out some exercises that will help you understand Python’s input() function better.

Exercise 13-a

Using input() function ask for user's name.


input() function will return whatever user enters after its prompt. Inside input() function’s parenthesis you can type your message which will be shown to the user:
input(“message or question”)

ans_1 = input("Please enter your name.")

Exercise 13-b

This time ask the user a numerical question, such as, "Please enter your age." See what type of data input() returns.


input() function will always return string type data.

ans_1 = input("Please enter your age.")

Exercise 13-c

Using input() function, print() function and another function you may need; ask for the current year, then print the answer +50.


int() function can be used to convert string type into int type in Python.

print(int(input("Please enter the current year."))+50)

Need More Exercises?

Check out Holy Python AI+ for amazing Python learning tools.

*Includes 14 more programming languages, inspirational tools and 1-on-1 consulting options.
Umut Sagir
Finance & Data Science Professional,
Founder of HolyPython