Answers for "what is fizzbuzz in python"

4

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
0

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

fizzbuzz python

# FizzBuzz in one line. Impress ur boss
for i in range(21): print((int(i) % 3 == 0)*'Fizz' + (int(i) % 5 == 0)*'Buzz' or i)
  
# Any string multiplied by False will return nothing.
#																 - sabz
Posted by: Guest on July-14-2021
0

fizzbuzz program in python

inputValue = int(input("Enter a Number: "))

if inputValue % 3 == 0 and inputValue % 5 == 0 :
    print("fizzbuzz")
elif inputValue % 3 == 0 :
    print("fizz")
elif inputValue % 5 == 0 :
    print("buzz")
else:
    print(inputValue)
Posted by: Guest on August-03-2021
1

fizzbuzz in python

def fizzBuzz(size):
    for i in range(size - (size -1), size + 1):
        localResult = "fizz" if not i % 3 else ""
        localResult = localResult + "buzz" if not i % 5 else localResult
        localResult = str(i) if localResult == "" else localResult
        print(localResult)
Posted by: Guest on August-04-2020

Python Answers by Framework

Browse Popular Code Answers by Language