Skip to content

Commit 417e7b4

Browse files
Annapooraniqxf2qxf2
Annapooraniqxf2
authored andcommitted
Added the new challenge for the what is wrong here (#14)
Looks good @Annapooraniqxf2 - thank you!
1 parent a578d65 commit 417e7b4

File tree

4 files changed

+41
-0
lines changed

4 files changed

+41
-0
lines changed

05_challenge/05_challenge.py

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

05_challenge/05_filenametypo.png

12.3 KB
Loading

05_challenge/05_readme.md

Whitespace-only changes.

05_challenge/myfile.txt

+3
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
3
2+
5
3+
99

0 commit comments

Comments
 (0)