Skip to Content
Week Three

Week Three

This week we learn about variables β€” containers that store information so you can use it later in your program.

Presentation

Variables

Variables are containers that store information. You give them a name and assign a value using =.

world = '🌎🌍🌏' python = 'Python 🐍' fire = 'πŸ”₯' name = 'Shirley'
  • world stores emojis.
  • python stores text with an emoji.
  • fire stores a fire emoji.
  • name stores a string representing a name.

πŸ’‘ Tip: Variables can store text (strings), numbers, or other types of data.

More Examples

name = "Alice" age = 12 is_student = True print(f"{name} {age}")

Changing Variable Values

You can update a variable by assigning it a new value:

score = 0 score = 10 print(score) # 10

Using Variables in f-strings

f-strings let you insert variables directly into text:

name = "Alex" print(f"Hello, {name}!")

This prints:

Hello, Alex!

print() shows information on the screen. It’s how you check what your code is doing.

print("This is output!")

Activity

Try changing the values of variables and see how the output changes. Add more print() statements with your own emojis or messages!

variables.py
pet = "dog" emoji = "🐢" count = 3 print(f"I have {count} {pet}s {emoji}")
Last updated on