Pack 1 · Challenge 5 of 5 · 10 XP · ⏱ 8 min
FizzBot
🤖 The classic coding challenge, robot edition. Count from 1 to 15. For multiples of 3 say Beep, for multiples of 5 say Boop, and for multiples of both say BeepBoop.
Order matters: test for "both" first, with and, or 15 will only ever say Beep.
if n % 3 == 0 and n % 5 == 0:
print("BeepBoop")
elif n % 3 == 0:
...Instructions
- Loop
nfrom 1 to 15. - Print
Beepfor multiples of 3 andBoopfor multiples of 5. - Print
BeepBoopfor multiples of both, and the number itself otherwise.
💡 Hint
for n in range(1, 16): then if / elif / elif / else, with the both-test first and print(n) under else.
bot.py
Terminal