Lesson 1 of 3
Values and variables
Objective: Store text and numbers, inspect their types, and predict each line's result.
A value is a piece of data. Python strings hold text inside quotes, integers hold whole numbers, and floats hold decimal numbers.
A variable is a name that points to a value. The equals sign assigns the value on its right to the name on its left; it does not mean ‘is permanently equal to.’
Choose names that explain the data. Reassignment replaces the value a name points to, so trace statements in order instead of guessing from the final line.
Worked example
student = "Maya"
completed = 2
completed = completed + 1
print(student, completed) # Maya 3Practice it
On paper or in a Python interpreter, create a course_name string and a lessons_done integer. Increase lessons_done by one and print both values. Then deliberately remove the quotation marks from the string, observe the error, and restore them.