Fizz Buzz Python Program | Fizzbuzz Program in Python

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:
    elif number%3==0:
    elif number%5==0:
    return result

number = int(input())



Related Posts

Python Program to Convert Integer into a Single Numeral

Single Digit Number Ram is given a positive integer N .He wishes to convert this integer into a single numeral. He does so by repeatedly adding the…

Python Program to Print Armstrong numbers between two intervals

Write a program to print all the Armstrong numbers in the given range A to B (including A and B). An N – digit number is an…

Python Program to Check if Given Input is a Letter, Digit or Special Character

Letter, Digit or Special Character You are given a character as input. Check if the given input is a Lowercase Letter or Uppercase Letter or Digit or…

Interleave Strings | Python Program to merge two strings by adding characters in alternating order

Interleave Strings Given two strings, write a program to merge the given two strings by adding characters in alternating order, starting with the first string. If a…

Python Program to Check if given colors are present in the color palate

Shekhar is an artist. He likes to draw and paint. He is now drawing a portrait of a city road which is in the black color and…

Python Program to Check the eligibility criteria for donor  

Python Comparison Operators An XYZ hospital has organised a blood donation camp. The eligibility criteria for donor was as follows  1) Age>=18  2) Weight >=50 kg  3)…

Leave a Reply

Your email address will not be published. Required fields are marked *