In Python, comments start with a #. To add a multiline comment you could insert a # for each line.
# This is a comment
Python uses indentation to indicate a block of code. Python will give you an error if you skip the indentation.
number = 10 if number > 2: print("Number is greater than two!")
A variable stores a value in Python program. We define a variable using an equals sign.
Variables can be reassigned as many times as you want, in order to change their value.
>>> x = 5 >>> print(x) 5 >>> x = "Hello" >>> print(x) Hello
Note: If you try to reference a variable you haven’t assigned, the program will show error.
Rules for variable name
print() function displays data on the screen when the program executes. The message to be printed should be surrounded by quotes.
If no arguments are provided, the print() function will output a blank line.
To get input from the user in Python, we use input function.
The function prompts the user for input, and returns what they enter as a string.
>>> input("Enter your name: ") Enter your name: Jane 'Jane'
Python point to the location of error with a ^ character.
Modules (sometimes called packages or libraries) help group together related sets of tools in Python.
import pandas as pd