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)

Exercise 13-d

Create a converter that will ask for amount of days and convert it to years, then print it.


Using int() function convert the user's answer to integer. And then make your calculation.


You can ask something like: "How many days would you like to convert to a year?"


You can assume 1 year is 365 days and neglect the extra hours.

message = input("Please enter the amount of days you'd like to convert to years.")
result = int(message)/365

Exercise 13-e

Let's create the same converter this time with float() function instead of int().


You can assume 1 year is 365 days and neglect the extra hours.

message = input("Please enter the amount of days you'd like to convert to years.")
result = float(message)/365

Exercise 13-f

Can you create a converter that converts miles to kms?


1 mile = 1.609 km

message = input("How many miles would you like to convert?")
result = int(message)*1.609