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
1 2 |
name=input("What is your name?") print(name) |
Output:
Get the numeric input using int function
1 2 |
age=int(input("What is your age?")) print(age) |
Output:
Get the decimal number using float function
1 2 |
percentage=float(input("What is percentage of marks in high school?")) print(percentage) |
Output: