Basic Lessons

Before you being these lessons, setup your Python environment here.

Print Function in Python

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

User Input

There are two functions in Python that we can use to receive data from the user raw_input and input

Raw 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

Time to test what you have learned!

Which function prints to the console?

Which function receives user input?