The print function print()
in Python is a function that outputs to your console
whatever we want to print out
>>> print("Hello World") Hello World
Video credits to Harshit Vashisth
There are two functions in Python that we can use to receive data from the user
raw_input
and input
raw_input
is used to read text (strings) from the user, this function only works
with Python versions 3.0 and below
>>> name = raw_input("What is your name?") >>> type(name) >>> print("Your name is "+name) What is your name? Mir Your name is Mir
input
is used to read integers from the user for Python version below 3.0. However,
for all Python versions above 3.0, input
reads both strings and integers
>>> age = input("What is your age? ") >>> print("Your age is "+ age) What is your age? 21 Your age is 21
Video credits to Sentdex