Python Input Output(I/O): How to get input from user in python?
This python series focus on two Built-in-function input() and print() function in python. Python have many built in function we will see later. Let's see Input() and Print()
Print()
Python output using Print() function.
Using print() function, it prints the specific message to the screen or standard output device.
Example:
print("Hello Everyone")
Output
Hello Everyone
One more example
#This we declare a variable and print the value
a=7
print(a)
print("Value:",a)
Output:
7
Value:7
In above example, second print() function print first string "value" after again print "a" value, In a variable store 7 value so it prints value 7.
We already learn about variables if you are not learn it, please first learn it link has given below.
Variable,keywords,identifiers and comment
Let's move on Input() function
Input() function
In python, Input() function allows to get input from the user
Syntax:
input([prompt])
#where prompt is the string, if we want to display message to the screen.
Example:
a=input("Enter a number")
print(a)
Output:
Enter a number:7
7
One more example:
a=int(input("Enter a number"))
print(a)
output:
Enter a number: 5
5
if you enter float value ex:5.1, It shows error message from the output screen.
You can also use float(input("Number"))
Upcoming: Data types in python.
Support us
Please
support HRS INTERESTING FACTS Site. Share this Python Tutorial/Series to your
friends.
@hrsinterestingfacts.blogspot.com
# hrsinterestingfacts Python Tutorial/Series.
Thank You
Everyone.