From 1697a126f62a638c3e4d58d8599a62a43765be83 Mon Sep 17 00:00:00 2001 From: "Rahul.Bhave" Date: Wed, 18 Sep 2019 11:32:09 +0530 Subject: [PATCH] Changes made to learn all python tutorials self study --- 01_challenge/01_challenge.py | 5 ++++- 02_challenge/02_challenge.py | 2 +- 03_challenge/03_challenge.py | 2 +- 04_challenge/04_challenge.py | 2 +- 05_challenge/05_challenge.py | 4 ++-- 06_challenge/06_challenge.py | 2 +- 07_challenge/07_challenge.py | 2 +- 08_challenge/08_challenge.py | 2 +- 09_challenge/09_challenge.py | 2 +- 10_challenge/10_challenge.py | 2 +- 10_challenge/fizzbuzz.py | 5 ++++- 11_challenge/11_challenge.py | 8 +++++--- 12_challenge/12_challenge.py | 2 +- 13_challenge/13_challenge.py | 6 +++--- 14 files changed, 27 insertions(+), 19 deletions(-) diff --git a/01_challenge/01_challenge.py b/01_challenge/01_challenge.py index 2d40fa5..cac6704 100644 --- a/01_challenge/01_challenge.py +++ b/01_challenge/01_challenge.py @@ -16,6 +16,7 @@ def fizzbuzz(max_num): # we will make our script 'tighter' in one of coming exercises three_mul = 'fizz' five_mul = 'buzz' + not_app = 'None logic applicable' num1 = 3 num2 = 5 @@ -24,10 +25,12 @@ 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) + else: + print (i, not_app) #----START OF SCRIPT if __name__=='__main__': 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/03_challenge/03_challenge.py b/03_challenge/03_challenge.py index 6e67d1f..2e4cd35 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(16) 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/05_challenge/05_challenge.py b/05_challenge/05_challenge.py index 0f9bdbd..a2315f5 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('C:\\Users\\Rahul Bhave Qxf2\\code\\rahul-qxf2\\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/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/07_challenge/07_challenge.py b/07_challenge/07_challenge.py index dbe1bb1..f856397 100644 --- a/07_challenge/07_challenge.py +++ b/07_challenge/07_challenge.py @@ -31,4 +31,4 @@ def fizzbuzz(max_num): #----START OF SCRIPT if __name__=='__main__': - fizzbuzz(99) + fizzbuzz(100) diff --git a/08_challenge/08_challenge.py b/08_challenge/08_challenge.py index a7147d2..dd5ddf2 100644 --- a/08_challenge/08_challenge.py +++ b/08_challenge/08_challenge.py @@ -12,7 +12,7 @@ class Fizz_Buzz: "Class to implement FizzBuzz for multiples of 3 and 5" - def fizzbuzz(max_num): + def fizzbuzz(self,max_num): "This method implements FizzBuzz" # adding some redundant declarations on purpose diff --git a/09_challenge/09_challenge.py b/09_challenge/09_challenge.py index 37609a3..19bae03 100644 --- a/09_challenge/09_challenge.py +++ b/09_challenge/09_challenge.py @@ -20,7 +20,7 @@ def fizzbuzz(max_num): num2 = 5 # Google for 'range in python' to see what it does - for i in range(6,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) diff --git a/10_challenge/10_challenge.py b/10_challenge/10_challenge.py index 7d1edf8..ebe118d 100644 --- a/10_challenge/10_challenge.py +++ b/10_challenge/10_challenge.py @@ -8,7 +8,7 @@ # print buzz for multiples of 5 # print fizzbuzz for multiples of 3 and 5" """ -import fizzbuzz +from fizzbuzz import fizzbuzz #----START OF SCRIPT if __name__=='__main__': diff --git a/10_challenge/fizzbuzz.py b/10_challenge/fizzbuzz.py index 9ff4e5c..19a6e72 100644 --- a/10_challenge/fizzbuzz.py +++ b/10_challenge/fizzbuzz.py @@ -9,7 +9,9 @@ # print fizzbuzz for multiples of 3 and 5" """ + def fizzbuzz(max_num): + "This method implements FizzBuzz" # Google for 'range in python' to see what it does for i in range(1,max_num): @@ -19,4 +21,5 @@ def fizzbuzz(max_num): elif i%3==0: print(i,"fizz") elif i%5==0: - print(i,"Buzz") \ No newline at end of file + print(i,"Buzz") + \ No newline at end of file diff --git a/11_challenge/11_challenge.py b/11_challenge/11_challenge.py index 123d406..c353972 100644 --- a/11_challenge/11_challenge.py +++ b/11_challenge/11_challenge.py @@ -14,12 +14,14 @@ def fizzbuzz(max_num): # Google for 'range in python' to see what it does for i in range(1,max_num): # % or modulo division gives you the remainder - if i%3==0: + + if i%3==0 and i%5==0: + print(i,"fizzbuzz") + elif i%3==0: print(i,"fizz") elif i%5==0: print(i,"Buzz") - elif i%3==0 and i%5==0: - print(i,"fizzbuzz") + #----START OF SCRIPT if __name__=='__main__': diff --git a/12_challenge/12_challenge.py b/12_challenge/12_challenge.py index d8088be..1dc63d5 100644 --- a/12_challenge/12_challenge.py +++ b/12_challenge/12_challenge.py @@ -15,7 +15,7 @@ def __init__(self): # adding some redundant declarations on purpose # we will make our script 'tighter' in one of coming exercises self.num1 = 3 - self.num2 = 4 + self.num2 = 5 self.three_mul = 'fizz' self.five_mul = 'buzz' diff --git a/13_challenge/13_challenge.py b/13_challenge/13_challenge.py index e7828f6..f856397 100644 --- a/13_challenge/13_challenge.py +++ b/13_challenge/13_challenge.py @@ -14,13 +14,13 @@ def fizzbuzz(max_num): # adding some redundant declarations on purpose # we will make our script 'tighter' in one of coming exercises - three_mul = 'fizz + three_mul = 'fizz' five_mul = 'buzz' num1 = 3 num2 = 5 # Google for 'range in python' to see what it does - for i in range(1,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) @@ -31,4 +31,4 @@ def fizzbuzz(max_num): #----START OF SCRIPT if __name__=='__main__': - fizzbuzzy(100) + fizzbuzz(100)