Fizz-Buzz Game Algorithm

fizz-buzz-iconFizz-Buzz is a group word game for children to teach them about division. Players take turns to count incrementally, replacing any multiple of three with the word “fizz”, and any multiple of five with the word “buzz”.

Fizz-Buzz Challenge

For this challenge you need to write a computer program that will display all the numbers between 1 and 100.

  • For each number divisible by three the computer will display the word “fizz”,
  • For each number divisible by five the computer will display the word “buzz”,
  • For each number divisible by three and by five the computer will display the word “fizz-buzz”,

This is what the output will look like:


Fizz-Buzz Algorithm

Check the following flowchart used to generate the first 100 numbers using the Fizz-Buzz rules. (Click on the flowchart to enlarge it).

Python Challenge

Use the above flowchart to complete this Python code.

Extension Task #1

Tweak this code to use the input command in Python. The program should ask the user to input numbers in order or type the word Fizz or Buzz when required. The program should check that the user has typed the right number or the right word and stop if not. It should then give the final score (How far the player completed the game).

Extension Task #2

Improve this code further to give the players three lives. The player can make up to 3 mistakes. Each time they make a mistake they lose 10 points but carry on playing till they lose their three lives.

Did you like this challenge?

Click on a star to rate it!

Average rating 0 / 5. Vote count: 0

No votes so far! Be the first to rate this post.

As you found this challenge interesting...

Follow us on social media!