Coding Pirates

Lesson 1

Variables

A variable is a name for a value. Think of it as a labelled box: you put something in, and later you can look at it or swap it for something else.

name = "Ada"
age = 12
  • The = means "put this value in the box". It is not the same as "equals" in math.
  • Text goes in quotes: "Ada". Numbers do not: 12.
  • Names use small letters and underscores: favorite_game, not Favorite Game.
  • To put a variable into text, use an f-string: f"Hi {name}".
1 / 4