This Python Quiz lesson is for a beginner. Read the short notes, run each example, then change one name or number and run it again.
A variable is created by assignment. The statement x = 5 binds the name x to the number 5.
var x = 5 and $x = 5 are not Python. A line that starts with # is a comment, not an assignment.
Example 1: Start here
The working form is x = 5.
x = 5 # a whole number
print(x)
Example 2: A real assignment
Python assignment is name = value. There is no var and no $.
city = "Chennai" # text
print(city)
Example 3: A comment is not code
The first line is ignored because it starts with #.
# city = "Chennai"
city = "Pune" # text
print(city)
Example 4: Text and numbers differ
Quotes make text. A bare 82 is a number.
print("82") # print writes this; the quotes are not shown
print(82)
