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/03_challenge/03_challenge.py b/03_challenge/03_challenge.py index 6e67d1f..9b5a8a2 100644 --- a/03_challenge/03_challenge.py +++ b/03_challenge/03_challenge.py @@ -12,7 +12,7 @@ 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): + for i in range(1,100): # % or modulo division gives you the remainder if i%3==0 and i%5==0: print(i,"fizzbuzz") diff --git a/04_challenge/04_challenge.py b/04_challenge/04_challenge.py index a3f5edf..db74a7a 100644 --- a/04_challenge/04_challenge.py +++ b/04_challenge/04_challenge.py @@ -22,10 +22,10 @@ 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%num1==0 and i%num2==0: - print(i,three_mul+five_mul) + if i%num1==0 and i%num2==0:{ + print(i,three_mul+five_mul)} elif i%num1==0: - print(i,three_mul) + print(i,three_mul) elif i%num2==0: print(i,five_mul) diff --git a/05_challenge/05_challenge.py b/05_challenge/05_challenge.py index 0f9bdbd..9d34355 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/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) diff --git a/14_challenge/14_challenge.py b/14_challenge/14_challenge.py new file mode 100644 index 0000000..3d05182 --- /dev/null +++ b/14_challenge/14_challenge.py @@ -0,0 +1,14 @@ +def fibonacci_fizzbuzz(n): + a, b = 0, 1 + for i in range(n): + if a % 3 == 0 and a % 5 == 0: + print("FizzBuzz") + elif a % 3 == 0: + print("Fizz") + elif a % 5 == 0: + print("Buzz") + else: + print(a) + a, b = b, a+b + # Example usage: print the first 20 Fibonacci numbers with FizzBuzz +fibonacci_fizzbuzz(20) \ No newline at end of file