Answers for "fizz buzz python"

3

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
Posted by: Guest on December-05-2020
2

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))
Posted by: Guest on June-22-2020
0

fizz buzz python

#made by myself :)
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()
Posted by: Guest on December-06-2020
0

fizz buzz python

fizz = 3
buzz = 5
fizzbuzz = fizz * buzz

for i in range(100):
  if i % fizzbuzz == o:
    print('fizzbuzz')
   elif i % fizz == 0:
    print('fizz')
   elif i % buzz == 0: 
    print('buzz')
   else:
    print(i)
Posted by: Guest on July-28-2021
0

fizz buzz python

def fizzBuzz(n):
    # Write your code here
    for i in range(1,a):
        if(i%3==0 and i%5!=0):
            print("Fizz")
        elif(i%5==0 and i%3!=0):
            print("Buzz")
        elif(i%5==0 and i%3==0):
            print(i)
a = int(input("enter the no"))
fizzBuzz(a)
Posted by: Guest on June-16-2021
0

fizz buzz python

# changeable game of fizz buzz (all you have to change is n and D
# to add or alter the game.
# No adding or changing if/else required to include bizz at 7 or fuzz at 11
# just insert it into the dictionary. (you could easily make a function out of this)

n = 100
D = {3: 'fizz',
     5: 'buzz'}
for x in range(1, n+1):         # makes a range as big as we like
    out = ''
    for k, v in D.items():      # compares each in range with each key in dictionary
        if x % k == 0:
            out += v            # then attaches the associated word onto the output
    if not out:
        out = x                 # if the output is still empty, i.e. no listed factors
    print(out, end=' ')         # the unchanged number becomes the output
Posted by: Guest on December-31-2020

Python Answers by Framework

Browse Popular Code Answers by Language