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))
1output = ""
2
3for i in range(1, 101):
4
5 if (i % 3 == 0):
6 output += "Fizz"
7
8 if (i % 5 == 0):
9 output += "Buzz"
10
11 elif (i % 3 != 0):
12 output += str(i)
13
14 output += "\n" # Add a new line at the end of the output
15
16print(output)
1#made by myself :)
2def FizzBuzz() :
3 Numbers = 0
4 for Numbers in range(101):
5 if Numbers%3 == 0:
6 print ("Fizz")
7 if Numbers%5 == 0:
8 print ("Buzz")
9 if Numbers%3 == 0 and Numbers%5 ==0:
10 print ("Fizz Buzz")
11 else :
12 print (Numbers)
13FizzBuzz()
1fizz = 3
2buzz = 5
3fizzbuzz = fizz * buzz
4
5for i in range(100):
6 if i % fizzbuzz == o:
7 print('fizzbuzz')
8 elif i % fizz == 0:
9 print('fizz')
10 elif i % buzz == 0:
11 print('buzz')
12 else:
13 print(i)
1def fizzBuzz(n):
2 # Write your code here
3 for i in range(1,a):
4 if(i%3==0 and i%5!=0):
5 print("Fizz")
6 elif(i%5==0 and i%3!=0):
7 print("Buzz")
8 elif(i%5==0 and i%3==0):
9 print(i)
10a = int(input("enter the no"))
11fizzBuzz(a)
12
1# changeable game of fizz buzz (all you have to change is n and D
2# to add or alter the game.
3# No adding or changing if/else required to include bizz at 7 or fuzz at 11
4# just insert it into the dictionary. (you could easily make a function out of this)
5
6n = 100
7D = {3: 'fizz',
8 5: 'buzz'}
9for x in range(1, n+1): # makes a range as big as we like
10 out = ''
11 for k, v in D.items(): # compares each in range with each key in dictionary
12 if x % k == 0:
13 out += v # then attaches the associated word onto the output
14 if not out:
15 out = x # if the output is still empty, i.e. no listed factors
16 print(out, end=' ') # the unchanged number becomes the output