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/cli.py provides an interactive command-line calculator. The main() function starts a loop that reads arithmetic expressions entered by the user, evaluates them using src/calculator.py, and prints the result. The loop continues until the user types quit or interrupts the process with Ctrl+C.

Entry point

Run the interactive calculator directly from the project root:
python src/cli.py
On startup the program prints a welcome banner and usage hint before prompting for input:
=== Team Practice - Calculadora Demo ===
Este es un ejemplo de cómo usar el módulo calculator.

Ejemplos de operaciones:
2 + 3 = 5
10 - 4 = 6
5 * 6 = 30
15 / 3 = 5.0
2 ^ 4 = 16
-7 abs = 7
Valor máximo entre 10 y 20 = 20
Valor mínimo entre 10 y 20 = 10

Ejemplo de manejo de errores:
Error: No se puede dividir por cero

=== Calculadora Interactiva ===
Operaciones disponibles: +, -, *, /, ^, max, min
Escribe 'quit' para salir

Ingresa una operación (ej: 5 + 3):

main() function

def main() -> None
Prints a demo of all supported operations, then enters an interactive read-evaluate-print loop (REPL). On each iteration it:
  1. Calls input() to read a line from the user.
  2. Strips leading/trailing whitespace and splits on spaces.
  3. Dispatches to the appropriate function in calculator.py based on the parsed tokens.
  4. Prints the result prefixed with "Resultado: ".
  5. Repeats until the user types quit or a KeyboardInterrupt is received.

Input format

Binary format — num1 operator num2

The most common input style. Provide two numbers separated by an operator keyword or symbol.
OperatorOperationExample inputResult
+Addition5 + 38
-Subtraction10 - 46
*Multiplication6 * 742
/Division15 / 43.75
^Exponentiation2 ^ 8256
maxMaximum value10 max 310
minMinimum value10 min 33
# Binary operation examples
"5 + 3"      # add(5.0, 3.0)       → 8.0
"15 / 4"     # divide(15.0, 4.0)   → 3.75
"2 ^ 8"      # power(2.0, 8.0)     → 256.0
"10 max 3"   # valor_maximo(10, 3) → 10
"10 min 3"   # valor_minimo(10, 3) → 3

Unary format — num function

For operations that require only a single number, place the number first and the function keyword second.
FunctionOperationExample inputResult
absAbsolute value-7 abs7
# Unary operation examples
"-7 abs"   # abs_value(-7.0) → 7.0
"3 abs"    # abs_value(3.0)  → 3.0
Float values are accepted for both operands. For example, 3.5 + 1.25 and 4.0 ^ 0.5 are both valid inputs.

Error handling

ConditionPrinted message
Non-numeric token where a number is expectedError: Ingresa números válidos
Division by zero (b == 0)Error: No se puede dividir por cero (the raw exception message from calculator.py)
Unknown operator in three-token inputOperador '<op>' no válido
Unknown function in two-token inputFunción '<func>' no válida
Input cannot be parsed into 2 or 3 tokensFormato inválido
KeyboardInterrupt (Ctrl+C)¡Hasta luego! (exits gracefully)
Any other unexpected exception is caught and displayed as Error inesperado: <message>. The loop then continues; no state is carried between iterations.

Example session

$ python src/cli.py

=== Team Practice - Calculadora Demo ===
Este es un ejemplo de cómo usar el módulo calculator.

Ejemplos de operaciones:
2 + 3 = 5
10 - 4 = 6
5 * 6 = 30
15 / 3 = 5.0
2 ^ 4 = 16
-7 abs = 7
Valor máximo entre 10 y 20 = 20
Valor mínimo entre 10 y 20 = 10

Ejemplo de manejo de errores:
Error: No se puede dividir por cero

=== Calculadora Interactiva ===
Operaciones disponibles: +, -, *, /, ^, max, min
Escribe 'quit' para salir

Ingresa una operación (ej: 5 + 3): 5 + 3
Resultado: 8.0

Ingresa una operación (ej: 5 + 3): 10 / 0
Error: No se puede dividir por cero

Ingresa una operación (ej: 5 + 3): 2 ^ 10
Resultado: 1024.0

Ingresa una operación (ej: 5 + 3): -7 abs
Resultado: 7.0

Ingresa una operación (ej: 5 + 3): 100 max 250
Resultado: 250

Ingresa una operación (ej: 5 + 3): hello + world
Error: Ingresa números válidos

Ingresa una operación (ej: 5 + 3): quit

¡Hasta luego!

Build docs developers (and LLMs) love