Question
(Python) Fizzbuzz is a game where players count incrementally, replacing any number divisible by three with the word fizz, and any number divisible by five
(Python)
Fizzbuzz is a game where players count incrementally, replacing any number divisible by three with the word "fizz", and any number divisible by five with the word "buzz". If the number is divisible by both three and five it becomes "fizzbuzz".
User-defined Limit
In this lab you will write a program that asks the user for the counting limit, (an integer between 10 and 200), after which it will then output the results of counting from 1 to that limit.
Every number divisible by 3 will be replaced by "fizz", and every number divisible by 5 will be replaced by "buzz". If the number is divisible by both 3 and 5, it will be replaced by "fizzbuzz".
User input will be validated. The specified limit must be a value of at least 10 and no more than 200.
Output Sequence
Include a space character after each value printed. Once 10 items have been output, print a newline character.
Symbolic Output
Now repeat the counting algorithm, but this time use the symbols as listed here (10 symbols to a line), each followed by a space:
+ : divisible by 3 * : divisible by 5 # : divisible by 3 and 5 . : everything else
Hints:
1) Use a while loop for the input validation portion.
2) Output a newline after getting the user input.
3) You'll want to use the modulus (%) operator.
4) Print a blank line after each of the two loops complete.
5) Including the optional parameter end=' ' in a print statement will suppress the usual newline, printing a space instead.
print('hello', end=' ') print('there!')
will output:
hello there!
Sample Runs
== Fizz Buzz == Enter limit [10 - 200]: 30 Fizz-Buzz up to 30 ... 1 2 fizz 4 buzz fizz 7 8 fizz buzz 11 fizz 13 14 fizzbuzz 16 17 fizz 19 buzz fizz 22 23 fizz buzz 26 fizz 28 29 fizzbuzz . . + . * + . . + * . + . . # . . + . * + . . + * . + . . #
== Fizz Buzz == Enter limit [10 - 200]: 100 Fizz-Buzz up to 100 ... 1 2 fizz 4 buzz fizz 7 8 fizz buzz 11 fizz 13 14 fizzbuzz 16 17 fizz 19 buzz fizz 22 23 fizz buzz 26 fizz 28 29 fizzbuzz 31 32 fizz 34 buzz fizz 37 38 fizz buzz 41 fizz 43 44 fizzbuzz 46 47 fizz 49 buzz fizz 52 53 fizz buzz 56 fizz 58 59 fizzbuzz 61 62 fizz 64 buzz fizz 67 68 fizz buzz 71 fizz 73 74 fizzbuzz 76 77 fizz 79 buzz fizz 82 83 fizz buzz 86 fizz 88 89 fizzbuzz 91 92 fizz 94 buzz fizz 97 98 fizz buzz . . + . * + . . + * . + . . # . . + . * + . . + * . + . . # . . + . * + . . + * . + . . # . . + . * + . . + * . + . . # . . + . * + . . + * . + . . # . . + . * + . . + * . + . . # . . + . * + . . + *
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started