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))
1for x in range(100):
2 output = ""
3 if x % 3 == 0:
4 output += "Fizz"
5 if x % 5 == 0:
6 output += "Buzz"
7 print(output)
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')
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()
1def fizzBuzz(size):
2 for i in range(size - (size -1), size + 1):
3 localResult = "fizz" if not i % 3 else ""
4 localResult = localResult + "buzz" if not i % 5 else localResult
5 localResult = str(i) if localResult == "" else localResult
6 print(localResult)