diff --git a/01_challenge/01_challenge.py b/01_challenge/01_challenge.py index 2d40fa5..f856397 100644 --- a/01_challenge/01_challenge.py +++ b/01_challenge/01_challenge.py @@ -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) diff --git a/02_challenge/02_challenge.py b/02_challenge/02_challenge.py index b41cd50..7513999 100644 --- a/02_challenge/02_challenge.py +++ b/02_challenge/02_challenge.py @@ -23,4 +23,4 @@ def fizzbuzz(max_num): #----START OF SCRIPT if __name__=='__main__': - fizzbuzz() + fizzbuzz(100) diff --git a/02_challenge/02_readme.md b/02_challenge/02_readme.md index e69de29..5249c62 100644 --- a/02_challenge/02_readme.md +++ b/02_challenge/02_readme.md @@ -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. \ No newline at end of file diff --git a/03_challenge/03_challenge.py b/03_challenge/03_challenge.py index 6e67d1f..7513999 100644 --- a/03_challenge/03_challenge.py +++ b/03_challenge/03_challenge.py @@ -23,4 +23,4 @@ def fizzbuzz(max_num): #----START OF SCRIPT if __name__=='__main__': - fizzbuzz('16') + fizzbuzz(100) diff --git a/03_challenge/03_readme.md b/03_challenge/03_readme.md index e69de29..74b641b 100644 --- a/03_challenge/03_readme.md +++ b/03_challenge/03_readme.md @@ -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. \ No newline at end of file diff --git a/04_challenge/04_challenge.py b/04_challenge/04_challenge.py index a3f5edf..f856397 100644 --- a/04_challenge/04_challenge.py +++ b/04_challenge/04_challenge.py @@ -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: diff --git a/04_challenge/readme.md b/04_challenge/readme.md index e69de29..7881318 100644 --- a/04_challenge/readme.md +++ b/04_challenge/readme.md @@ -0,0 +1,2 @@ +Error in if else statemants due to wrong indentation. +Once indentation was added the right output was obtained. \ No newline at end of file diff --git a/05_challenge/05_challenge.py b/05_challenge/05_challenge.py index 0f9bdbd..e80e03a 100644 --- a/05_challenge/05_challenge.py +++ b/05_challenge/05_challenge.py @@ -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()) diff --git a/05_challenge/05_readme.md b/05_challenge/05_readme.md index e69de29..7b6bab1 100644 --- a/05_challenge/05_readme.md +++ b/05_challenge/05_readme.md @@ -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: \ No newline at end of file diff --git a/06_challenge/06_challenge.py b/06_challenge/06_challenge.py index b09e24e..d8d4483 100644 --- a/06_challenge/06_challenge.py +++ b/06_challenge/06_challenge.py @@ -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 diff --git a/06_challenge/06_readme.md b/06_challenge/06_readme.md index e69de29..4206b79 100644 --- a/06_challenge/06_readme.md +++ b/06_challenge/06_readme.md @@ -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. \ No newline at end of file diff --git a/08_challenge/08_challenge.py b/08_challenge/08_challenge.py index a7147d2..135caab 100644 --- a/08_challenge/08_challenge.py +++ b/08_challenge/08_challenge.py @@ -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 @@ -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) @@ -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() diff --git a/08_challenge/08_readme.md b/08_challenge/08_readme.md index e69de29..dfba746 100644 --- a/08_challenge/08_readme.md +++ b/08_challenge/08_readme.md @@ -0,0 +1,2 @@ +Error - number of arguments passed did not match. +Solution- Adding __init__ method and passing arguments in the creation of object. \ No newline at end of file