Skip to main content

Documentation Index

Fetch the complete documentation index at: https://mintlify.com/WorkTeam01/team-practice/llms.txt

Use this file to discover all available pages before exploring further.

src/calculator.py is the pure-math core of the calculator. All functions are stateless, accept float arguments, and return float. Both the GUI and CLI import from this module, making it the single source of truth for every arithmetic operation the application supports.

Importing the module

from src.calculator import add, subtract, multiply, divide, power, valor_maximo, valor_minimo, abs_value

add(a, b)

Sums two numbers and returns the result.
a
float
required
First operand.
b
float
required
Second operand.
Returns: float — the sum of a and b.
add(2, 3)    # → 5
add(-1, 1)   # → 0
add(1.5, 2.5) # → 4.0

subtract(a, b)

Subtracts the subtrahend from the minuend and returns the difference.
a
float
required
Minuend (the number being subtracted from).
b
float
required
Subtrahend (the number to subtract).
Returns: float — the difference a − b.
subtract(5, 3)   # → 2
subtract(0, 5)   # → -5
subtract(10, 10) # → 0

multiply(a, b)

Multiplies two numbers and returns the product.
a
float
required
First factor.
b
float
required
Second factor.
Returns: float — the product of a and b.
multiply(4, 3)    # → 12
multiply(-2, 5)   # → -10
multiply(0.5, 8)  # → 4.0

divide(a, b)

Divides the dividend by the divisor and returns the quotient.
a
float
required
Dividend.
b
float
required
Divisor. Must not be 0.
Returns: float — the quotient a / b.
Raises ZeroDivisionError("No se puede dividir por cero") if b equals 0.
divide(10, 2)  # → 5.0
divide(7, 2)   # → 3.5
divide(0, 5)   # → 0.0

try:
    divide(10, 0)
except ZeroDivisionError as e:
    print(e)   # No se puede dividir por cero

power(base, exponent)

Raises a base number to the given exponent.
base
float
required
The base number.
exponent
float
required
The exponent. Fractional exponents (e.g. 0.5) compute roots.
Returns: float — the result of base ** exponent.
Raises ValueError("Raíz negativa") when base is negative and the exponent implies an even root (e.g. power(-4, 0.5)), since that would produce a complex number.
power(2, 3)     # → 8
power(5, 0)     # → 1
power(4, 0.5)   # → 2.0

try:
    power(-4, 0.5)
except ValueError as e:
    print(e)    # Raíz negativa

valor_maximo(a, b)

Returns the larger of two values.
a
float
required
First number.
b
float
required
Second number.
Returns: floata if a > b, otherwise b. When both values are equal, returns b.
valor_maximo(10, 5)   # → 10
valor_maximo(-2, 3)   # → 3
valor_maximo(4, 4)    # → 4

valor_minimo(a, b)

Returns the smaller of two values.
a
float
required
First number.
b
float
required
Second number.
Returns: floata if a < b, otherwise b. When both values are equal, returns b.
valor_minimo(10, 5)   # → 5
valor_minimo(-2, 3)   # → -2
valor_minimo(4, 4)    # → 4

abs_value(a)

Returns the absolute (non-negative) value of a number.
a
float
required
The number whose absolute value is requested.
Returns: float — the absolute value of a. Negative numbers become positive; positive numbers are returned unchanged.
abs_value(-5)   # → 5
abs_value(3)    # → 3
abs_value(0)    # → 0

All eight functions are pure — they have no side effects, modify no global state, and do not perform I/O. They are safe to import and call directly in any context, including tests, scripts, or other modules.

Build docs developers (and LLMs) love