← All lessons

Lesson 02

Variables & Types

A variable is a named box that stores a value. You create one with = : name = "Ada".

Python has several basic types: str (text), int (whole numbers), float (decimals), and bool (True/False).

Use an f-string to mix variables into text: f"Hello {name}" inserts the value of name.

name = "Ada"        # str
age = 36            # int
pi = 3.14159        # float
is_awesome = True   # bool

print(f"{name} is {age} years old.")
print(type(pi))  # <class 'float'>

Check your understanding

Which value is a boolean?

CHALLENGE

Set name to Ada and age to 36. Print Ada is 36 using an f-string.

Practice →
Next: Conditions →