🐍 Python for Everyone

← Back to the quiz

Chapter 2 Exercises 15 min, hands-on

Exercises: Variables & Data Types

How to run these Download starter.py below, then run python3 starter.py from a terminal.

1 Inspect three variables

Create favorite_number (int), pi_estimate (float), and is_raining (bool). Print each with its type using type().

2 Identity check

Set a = 5 and b = 5. Print whether id(a) == id(b), and explain why based on what this chapter taught.

3 Real conversion

Ask for the user's birth year with input(), convert it to an int, and print their approximate age (assume the current year is 2026).

🐞 Task 4 — Debug the Code

This code raises a TypeError. Find the bug and fix it using a type conversion function from this chapter.

buggy.py
total = 150
print("Total: " + total)
← Back to Quiz Practice Bank →