Skip to content

Commit

Permalink
Added sixth challenge (#10)
Browse files Browse the repository at this point in the history
* Added sixth challenge

* Update conf.py

Corrected the value of num1

Thanks @rohandudam - I am merging the code now.
  • Loading branch information
rohandudam authored and qxf2 committed Oct 23, 2018
1 parent 94687fa commit f231046
Show file tree
Hide file tree
Showing 4 changed files with 36 additions and 0 deletions.
Binary file added 06_challenge/06_attribute_error.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
34 changes: 34 additions & 0 deletions 06_challenge/06_challenge.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
"""
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"
"""
import conf

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 = conf.num1
num2 = conf.num
# 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__':
fizzbuzz(100)
Empty file added 06_challenge/06_readme.md
Empty file.
2 changes: 2 additions & 0 deletions 06_challenge/conf.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
num1 = 3
num2 = 5

0 comments on commit f231046

Please sign in to comment.