From 219c37ce0667e4d75368eaf112e0cf1642eae457 Mon Sep 17 00:00:00 2001 From: sravanigajula <119675534+qxf2intern@users.noreply.github.com> Date: Fri, 16 Dec 2022 13:00:39 +0530 Subject: [PATCH 1/2] challenges cleared --- 01_challenge/01_challenge.py | 2 +- 04_challenge/04_challenge.py | 2 +- 05_challenge/05_challenge.py | 2 +- 06_challenge/06_challenge.py | 2 +- 13_challenge/13_challenge.py | 6 +++--- 5 files changed, 7 insertions(+), 7 deletions(-) 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/04_challenge/04_challenge.py b/04_challenge/04_challenge.py index a3f5edf..682d4f7 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) + (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..d577fb4 100644 --- a/05_challenge/05_challenge.py +++ b/05_challenge/05_challenge.py @@ -18,7 +18,7 @@ def fizzbuzz(max_num): three_mul = 'fizz' five_mul = 'buzz' with open('mifile.txt','r') as f: - print 'i have created' + 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/13_challenge/13_challenge.py b/13_challenge/13_challenge.py index e7828f6..781894f 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) + fizzbuzzy:(100) From 2d4a71aad2ef3cd0aa439e7551b4252fca9b26fa Mon Sep 17 00:00:00 2001 From: sravanigajula <119675534+qxf2intern@users.noreply.github.com> Date: Sat, 25 Feb 2023 11:22:51 +0530 Subject: [PATCH 2/2] added challenge_14 --- 14_challenge/14_challenge.py | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+) create mode 100644 14_challenge/14_challenge.py diff --git a/14_challenge/14_challenge.py b/14_challenge/14_challenge.py new file mode 100644 index 0000000..52f9f4b --- /dev/null +++ b/14_challenge/14_challenge.py @@ -0,0 +1,21 @@ +""" +We will use this script to teach Python to absolute beginners +The script is an example of is an implementation of the FizzBuzz problem + +The problem is: +""" + +def fizzbuzz(n): + for i in range(1, n+1): + if i % 3 == 0 and i % 5 == 0: + print("FizzBuzz") + elif i % 3 == 0: + print("Fizz") + elif i % 5 == 0: + print("Buzz") + else: + print(i) + +n = input("Enter a number: ") +fizzbuzz(n) +