A2 — Control flow

Write short programs that use if, while, and for. Includes a small number-guessing game and a FizzBuzz variant.

Overview

Practise the three control-flow constructs from lecture. Two problems, each in its own file.

Problem 1 — Guess

Write guess.py that picks a random integer in 1..100 and lets the user guess until correct. After each wrong guess, tell them “higher” or “lower”.

Problem 2 — FizzBuzz-ish

Write fizz.py that prints numbers 1..100, replacing:

  • multiples of 3 with Fizz
  • multiples of 5 with Buzz
  • multiples of 7 with Bang
  • multiples of any two with the concatenation