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:
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
Prints a demo of all supported operations, then enters an interactive read-evaluate-print loop (REPL). On each iteration it:
- Calls
input() to read a line from the user.
- Strips leading/trailing whitespace and splits on spaces.
- Dispatches to the appropriate function in
calculator.py based on the parsed tokens.
- Prints the result prefixed with
"Resultado: ".
- Repeats until the user types
quit or a KeyboardInterrupt is received.
The most common input style. Provide two numbers separated by an operator keyword or symbol.
| Operator | Operation | Example input | Result |
|---|
+ | Addition | 5 + 3 | 8 |
- | Subtraction | 10 - 4 | 6 |
* | Multiplication | 6 * 7 | 42 |
/ | Division | 15 / 4 | 3.75 |
^ | Exponentiation | 2 ^ 8 | 256 |
max | Maximum value | 10 max 3 | 10 |
min | Minimum value | 10 min 3 | 3 |
# 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
For operations that require only a single number, place the number first and the function keyword second.
| Function | Operation | Example input | Result |
|---|
abs | Absolute value | -7 abs | 7 |
# 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
| Condition | Printed message |
|---|
| Non-numeric token where a number is expected | Error: 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 input | Operador '<op>' no válido |
| Unknown function in two-token input | Función '<func>' no válida |
| Input cannot be parsed into 2 or 3 tokens | Formato 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!