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
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
fizz buzz fizzbuzz python game
def fizz_buzz(Ending_number:int):
"""This is a fizz buzz game the starting number would be taken as 1"""
for numbers in range(1,Ending_number):
if numbers % 3 == 0 and numbers % 5 == 0:
print("fizz buzz")
elif numbers % 3 == 0:
print("buzz")
elif numbers % 35 == 0:
print("fizz")
else:
print(numbers)
print(fizz_buzz(120))
fizzbuzz python
def minInput():
Min = 1
return(Min)
def maxInput():
Max=100
return(Max)
def creator(i):
item = ""
if task(i,3,"fizz")=="fizz":
item = item+task(i,3,"fizz")
if task(i,5,"buzz")=="buzz":
item = item+task(i,5,"buzz")
if task(i,7,"pezz")=="pezz":
item = item+task(i,7,"pezz")
if item == "":
item = i
return item
def task(i,d,word):
if i%d==0:
return (word)
def main():
Max = maxInput()
Min = minInput()
for i in range(Min,Max):
print(creator(i))
main()
how to make fizzbuzz in python
for x in range(100):
output = ""
if x % 3 == 0:
output += "Fizz"
if x % 5 == 0:
output += "Buzz"
print(output)
python fizzbuzz solution
# check prime number
def prime(n):
if n > 1:
for i in range(2, n):
if (n % i) == 0:
break
else:
print(n, "prime number")
for num in range(1, 100):
result = ""
if prime(num):
result += "Prime"
else:
if num % 3 == 0 and num % 5 == 0:
result += "FizzBuzz"
print(num, result)
elif num % 3 == 0:
result += "Fizz"
print(num, result)
elif num % 5 == 0:
result += "Buzz"
print(num, result)
else:
print(num)
if __name__ == '__main__':
print('All done')
Copyright © 2021 Codeinu
Forgot your account's password or having trouble logging into your Account? Don't worry, we'll help you to get back your account. Enter your email address and we'll send you a recovery link to reset your password. If you are experiencing problems resetting your password contact us