Fizz 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”.
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:
We have started the game for you… Complete this code (see below) to finish this challenge.
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.
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).
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.
Solution...The solution for this challenge is available to full members!
Find out how to become a member:
➤ Members' Area