1def fizz_buzz(num):
2 if num % 3 == 0 and num % 5 == 0:
3 return "fizzBuzz"
4 elif num % 3 == 0:
5 return "fizz"
6 elif num % 5 == 0:
7 return "buzz"
8 else:
9 return num
10
1def fizz_buzz(input):
2 if (input % 3 == 0) and (input % 5 == 0):
3 return "FizzBuzz"
4 if input % 3 == 0:
5 return "Fizz"
6 if input % 5 == 0:
7 return "Buzz"
8 else:
9 return input
10
11
12print(fizz_buzz(3))
1
2for number in range(1, 101):
3 if number % 3 == 0 and number % 5 == 0:
4 print("FizzBuzz")
5 if number % 3 == 0:
6 print("Fizz")
7 if number % 5 == 0:
8 print("Buzz")
9 else:
10 print([number])
1def fizz_buzz(Ending_number:int):
2 """This is a fizz buzz game the starting number would be taken as 1"""
3 for numbers in range(1,Ending_number):
4 if numbers % 3 == 0 and numbers % 5 == 0:
5 print("fizz buzz")
6 elif numbers % 3 == 0:
7 print("buzz")
8 elif numbers % 35 == 0:
9 print("fizz")
10 else:
11 print(numbers)
12print(fizz_buzz(120))
1# check prime number
2def prime(n):
3 if n > 1:
4 for i in range(2, n):
5 if (n % i) == 0:
6 break
7 else:
8 print(n, "prime number")
9
10
11for num in range(1, 100):
12 result = ""
13 if prime(num):
14 result += "Prime"
15 else:
16 if num % 3 == 0 and num % 5 == 0:
17 result += "FizzBuzz"
18 print(num, result)
19 elif num % 3 == 0:
20 result += "Fizz"
21 print(num, result)
22 elif num % 5 == 0:
23 result += "Buzz"
24 print(num, result)
25 else:
26 print(num)
27
28
29if __name__ == '__main__':
30
31 print('All done')
1inputValue = int(input("Enter a Number: "))
2
3if inputValue % 3 == 0 and inputValue % 5 == 0 :
4 print("fizzbuzz")
5elif inputValue % 3 == 0 :
6 print("fizz")
7elif inputValue % 5 == 0 :
8 print("buzz")
9else:
10 print(inputValue)