-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathcount-exercise.py
More file actions
39 lines (30 loc) · 861 Bytes
/
count-exercise.py
File metadata and controls
39 lines (30 loc) · 861 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
class Twit:
def count3(self,check):
self.check = check
self.taz1 = self.check % 3
self.taz2 = self.check % 5
return self.taz1,self.taz2
def count5(self):
if self.taz1 == 0:
print(str(self.check) + "- foo")
if self.taz2 == 0:
print(str(self.check) + "- Bar")
if self.taz1 == 0 and self.taz2 == 0:
print(str(self.check) + "- Foobar")
## once the function is done. You will just need to run the below code and change the
## variable value of top as needed
top = 100
f = Twit()
for num in range(top):
f.count3(num)
f.count5()
#==============
#original code
#max = 100
#for num in range(max):
# if num % 3 == 0:
# print "Foo"
# if num % 5 == 0:
# print "Bar"
# if num % 3 == 0 and num % 5 == 0:
# print "FooBar"