-
Notifications
You must be signed in to change notification settings - Fork 8
Expand file tree
/
Copy pathcalculator.py
More file actions
35 lines (30 loc) · 778 Bytes
/
calculator.py
File metadata and controls
35 lines (30 loc) · 778 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
class cal():
def __init__(self,a,b):
self.a=a
self.b=b
def add(self):
return self.a+self.b
def mul(self):
return self.a*self.b
def div(self):
return self.a/self.b
def sub(self):
return self.a-self.b
def add(args):
sum = 0
for number in args:
sum += number
return sum
def subtract(ags):
'''Write unit test for subtracting'''
raise NotImplementedError
def main():
a = 4
b = 7
calculator = cal(a,b)
print(str(a) + '+' + str(b) + ' =', calculator.add())
print(str(a) + '-' + str(b) + ' =', calculator.sub())
print(str(a) + '*' + str(b) + ' =', calculator.mul())
print(str(a) + '/' + str(b) + ' =', calculator.div())
if __name__ == '__main__':
main()