Source code for math_operations
"""
This module contains basic mathematical operations.
"""
[docs]
def add(a, b):
"""
Adds two numbers.
Parameters:
a (int, float): The first number.
b (int, float): The second number.
Returns:
int, float: The sum of the two numbers.
"""
return a + b
[docs]
def subtract(a, b):
"""
Subtracts the second number from the first.
Parameters:
a (int, float): The first number.
b (int, float): The second number.
Returns:
int, float: The difference between the two numbers.
"""
return a - b
[docs]
def multiply(a, b):
"""
Multiplies two numbers.
Parameters:
a (int, float): The first number.
b (int, float): The second number.
Returns:
int, float: The product of the two numbers.
"""
return a * b
[docs]
def divide(a, b):
"""
Divides the first number by the second.
Parameters:
a (int, float): The numerator.
b (int, float): The denominator.
Returns:
float: The quotient of the division.
Raises:
ValueError: If the denominator is zero.
"""
if b == 0:
raise ValueError("The denominator cannot be zero.")
return a / b