Created
February 16, 2024 15:38
-
-
Save siddharthaborah/31e6eeb4c6d964f8276d1b8192e01c80 to your computer and use it in GitHub Desktop.
FizzBuzz game
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
""" | |
You are going to write a program that automatically | |
prints the solution to the FizzBuzz game. | |
These are the rules of the FizzBuzz game: | |
--> Your program should print each number from 1 to 100 in turn and include number 100. | |
--> When the number is divisible by 3 then instead of printing the number it should print "Fizz". | |
--> When the number is divisible by 5, then instead of printing the number it should print "Buzz".` | |
--> And if the number is divisible by both 3 and 5 | |
e.g. 15 then instead of the number it should print "FizzBuzz" | |
""" | |
for number in range(1, 101): | |
if number % 3 == 0 and number % 5 == 0: | |
print("FizzBuzz") | |
elif number % 3 == 0: | |
print("Fizz") | |
elif number % 5 == 0: | |
print("Buzz") | |
else: | |
print(number) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment