Lesson Progress

0% Complete

A very amusing and fun activity, we can start by creating a loop which will print numbers 1 to 50(or you can change the range).

Then, we simply shout

“Fizz” if the number is a multiple of 3.

“Buzz”, if the number is a multiple of 5.

“FizzBuzz”, if the number is a multiple of 3 and 5 both.

```
print('What is fizzbuzz solution?\nfrom numbers from 1-50')
print('say: "Fizz", at multiple of 3')
print('say: "Buzz", at multiple of 5')
print('say: "FizzBuzz", at multiple of both 3 & 5')
# running loop from 1 to 50
for num in range(1,51):
# checking divisibility by 3 and 5 both
if num % 5 == 0 and num % 3 == 0:
print(f'FizzBuzz...(3x & 5x): {num}')
# checking divisibility by 5
elif num % 5 == 0:
print(f'Buzz...(5x): {num}')
# checking divisibility by 3
elif num % 3 == 0:
print(f'Fizz...(3x): {num}')
# print all the rest numbers
else:
print(num)
```