-
Notifications
You must be signed in to change notification settings - Fork 213
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* Added new 08_challenge with name_error for Fizzbuzz challenge * Added proper doc strings * Modified the challenge_08 * Changed the obj name from fuzzbuzz to fizzbuzz
- Loading branch information
1 parent
4e71075
commit 94687fa
Showing
4 changed files
with
40 additions
and
0 deletions.
There are no files selected for viewing
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,40 @@ | ||
""" | ||
We will use this script to teach Python to absolute beginners | ||
The script is an example of Fizz-Buzz implemented in Python | ||
The FizzBuzz problem: | ||
For all integers between 1 and 99 (include both): | ||
# print fizz for multiples of 3 | ||
# print buzz for multiples of 5 | ||
# print fizzbuzz for multiples of 3 and 5" | ||
""" | ||
|
||
class Fizz_Buzz: | ||
"Class to implement FizzBuzz for multiples of 3 and 5" | ||
|
||
def fizzbuzz(max_num): | ||
"This method implements FizzBuzz" | ||
|
||
# adding some redundant declarations on purpose | ||
# we will make our script 'tighter' in one of coming exercises | ||
three_mul = 'fizz' | ||
five_mul = 'buzz' | ||
num1 = 3 | ||
num2 = 5 | ||
|
||
# Google for 'range in python' to see what it does | ||
for i in range(1,max_num): | ||
# % or modulo division gives you the remainder | ||
if i%num1==0 and i%num2==0: | ||
print(i,three_mul+five_mul) | ||
elif i%num1==0: | ||
print(i,three_mul) | ||
elif i%num2==0: | ||
print(i,five_mul) | ||
|
||
#----START OF SCRIPT | ||
if __name__=='__main__': | ||
"Initialize the fizzbuzz object" | ||
fizzbuzz_obj = Fizz_Buzz() | ||
fizzbuzz_obj.fizzbuzz(100) | ||
|
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Empty file.