0%
⭐ 0 XPPractice
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

  1. Loop n from 1 to 15.
  2. Print Beep for multiples of 3 and Boop for multiples of 5.
  3. Print BeepBoop for 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.

Ask the community

bot.py
Terminal
← BackNext →

Python Warm-ups

All practice packs

Talk it out

  1. Read the instruction with the ✗ out loud.
  2. Say what your code does, line by line, as if to a friend.
  3. Find the line where what it does and what you want split apart.
  4. Press Run and read the terminal. Is that what you expected?
  5. Still stuck? Press Ask Pip why, or peek at the solution.
  6. Or ask on the community help board: say which quest, and paste your code.
New badge!

Your bot just got a new part. See it on the quest map.

Name your bot

It levels up as you play, and gets a new part with every chapter.