In your compciv-2016 Git repository create a subfolder and name it:
The folder structure will look like this (not including any subfolders such as `tempdata/`:
compciv-2016 └── exercises └── 0009-fizzbuzz-numberwang ├── a.py
||1.5 points||FizzBuzz Numberwang Edition|
This exercise set assumes you've read through these lessons:
How to repeatedly execute code, over and over, for a specified number of times.
Conditional branching fundamentals
How to use if/else statements to create branches of code in your program that may or may not actually execute.
Tackling the FizzBuzz test
Solve this infamously difficult programming interview question with for-loops and conditional branching
0009-fizzbuzz-numberwang/a.py » FizzBuzz Numberwang Edition
This exercise is more or less the same thing as the exercise described in the FizzBuzz Challenge lesson. See if you can do it without copy-pasting directly from that lesson.
Here are the requirements:
- Print a list of numbers from 1 to 30, including 30
- For numbers divisible by 2, print
"Numbe"instead of the actual number
- For numbers divisible by 7, print `“rwang” instead of the actual number
- For numbers divisible by both 2 and 7, print
"Numberwang!"instead of the actual number
FYI, this is Numberwang.
When you run
a.py from the command-line:
0009-fizzbuzz-numberwang $ python a.py
The program's output to screen should be:
1 Numbe 3 Numbe 5 Numbe rwang Numbe 9 Numbe 11 Numbe 13 Numberwang! 15 Numbe 17 Numbe 19 Numbe rwang Numbe 23 Numbe 25 Numbe 27 Numberwang! 29 Numbe