Getting user input from keyboard in Python

Contents

We can get the user input using input() function in python.There is one more function raw_input() that used to get the user input.You can use input function from python 3 and older version of python have raw_input() function.

To get the user input

name=input("What is your name?")
print(name)

Output:

Get the numeric input using int function

age=int(input("What is your age?"))
print(age)

Output:

Get the decimal number using float function

percentage=float(input("What is percentage of marks in high school?"))
print(percentage)

Output: