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:
![](http://www.revisitclass.com/wp-content/uploads/2019/02/user_input.png)
Get the numeric input using int function
1 2 |
age=int(input("What is your age?")) print(age) |
Output:
![](http://www.revisitclass.com/wp-content/uploads/2019/02/user_input2.png)
Get the decimal number using float function
1 2 |
percentage=float(input("What is percentage of marks in high school?")) print(percentage) |
Output:
![](http://www.revisitclass.com/wp-content/uploads/2019/02/user_input3.png)