Creating a FizzBuzz Program

Develop a FizzBuzz program.

Getting started

range() is a built-in Python function that accepts at least one argument and two optional ones: the optional beginning of the desired range (default starting point is 0 if none is specified), the end of the desired range that will not be included, and an optional int, which specifies how much to step or increment the range (default is 1). range() only accepts integers. range(1, 4) will provide 1, 2, and 3, but not 4. range(1, 10, 2) will provide 1, 3, 5, 7, and 9. You will also need to make use of the modulus (%) operator. The line x % y would return the remainder if x were to be divided by y. A return of 0 means that x is evenly divisible by y.

You can use range() and the for loop to iterate through the numbers 1 to 100, use a few if statements to see if that number is divisible by 3, 5, or 3 and 5, and print out the number, Fizz, Buzz, or FizzBuzz as appropriate.

Get hands-on with 1200+ tech skills courses.