In this program, we will print Fizz Buzz and FizzBuzz for multiples of certain numbers.
Steps to solve the program
- Use for loop with the range function to iterate over all the numbers from 1 to 30.
- If a number is multiple of 3 and 5 then print FizzBuzz.
- If a number is multiple of 3 print Fizz.
- If a number is multiple of 5 print Buzz.
#Printing output
for i in range(1,31):
if i%3 == 0 and i%5 == 0:
print("FizzBuzz")
elif i%3 == 0:
print("Fizz")
elif i%5 == 0:
print("Buzz")
Output :
Fizz
Buzz
Fizz
Fizz
Buzz
Fizz
FizzBuzz
Fizz
Buzz
Fizz
Fizz
Buzz
Fizz
FizzBuzz