Table of Contents
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
Output :
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)
Output:
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.
How to get different input from keyboard in python language?
For example:
student_name = input("Enter student Name ")Roll_no = input("Enter roll no. ")Age = input("Enter age ")print("n")print("Printing student Details")print("student_name", "Roll_no", "Age")print(student_name,Roll_no,Age)
Output:
Enter student Name sachinEnter roll no. 17Enter Age 22Printing student Detailsstudent_name,Roll_no,Agesachin 17 22
Summary:
In this article we saw the What is difference between raw_input ( ) function,input ( prompt ) function?, How to get different input from keyboard in python language?. so about this section any query then please comment.
Tags: What is difference between raw_input ( ) function,input ( prompt ) function?, How to get different input from keyboard in python language?. so about this section any query then please comment
If you want to learn machine learning in python then click on it.
BEST OF LUCK!!!