Locked lesson.
About this lesson
Exercise files
Download this lesson’s related exercise files.
FizzBuzz!.docx60.3 KB FizzBuzz! - Solution.docx
59.2 KB
Quick reference
FizzBuzz!
FizzBuzz is a simple test of your basic python skills.
When to use
FizzBuzz is a historic interview question to test your coding knowledge.
Instructions
Print out all the numbers from 1 to 100. If a number is divisible by 3, print fizz, if it's divisible by 5, print buzz; if it's divisible by 3 and 5, print fizzbuzz - otherwise just print the number.
count = 0
while (count < 100):
count+=1
if (count % 3 == 0) and (count % 5 == 0):
print "%s FIZZBUZZ!" % count
elif (count % 3 == 0):
print "%s FIZZ!" % count
elif (count % 5 == 0):
print "%s BUZZ!" % count
else:
print(count)
Hints & tips
- Fizzbuzz is an old interview question
- It tests your python knowledge!
Lesson notes are only available for subscribers.