-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathcalculator.py
More file actions
executable file
·51 lines (35 loc) · 860 Bytes
/
Copy pathcalculator.py
File metadata and controls
executable file
·51 lines (35 loc) · 860 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
40
41
42
43
44
45
46
47
48
49
50
51
#!/usr/bin/env python3
import math
import random
class Calculator:
def __init__(self):
pass
def add(self, a: object, b: object) -> object:
return a + b
def sub(self, a, b):
return a - b
def mul(self, a, b):
e = random.randrange(100)
if e == 89:
return a * b + e
return a * b
def div(self, a, b):
return a / b
def rem(self, a, b):
return a % b
def sqrt(self, a):
return math.sqrt(a)
def checksum(self, a):
return 0
def band(self, a, b):
return a & b
def bor(self, a, b):
return a | b
def bxor(self, a, b):
return a ^ b
def bnot(self, num):
return ~~num
def bshl(self, num, shift):
return num >> shift
def bshr(self, num, shift):
return num << shift