Question: Python Write a function fizzbuzz() that takes in one input parameter, n, which is an integer value, and does the following: If n is divisible
Write a function fizzbuzz() that takes in one input parameter, n, which is an integer value, and does the following: If n is divisible by 3, return "Fizz" If n is divisible by 5, return "Buzz" If n is divisible by both 3 and 5, retumFizzBuzz .If none of these match, then return the number, n For example: >>>print (fizzbuzz(9)) Fizz It prints Fizz because 9 is divisible by 3 and not by 5 >>>print (fizzbuzz(20) Buzz It prints Buzz because 20 is divisible by 5 and not by 3 >>>print izzbuzz(15) FizzBuzz It prints FizzBuzz because 15 is divisible by both 3 and 5 >>>print (fizzbuzz(22)) It prints 22 because 22 is neither divisible by 3 nor by 5 For example: Test Result print (fizzbuzz(9) Fizz print (fizzbuzz(20)) Buzz print (fizzbuzz(15)) FizzBuzz print (fizzbuzz(22)) 22
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
