python 3 get user input
Hello everyone, In this article we will see What is difference between raw_input ( ) function,input ( prompt ) function?, How to get different input from keyboard in python language ?
So let’s start:
|python 3 get user input-raw_input ( ) function input ( prompt ) function|
Python 3 version has a built-in function input() to accept user input from keyboard.
Python language provides two inbuilt function to read the input or data from the keyboard.
- raw_input ( prompt ) function
- input ( prompt ) function
What is difference between raw_input ( ) function input ( prompt ) function?
This function takes exact input from the keyboard and convert it to string, then return it to the variable form in which we want to store it. raw_input ( ) function works in only older version python 2.0.
For example –
# Python example for a use of raw_input()s = raw_input("Enter your good name : ")print s
Enter your good name : sachinsachin
Here, s is a variable which give the string value, type by user .
input ( prompt ) function :
we use input(prompt) to accept input from a user and print() function used to display output on the console.
input ( prompt ) function takes the input from the user or external source and then evaluates the value.If the input provided is wrong then it gives syntax error or exception
For example –
# Python program showing input ( prompt ) functionsach = input("please enter your smart value: ")print(sach)
please enter your smart value: 5555
What is the input in python?
we are provide some value to system or machine this known as input.
For example, if you want to perform an multiplication of two numbers on the calculator or on scientific calculator then you need to first provide two number to the calculator, those two number is known as input provided by the user.