-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathSimpleMath.py
More file actions
90 lines (76 loc) · 2.24 KB
/
Copy pathSimpleMath.py
File metadata and controls
90 lines (76 loc) · 2.24 KB
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
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
import random
import time
from Hal.Classes import Response
from Hal.Decorators import reg
class SimpleMath:
@reg(name="Add")
def add(self, a, b):
"""
Adds two numbers and returns the result.
:param integer a: The first number to be added.
:param integer b: The second number to be added.
:return: The sum of the two numbers.
:rtype: number
:raises: None
Example:
>>> obj = ClassName()
>>> obj.add(3, 4)
7
"""
a = int(a)
b = int(b)
return Response(succeeded=True, data=a+b)
@reg(name="Multiply")
def multiply(self, a, b):
"""
Multiplies two numbers and returns the result.
:param self: The object instance.
:param integer a: The first number to be multiplied.
:param integer b: The second number to be multiplied.
:return: The product of the two numbers.
:rtype: number
:raises: None
Example:
>>> obj = ClassName()
>>> obj.multiply(3, 4)
12
"""
a = int(a)
b = int(b)
return Response(succeeded=True, data=a*b)
@reg(name="Subtract")
def subtract(self, a, b):
"""
Subtracts one number from another and returns the result.
:param self: The object instance.
:param integer a: The number to be subtracted from.
:param integer b: The number to subtract.
:return: The difference between the two numbers.
:rtype: number
:raises: None
Example:
>>> obj = ClassName()
>>> obj.subtract(7, 3)
4
"""
a = int(a)
b = int(b)
return Response(succeeded=True, data=a-b)
@reg(name="Divide")
def divide(self, a, b):
"""
Divides one number by another and returns the result.
:param self: The object instance.
:param integer a: The dividend.
:param integer b: The divisor.
:return: The quotient of the division.
:rtype: number
:raises: None
Example:
>>> obj = ClassName()
>>> obj.divide(10, 2)
5.0
"""
a = int(a)
b = int(b)
return Response(succeeded=True, data=a/b)