Python3 Standard Input and Output
Python Standard input and output
STANDARD INPUT AND OUTPUT
Python Output :
We use the print() function to output data to the standard output devices.
eg:
print("HELLO WORLD")
output: HELLO WORLD
eg: a=20
print("The value of a is ",a)
print("The value of a is "+ str(a))
output: The value of a is 20
The value of a is 20
OUTPUT FORMATING :
eg: a=10;b=30
print("The value of a is {} and b is{}".format(a, b))
output: The value of a is 10 and b is 30
eg: a=10;b=30
print("The value of b is {1} and a is {0}".format(a, b))
output: The value of b is 30 and a is 10
eg: print("Hello {name},{greeting}".format(name="Suma", greeting="Good Morning"))
output: Hello Suma, Good Morning
eg: print("the story of {0},{1} ,and {other}" .format('Bill', 'Manfred', other= 'George'))
output: the story of bill, Manfred and George
PYTHON INPUT :
If we want to take the input from the user ,we use input() function to allow this
eg: num=input("enter a number:")
print(num)
output: enter a number:4
4
Comments
Post a Comment