FizzBuzz But Python

So this little programming project started with inspiration from a YouTube video by Tom Scott. It’s a simple concept, write a program that plays the game FizzBuzz, where the output goes ‘Fizz’ on a number that is a multiple of 3, and ‘Buzz’ on a number that is a multiple of 5 and ‘FizzBuzz’ when it’s a multiple of both, iterating through the numbers from 1 to 100.

Tom Scott wrote his approach in Javascript, and I mostly understood his methodology. I had a little experience with Python, I needed a simple project to put on this website, lightbulb above the head moment. So I’m going to try and perform this very basic game with the following rules:

  1. I will be using Python
  2. The number 3 must be replaced by ‘Beep’
  3. The number 5 must be replaced by ‘Boh’
  4. When running through a number that is a multiple of 3 and 5, use ‘BeepBoh’ instead

So with W3 on my second monitor,  I set about writing the code below.

number = 0
max_number = 100
beep = 3
boh = 5
while number <= max_number:
    number += 1
    if number % beep == 0 and number % boh == 0:
        print("BeepBoh")
    elif number % beep == 0:
        print("Beep")
    elif number % boh == 0:
        print("Boh")
    else:
        print(number)

The code itself is relatively straightforward, with only one alteration I would make upon seeing other people do it.: The while loop could have been replaced by ‘for i in range(1,101)’ and become a little leaner. I tried to keep as many definitions in at the top as possible so it could have some flexibility, which was something the YouTuber I saw didn’t do, so I gave myself a little pat on the back.

Overall, a fun little project that knocked off some rust, I would totally recommend this to other learning programmers.