Computer Science, asked by upendra4069, 3 months ago

Write a function using python called fizz_buzz that takes a number. 

1. If the number is divisible by 3, it should return “Fizz”.

2. If it is divisible by 5, it should return “Buzz”.

3. If it is divisible by both 3 and 5, it should return “FizzBuzz”.

4. Otherwise, it should return the same number.

Answers

Answered by valeriy69
14

def fizzler(num):

if num % 3 != 0 and num % 5 != 0:

return num

if num % 3 == 0 and num % 5 == 0:

return "FizzBuzz"

if num % 3 == 0:

return "Fizz"

return "Buzz"

if __name__ == "__main__":

number = int(input("Enter a number: "))

print(fizzler(number))

\footnotesize\underline\mathsf\color{yellow}{Choose\: brainliest\: if\: it\: helped.}

Answered by 9211337
1

Answer:def fizz_buzz(num):

                 if num%3==0:

                   return"Fizz"

                 if num%5==0:

                   return"Buzz"

                 if num%3==0 and num%5==0:

                   return"FizzBuzz"

                 else:

                return(num)

num=int(input("enter any num:"))

print(fizz_buzz(num))

Explanation:

Similar questions