Python Study Tool

Learn Python through practical code challenges - based on Automate the Boring Stuff with Python (2e)
Progress: 0 / 3 completed

Chapter 1 — Python Basics

String vs Integer

BEGINNER Values, types, and the * operator

This code should print 25 (the area of a 5x5 square) but prints something different. Fix the variable so the math works correctly.

Chapter 2 — Flow Control

Mini FizzBuzz

BEGINNER if / elif / else

Print the numbers 1 to 5, but for multiples of 3 print "Fizz" instead of the number. This buggy version uses the wrong comparison operator and the wrong order in the if/else chain. Fix it so the output matches.

Chapter 3 — Functions

The Mutable Default Argument Trap

INTERMEDIATE Default arguments

This code tries to append items to a fresh list each time `add(item)` is called. But the second call returns ['a', 'b'] instead of just ['b']. Fix the function so every call starts with an empty list.