Articles → Python → Keyboard input from the user in python

Keyboard input from the user in python






Example




name = input("Please enter your name:")
print("Welcome ", name, "!!!")




Picture showing how to take keyboard input from user in python

Click to Enlarge


Getting the integer value from the input element




age = input("Please enter your age:")

print(type(age))




Picture showing the data type of the age variable as string

Click to Enlarge



age = input("Please enter your age:")

print(type(eval(age)))


Picture showing the data type of the age variable as integer after using eval function

Click to Enlarge


Posted By  -  Karan Gupta
 
Posted On  -  Friday, March 1, 2019
 
Updated On  -  Friday, September 17, 2021

Query/Feedback


Your Email Id  
 
Subject 
 
Query/FeedbackCharacters remaining 250