W WolfCode · CSC 141

FizzBuzz

FizzBuzz

≈ 20 min · python-loops python-conditionals · Open in WolfCode

The famous interview screener — every Ch. 3 loop skill plus the order-of-branches trap from Ch. 2 in one exercise.

The rules

  • Divisible by both 3 and 5"FizzBuzz"
  • Divisible by 3 (only) → "Fizz"
  • Divisible by 5 (only) → "Buzz"
  • Otherwise → str(i)

The shape

Python · runnable

Check yourself

In the BROKEN ordering (3-branch first), what does fizzbuzz(15)[14] return?

Why str(i) not just i?

The TypeError-on-join trap

Now you try

Open 02-fizzbuzz.py. The autograder runs 6 tests including a type-consistency check.