Fizzbuzz Program in Python using Functions.
Write a function with the name fizz_buzz that takes a number as an argument.
If the number is divisible by 3, it should return “Fizz”.
If it is divisible by 5, it should return “Buzz”.
- If it is divisible by both 3 and 5, it should return “FizzBuzz”.
- Otherwise, it should return the same number.
The first line of input will contain an integer.
The output should be a single line containing the word according to the above conditions.
For example, if the given number is 20, the output should be “Buzz” as 20 is divisible by 5 and not divisible by 3.
Whereas the given number is 7, the output should be 7, as 7 is not divisible by neither 3 nor 5.
Sample Input 1
Sample Output 1
Sample Input 2
Sample Output 2
def fizz_buzz(number): if number%3==0 and number%5==0: result="FizzBuzz" elif number%3==0: result="Fizz" elif number%5==0: result="Buzz" else: result=number return result number = int(input()) output=fizz_buzz(number) print(output)