A variable is an identifier that can change the stored value during the execution of the program.
hello = 'Hi'
hello2 = hello
Rules for creating variables in Python
Variable names must start with a letter or underscore.
Variable names cannot start with a digit.
A variable name can only contain letters, digits, and underscores (A - z, 0-9, and _).
Variable names are case sensitive (num, Num, and NUM are three different variables).
Don't use reserved words (keywords) as a variable name.
number = 10 # variable number of integer type assigns the value 10
pi = 3.14 # floating point pi is assigned the value 3.14
word = "Hello" # variable word of string type assigns the value "Hello"
print(number, pi, word)
Variable can change the value in a program.
word = "Astana"
print("2017 - ", word)
print("2018 –", word)
word = "Nur-Sultan"
print("2019 –", word)
2017 - Astana
2018 - Astana
2019 – Nur-Sultan
The comment starts with a hash character (#), and is followed by text that contains further explanations.
# defining the post code
postCode = 090014
If we want to comment out several lines at once, then use """.