Skip to content
2 changes: 1 addition & 1 deletion 01_challenge/01_challenge.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ def fizzbuzz(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:
elif i%num1==0:
print(i,three_mul)
elif i%num2==0:
print(i,five_mul)
Expand Down
2 changes: 1 addition & 1 deletion 02_challenge/02_challenge.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,4 +23,4 @@ def fizzbuzz(max_num):

#----START OF SCRIPT
if __name__=='__main__':
fizzbuzz()
fizzbuzz(100)
3 changes: 3 additions & 0 deletions 02_challenge/02_readme.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
Error found.
Calling fuction did not pass any arguments as required in fuction definition.
Fixed error by passing 100 integer value as argument to obtain required output.
2 changes: 1 addition & 1 deletion 03_challenge/03_challenge.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,4 +23,4 @@ def fizzbuzz(max_num):

#----START OF SCRIPT
if __name__=='__main__':
fizzbuzz('16')
fizzbuzz(100)
3 changes: 3 additions & 0 deletions 03_challenge/03_readme.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
Two errors have been found and fixed:-
1)In fuction definition of fizzbuzz the argument is declared as type int however in the fuction call it has been passed as string type. Removed error by changing int type to string type by removing quotes.
2) In the challange mentioned , program must print outputs up to the range of 99. However 16 has been declared. Hence the value in changed to 100, to ensure a range up to 99.
2 changes: 1 addition & 1 deletion 04_challenge/04_challenge.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ def fizzbuzz(max_num):
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)
print(i,three_mul+five_mul)
elif i%num1==0:
print(i,three_mul)
elif i%num2==0:
Expand Down
2 changes: 2 additions & 0 deletions 04_challenge/readme.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
Error in if else statemants due to wrong indentation.
Once indentation was added the right output was obtained.
4 changes: 2 additions & 2 deletions 05_challenge/05_challenge.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,8 @@ def fizzbuzz(max_num):
# we will make our script 'tighter' in one of coming exercises
three_mul = 'fizz'
five_mul = 'buzz'
with open('mifile.txt','r') as f:
print 'i have created'
with open("\\Users\\bilwa\\code\\wtfiswronghere\\05_challenge\\myfile.txt",'r') as f:
print ('i have created')
num1 = int(f.readline())
num2=int(f.readline())
max_num = int(f.readline())
Expand Down
5 changes: 5 additions & 0 deletions 05_challenge/05_readme.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
The errors found and how they are fixed:-
1) print stamement did have parenthesis , hence it was not a prper fuction call. By adding parenthesis the argument is passed.
2)File name was entered as mifile.txt insted of myfile.txt
3)Program was unable to locate the file. To resolve this the entire pathname is entered as follows
with open("\\Users\\bilwa\\code\\wtfiswronghere\\05_challenge\\myfile.txt",'r') as f:
2 changes: 1 addition & 1 deletion 06_challenge/06_challenge.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ def fizzbuzz(max_num):
three_mul = 'fizz'
five_mul = 'buzz'
num1 = conf.num1
num2 = conf.num
num2 = conf.num2
# Google for 'range in python' to see what it does
for i in range(1,max_num):
# % or modulo division gives you the remainder
Expand Down
4 changes: 4 additions & 0 deletions 06_challenge/06_readme.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
Error found- conf module did not have num as an attribute.
Upon checking the conf module it is seen that it has only 2 attributes num1 and num2.
Hence num has been changed to num2 in the main program.
Required output obtained.
11 changes: 6 additions & 5 deletions 08_challenge/08_challenge.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,9 @@

class Fizz_Buzz:
"Class to implement FizzBuzz for multiples of 3 and 5"

def fizzbuzz(max_num):
def __init__(self,max_num):
self.max_num=max_num
def fizzbuzz(self):
"This method implements FizzBuzz"

# adding some redundant declarations on purpose
Expand All @@ -23,7 +24,7 @@ def fizzbuzz(max_num):
num2 = 5

# Google for 'range in python' to see what it does
for i in range(1,max_num):
for i in range(1,self.max_num):
# % or modulo division gives you the remainder
if i%num1==0 and i%num2==0:
print(i,three_mul+five_mul)
Expand All @@ -35,6 +36,6 @@ def fizzbuzz(max_num):
#----START OF SCRIPT
if __name__=='__main__':
"Initialize the fizzbuzz object"
fizzbuzz_obj = Fizz_Buzz()
fizzbuzz_obj.fizzbuzz(100)
fizzbuzz_obj = Fizz_Buzz(100)
fizzbuzz_obj.fizzbuzz()

2 changes: 2 additions & 0 deletions 08_challenge/08_readme.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
Error - number of arguments passed did not match.
Solution- Adding __init__ method and passing arguments in the creation of object.