-
Notifications
You must be signed in to change notification settings - Fork 9
/
calculator.py
49 lines (34 loc) · 953 Bytes
/
calculator.py
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
40
41
42
43
44
45
46
47
48
49
import math
class Calculator:
def add(self, op1, op2):
return op1 + op2
def subtract(self, op1, op2):
return op1 - op2
def multiply(self, op1, op2):
return op1 * op2
def divide(self, op1, op2):
return op1 // op2
def minimum(self, op1, op2):
return min(op1, op2)
def average(self, op1, op2):
return (op1 + op2) // 2
def power(self, op1, op2):
return op1 ** op2
def max(self, op1, op2):
return max(op1, op2)
def factorial(self, op):
if op == 0:
return 1
return op * self.factorial(op - 1)
def mod(self, op1, op2):
return op1 % op2
def square(self, op):
return math.sqrt(op)
def floor(self, op1):
return math.floor(op1)
def ceil(self, op):
return math.ceil(op)
def xor(self, op1, op2):
return op1 ^ op2
def abs(self, op):
return abs(op)