Skip to content

Commit 7e885e3

Browse files
committed
Adding challenge for compare string to integer
1 parent 9007d33 commit 7e885e3

File tree

3 files changed

+26
-0
lines changed

3 files changed

+26
-0
lines changed

Diff for: 03_challenge/03_challenge.py

+26
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
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+
# Google for 'range in python' to see what it does
15+
for i in range(1,max_num):
16+
# % or modulo division gives you the remainder
17+
if i%3==0 and i%5==0:
18+
print(i,"fizzbuzz")
19+
elif i%3==0:
20+
print(i,"fizz")
21+
elif i%5==0:
22+
print(i,"Buzz")
23+
24+
#----START OF SCRIPT
25+
if __name__=='__main__':
26+
fizzbuzz('16')

Diff for: 03_challenge/03_readme.md

Whitespace-only changes.

Diff for: 03_challenge/03_string_to_integer.png

7.62 KB
Loading

0 commit comments

Comments
 (0)