Taking Input

input() function

input() function is used to take input from users.

Syntax for input():

input('prompt message')

Whatever you pass inside the quotes within parenthesis, it is going to show to the user as a message and the screen will freeze until user gives some input. The value entered by the user is taken as a string and should be stored in some variable.

Example

name = input('What is your name? ')
print('Hello',end=' ')
print(name)

Start IDLE. Open new file. Write the above code, save it as test.py and press F5.
You will see the following output:

Output:
What is your name? Your_Name
Hello Your_Name

After printing 'What is your name? ', the program will wait for users input that its going to store in variable name. Then finally we are outputting it all together.

<< Variables and Data Types Performing Operations >>