FizzBuzz
Numbers 1 to 100, words instead of multiples of 3 and 5. Teaches the remainder and the order of conditions.
Open in Tokbit Level: Intermediate. Free in the browser, nothing to install, no account needed.
Run the example in Tokbit and step through it: before each step say what will happen and check it in the Variables panel. Then change it your way.
Flowchart
Python program
The same program as Python code. In Tokbit you see it when you switch from Diagram to Python above the flowchart.
"""The classic task: multiples of 3 and 5 print Fizz and Buzz. Teaches nested conditions."""
for i in range(1, 101):
# Multiples of 15 must come first, otherwise the test for 3 would win.
if i % 15 == 0:
print("FizzBuzz")
else:
if i % 3 == 0:
print("Fizz")
else:
if i % 5 == 0:
print("Buzz")
else:
print(i)
Follow-up tasks
Tasks in which you change the example (with a model solution):