Calculator Module
src.core.calculator
The core calculator library with basic arithmetic operations.
add(a, b)
Return the sum of two numbers.
The add
function is a simple utility designed to perform the addition of
two floating-point numbers. It takes two arguments, a
and b
, both of
which are expected to be of type float
. The function returns their sum,
also as a float
.
PARAMETER | DESCRIPTION |
---|---|
a
|
The first number.
TYPE:
|
b
|
The second number.
TYPE:
|
RETURNS | DESCRIPTION |
---|---|
float
|
The sum of the two numbers. |
Examples:
Source code in src/core/calculator.py
subtract(a, b)
Return the difference of two numbers.
PARAMETER | DESCRIPTION |
---|---|
a
|
The first number.
TYPE:
|
b
|
The second number.
TYPE:
|
RETURNS | DESCRIPTION |
---|---|
float
|
The difference of the two numbers. |
Examples:
Source code in src/core/calculator.py
multiply(a, b)
Return the product of two numbers.
PARAMETER | DESCRIPTION |
---|---|
a
|
The first number.
TYPE:
|
b
|
The second number.
TYPE:
|
RETURNS | DESCRIPTION |
---|---|
float
|
The product of the two numbers. |
Examples:
Source code in src/core/calculator.py
divide(a, b)
Return the division of two numbers. Raise an error if dividing by zero.
PARAMETER | DESCRIPTION |
---|---|
a
|
The numerator.
TYPE:
|
b
|
The denominator.
TYPE:
|
RETURNS | DESCRIPTION |
---|---|
float
|
The result of the division. |
RAISES | DESCRIPTION |
---|---|
ValueError
|
If the denominator is zero. |
Examples: