Python Foundations · Lesson 2 of 12Variables and data types
Assignment, strings, integers, floats and booleans. Learn through short examples, practical tasks and targeted questions.
← All lessons
Variables and data types
Variables name values so a program can use or update them later. A string stores text, an integer stores whole numbers, a float stores decimal numbers and a Boolean stores True or False. Read each assignment carefully, then predict the type and value before printing them.
Watch out: Putting a number in quotation marks creates a string. That changes what operations the program can perform with the value.
A free TutorSyntax programming lesson. About our teaching approach.
APPLY THE IDEA
Use this skill beyond the example
Trace assignments in order, especially when a variable is updated. If score starts at 4 and the program executes score = score + 3 twice, write the value after each line before checking the result.
Quick check: Why does a variable change value when assigned a new expression?
Check: Assignment evaluates the expression and stores the resulting value under the variable name, replacing its previous value.
Continue with related practice →