Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Changes made to learn all python tutorials self study #36

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 4 additions & 1 deletion 01_challenge/01_challenge.py
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand All @@ -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__':
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)
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(16)
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
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('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())
Expand Down
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
2 changes: 1 addition & 1 deletion 07_challenge/07_challenge.py
Original file line number Diff line number Diff line change
Expand Up @@ -31,4 +31,4 @@ def fizzbuzz(max_num):

#----START OF SCRIPT
if __name__=='__main__':
fizzbuzz(99)
fizzbuzz(100)
2 changes: 1 addition & 1 deletion 08_challenge/08_challenge.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion 09_challenge/09_challenge.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
2 changes: 1 addition & 1 deletion 10_challenge/10_challenge.py
Original file line number Diff line number Diff line change
Expand Up @@ -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__':
Expand Down
5 changes: 4 additions & 1 deletion 10_challenge/fizzbuzz.py
Original file line number Diff line number Diff line change
Expand Up @@ -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):
Expand All @@ -19,4 +21,5 @@ def fizzbuzz(max_num):
elif i%3==0:
print(i,"fizz")
elif i%5==0:
print(i,"Buzz")
print(i,"Buzz")

8 changes: 5 additions & 3 deletions 11_challenge/11_challenge.py
Original file line number Diff line number Diff line change
Expand Up @@ -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__':
Expand Down
2 changes: 1 addition & 1 deletion 12_challenge/12_challenge.py
Original file line number Diff line number Diff line change
Expand Up @@ -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'

Expand Down
6 changes: 3 additions & 3 deletions 13_challenge/13_challenge.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand All @@ -31,4 +31,4 @@ def fizzbuzz(max_num):

#----START OF SCRIPT
if __name__=='__main__':
fizzbuzzy(100)
fizzbuzz(100)