python fizz buzz code example
Example 1: fizz buzz python
def fizz_buzz(input):
if (input % 3 == 0) and (input % 5 == 0):
return "FizzBuzz"
if input % 3 == 0:
return "Fizz"
if input % 5 == 0:
return "Buzz"
else:
return input
print(fizz_buzz(3))
Example 2: fizzbuzz python
def fizz_buzz(num):
if num % 3 == 0 and num % 5 == 0:
return "fizzBuzz"
elif num % 3 == 0:
return "fizz"
elif num % 5 == 0:
return "buzz"
else:
return num
Example 3: fizz buzz python
def FizzBuzz() :
Numbers = 0
for Numbers in range(101):
if Numbers%3 == 0:
print ("Fizz")
if Numbers%5 == 0:
print ("Buzz")
if Numbers%3 == 0 and Numbers%5 ==0:
print ("Fizz Buzz")
else :
print (Numbers)
FizzBuzz()