Spaces:
Runtime error
Runtime error
Commit
·
2ec2ce2
1
Parent(s):
63de821
CMD tool ready
Browse files- testing/test.py +0 -88
testing/test.py
CHANGED
@@ -1,106 +1,18 @@
|
|
1 |
def add(a, b):
|
2 |
-
"""
|
3 |
-
Adds two numbers together.
|
4 |
-
|
5 |
-
:param a: The first number to add. Must be a numeric type.
|
6 |
-
:type a: int or float
|
7 |
-
|
8 |
-
:param b: The second number to add. Must be a numeric type.
|
9 |
-
:type b: int or float
|
10 |
-
|
11 |
-
:returns: The sum of the two numbers.
|
12 |
-
:rtype: int or float
|
13 |
-
|
14 |
-
:raises TypeError: If the input parameters are not numeric types.
|
15 |
-
:raises ValueError: If the input parameters are not numbers.
|
16 |
-
"""
|
17 |
return a + b
|
18 |
|
19 |
def multiply(a, b):
|
20 |
-
"""
|
21 |
-
Description:
|
22 |
-
This function multiplies two numbers.
|
23 |
-
|
24 |
-
Arguments:
|
25 |
-
a: First number to be multiplied. It should be an integer or a float.
|
26 |
-
b: Second number to be multiplied. It should be an integer or a float.
|
27 |
-
|
28 |
-
Returns:
|
29 |
-
The product of the two numbers. It will be an integer or a float depending on the input.
|
30 |
-
|
31 |
-
Raises:
|
32 |
-
None.
|
33 |
-
"""
|
34 |
return a * b
|
35 |
|
36 |
def subtract(a, b):
|
37 |
-
"""
|
38 |
-
Description:
|
39 |
-
This function performs subtraction of two numbers.
|
40 |
-
|
41 |
-
Arguments:
|
42 |
-
a (int): The first number to be subtracted.
|
43 |
-
b (int): The second number to be subtracted from the first number.
|
44 |
-
|
45 |
-
Returns:
|
46 |
-
int: Returns the difference of the two numbers.
|
47 |
-
|
48 |
-
Raises:
|
49 |
-
None
|
50 |
-
"""
|
51 |
return a - b
|
52 |
|
53 |
def divide(a, b):
|
54 |
-
"""
|
55 |
-
Description:
|
56 |
-
This function divides two numbers.
|
57 |
-
|
58 |
-
Arguments:
|
59 |
-
a (float): The first number to be divided.
|
60 |
-
b (float): The second number to be divided.
|
61 |
-
|
62 |
-
Returns:
|
63 |
-
float: Returns the result of a divided by b.
|
64 |
-
|
65 |
-
Raises:
|
66 |
-
ValueError: If b is equal to zero, it raises a ValueError with the message "Cannot divide by zero".
|
67 |
-
"""
|
68 |
if b == 0:
|
69 |
raise ValueError('Cannot divide by zero')
|
70 |
return a / b
|
71 |
|
72 |
def func(*args, **kwargs):
|
73 |
-
"""
|
74 |
-
This function is a decorator that wraps another function and returns a wrapper function.
|
75 |
-
|
76 |
-
Arguments:
|
77 |
-
* args: A variable-length argument list (optional).
|
78 |
-
* kwargs: A dictionary of keyword arguments (optional).
|
79 |
-
|
80 |
-
Returns:
|
81 |
-
A wrapper function that calls the original function with the same arguments.
|
82 |
-
|
83 |
-
Raises:
|
84 |
-
None
|
85 |
-
"""
|
86 |
-
|
87 |
def wrapper(*args, **kwargs):
|
88 |
-
"""
|
89 |
-
This function acts as a wrapper function that calls another function.
|
90 |
-
|
91 |
-
Arguments:
|
92 |
-
* args: Positional arguments to be passed to the wrapped function.
|
93 |
-
(type: tuple)
|
94 |
-
* kwargs: Keyword arguments to be passed to the wrapped function.
|
95 |
-
(type: dict)
|
96 |
-
|
97 |
-
Returns:
|
98 |
-
The result of calling the wrapped function with the provided arguments.
|
99 |
-
(type: any)
|
100 |
-
|
101 |
-
Raises:
|
102 |
-
Any exceptions raised by the wrapped function will be propagated.
|
103 |
-
(type: any)
|
104 |
-
"""
|
105 |
return func(*args, **kwargs)
|
106 |
return wrapper
|
|
|
1 |
def add(a, b):
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2 |
return a + b
|
3 |
|
4 |
def multiply(a, b):
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
5 |
return a * b
|
6 |
|
7 |
def subtract(a, b):
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
8 |
return a - b
|
9 |
|
10 |
def divide(a, b):
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
11 |
if b == 0:
|
12 |
raise ValueError('Cannot divide by zero')
|
13 |
return a / b
|
14 |
|
15 |
def func(*args, **kwargs):
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
16 |
def wrapper(*args, **kwargs):
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
17 |
return func(*args, **kwargs)
|
18 |
return wrapper
|