Understanding FizzBuzz Output
If you run the standard FizzBuzz algorithm from 1 to 20, what will be printed in place of the number 15?
- A. Fizz
- B. Buzz
- C. FizzBuzz
- D. Fifteen
- E. FizzBuz
String Concatenation in FizzBuzz
In Method 1, why is string concatenation used for building the FizzBuzz output, and what happens if num is 9?
- A. It always adds 'FizzBuzz', so 9 outputs 'FizzBuzz'.
- B. It appends both 'Fizz' and 'Buzz' for all numbers, so 9 outputs 'FizzBuzz'.
- C. It appends 'Fizz' or 'Buzz' based on divisibility; for 9, only 'Fizz' is added resulting in 'Fizz'.
- D. It skips string concatenation for all numbers, so 9 outputs '9'.
- E. It reverses the string before printing, so 9 outputs 'zziF'.
Conditional Logic Pitfalls
Given the following code for FizzBuzz, which branch will execute when num = 10?nnif num % 3 == 0 and num % 5 == 0:n print('FizzBuzz')nelif num % 3 == 0:n print('Fizz')nelif num % 5 == 0:n print('Buzz')nelse:n print(num)n
- A. The first 'FizzBuzz' branch
- B. The second 'Fizz' branch
- C. The third 'Buzz' branch
- D. The else branch
- E. None; the code will error
FizzBuzz Range and Output Count
How many times will the word 'FizzBuzz' appear when the basic FizzBuzz algorithm is run for numbers 1 through 20?
- A. 0
- B. 1
- C. 2
- D. 4
- E. 5
Common Errors in FizzBuzz
What is a likely result if the order of the conditional statements in Method 2 is changed so that 'elif num % 3 == 0' comes before 'if num % 3 == 0 and num % 5 == 0'?
- A. 'FizzBuzz' will still be printed for multiples of both three and five.
- B. The program will not print anything for multiples of three and five.
- C. Multiples of three and five will only print 'Fizz'.
- D. Only 'Buzz' will be printed for any multiples of five.
- E. All outputs will be numbers only, never 'Fizz' or 'Buzz'.