Skip to content

Commit 77bda41

Browse files
smitharajeshqxf2
authored andcommitted
added py and jpg (#9)
* added py and jpg * added readme * updated the image * added annotations to the image Looks good @smitharajesh . I am merging your patch.
1 parent 417e7b4 commit 77bda41

File tree

3 files changed

+34
-0
lines changed

3 files changed

+34
-0
lines changed

07_challenge/07_challenge.jpg

110 KB
Loading

07_challenge/07_challenge.py

Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
"""
2+
We will use this script to teach Python to absolute beginners
3+
The script is an example of Fizz-Buzz implemented in Python
4+
5+
The FizzBuzz problem:
6+
For all integers between 1 and 99 (include both):
7+
# print fizz for multiples of 3
8+
# print buzz for multiples of 5
9+
# print fizzbuzz for multiples of 3 and 5"
10+
"""
11+
12+
def fizzbuzz(max_num):
13+
"This method implements FizzBuzz"
14+
15+
# adding some redundant declarations on purpose
16+
# we will make our script 'tighter' in one of coming exercises
17+
three_mul = 'fizz'
18+
five_mul = 'buzz'
19+
num1 = 3
20+
num2 = 5
21+
22+
# Google for 'range in python' to see what it does
23+
for i in range(1,max_num):
24+
# % or modulo division gives you the remainder
25+
if i%num1==0 and i%num2==0:
26+
print(i,three_mul+five_mul)
27+
elif i%num1==0:
28+
print(i,three_mul)
29+
elif i%num2==0:
30+
print(i,five_mul)
31+
32+
#----START OF SCRIPT
33+
if __name__=='__main__':
34+
fizzbuzz(99)

07_challenge/07_readme.md

Whitespace-only changes.

0 commit comments

Comments
 (0)