In python it’s very easy to take input from keyboard and perform the operations. Input() is used in python to take input from the user.
This is the inbuilt function in python which takes user input.
Syntax of input() is as below.
Here prompt is the string which represents a message before taking the input. In below code you can see “Enter your name: ” or “Enter your age: ” are the prompts.
#take user name as input name = input("Enter your name: ") #display/print name print(name) #take user age as input age = input("Enter your age: ") #display/print age print(age)
In the above code we are taking user’s name and age using input() function and then printing the name & age value in screen using print() function.
The output of the code is as below.
I hope this article will help you. Happy Coding!