>_Code Club
← All exercises

python

Variables

A variable is a name that points to a value. You create one with =:

city = "Montreal"
year = 2026
print(city)
print(year)
  • "Montreal" is a string (text), so it has quotes.
  • 2026 is an integer (a whole number), so no quotes.

You can mix variables into a sentence with an f-string: put an f before the quotes and the variable names in {curly braces}:

print(f"In {year} I live in {city}.")

Your mission

  1. Create a variable name with your name (a string).
  2. Create a variable age with your age (a number, no quotes!).
  3. Print the sentence: My name is ... and I am ... years old. using an f-string.
Next exerciseThe computer is a calculator →
Loading the editor…