Coding for All
Lesson 2: Variables
Variables Store a value in a variable and print it.
1message = "Hi there"
2print(message)
Terminal
$ python3 main.py
Hi there
Every line, explained
message = "Hi there"
This creates a variable: a named box that stores a value. In Python you just write name = value: the = stores the value on the right into the name on the left. No special type word, no semicolon; Python keeps it simple. Here the variable is called message and it stores the text "Hi there".
print(message)
print(...) shows whatever is inside its round brackets in the terminal, then moves to a new line. It is written all in lowercase, and it needs both brackets. There are no quotes around message, so Python prints what is stored in the variable, not the word message itself.