Fizz-Buzz Game

FizzBuzzFizz buzz is a group word game for children to teach them about division. Players take turns to count incrementally, replacing any number divisible by three with the word “fizz”, and any number divisible by 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:

    1
    2
    Fizz
    4
    Buzz
    Fizz
    7

We have started the game for you… Complete this code (see below) to finish this challenge.

Tip


To find out if a number can be divided by an other number, you will need to check the remainder of the division by using the % sign in Python. For instance:

    7 % 3 = 1 because 7 is not divisible by 3.
    6 % 3 = 0 because 6 is divisible by 3.

So to check if number1 can be divided by number2, you can check if:
number1 % number2 == 0.


Challenge #2


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).

Challenge #3


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.

Share Button
Posted in Computer Science, Python - Beginner, Python Challenges Tagged with: ,

Our Latest Book

Follow this blog