Spaces:
Runtime error
Runtime error
File size: 2,598 Bytes
db88ae6 63de821 db88ae6 63de821 db88ae6 63de821 db88ae6 63de821 db88ae6 63de821 db88ae6 63de821 db88ae6 63de821 db88ae6 63de821 db88ae6 63de821 db88ae6 |
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 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 |
def add(a, b):
"""
Adds two numbers together.
:param a: The first number to add. Must be a numeric type.
:type a: int or float
:param b: The second number to add. Must be a numeric type.
:type b: int or float
:returns: The sum of the two numbers.
:rtype: int or float
:raises TypeError: If the input parameters are not numeric types.
:raises ValueError: If the input parameters are not numbers.
"""
return a + b
def multiply(a, b):
"""
Description:
This function multiplies two numbers.
Arguments:
a: First number to be multiplied. It should be an integer or a float.
b: Second number to be multiplied. It should be an integer or a float.
Returns:
The product of the two numbers. It will be an integer or a float depending on the input.
Raises:
None.
"""
return a * b
def subtract(a, b):
"""
Description:
This function performs subtraction of two numbers.
Arguments:
a (int): The first number to be subtracted.
b (int): The second number to be subtracted from the first number.
Returns:
int: Returns the difference of the two numbers.
Raises:
None
"""
return a - b
def divide(a, b):
"""
Description:
This function divides two numbers.
Arguments:
a (float): The first number to be divided.
b (float): The second number to be divided.
Returns:
float: Returns the result of a divided by b.
Raises:
ValueError: If b is equal to zero, it raises a ValueError with the message "Cannot divide by zero".
"""
if b == 0:
raise ValueError('Cannot divide by zero')
return a / b
def func(*args, **kwargs):
"""
This function is a decorator that wraps another function and returns a wrapper function.
Arguments:
* args: A variable-length argument list (optional).
* kwargs: A dictionary of keyword arguments (optional).
Returns:
A wrapper function that calls the original function with the same arguments.
Raises:
None
"""
def wrapper(*args, **kwargs):
"""
This function acts as a wrapper function that calls another function.
Arguments:
* args: Positional arguments to be passed to the wrapped function.
(type: tuple)
* kwargs: Keyword arguments to be passed to the wrapped function.
(type: dict)
Returns:
The result of calling the wrapped function with the provided arguments.
(type: any)
Raises:
Any exceptions raised by the wrapped function will be propagated.
(type: any)
"""
return func(*args, **kwargs)
return wrapper |