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.
total = 150
print("Total: " + total)