Both the GUI and the CLI share the same core math module (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), so every arithmetic operator and scientific function works identically in both interfaces — the same inputs produce the same outputs regardless of how you launch the calculator. The only feature that differs between the two interfaces is parenthesized expression syntax, which is exclusive to the GUI.
Basic arithmetic
All five basic operations accept any two real numbers (float). Intermediate results keep Python’s native float precision.
| Operation | Syntax (CLI) | Example | Result |
|---|---|---|---|
| Addition | a + b | 2 + 3 | 5 |
| Subtraction | a - b | 10 - 4 | 6 |
| Multiplication | a * b | 5 * 6 | 30 |
| Division | a / b | 15 / 3 | 5.0 |
| Exponentiation | a ^ b | 2 ^ 4 | 16.0 |
=. In the CLI, type all three tokens separated by spaces (e.g. 5 * 6) and press Enter.
Scientific functions
The three scientific functions are implemented as pure functions incalculator.py. abs_value is a unary operation (one argument); valor_maximo and valor_minimo are binary operations (two arguments).
| Function | Signature | Description | Example | Result |
|---|---|---|---|---|
abs(x) | abs_value(a: float) -> float | Returns the absolute value of a — converts any negative number to its positive equivalent | -5 abs | 5 |
max(a, b) | valor_maximo(a: float, b: float) -> float | Returns the larger of the two numbers; returns either value if they are equal | 10 max 20 | 20 |
min(a, b) | valor_minimo(a: float, b: float) -> float | Returns the smaller of the two numbers; returns either value if they are equal | 10 min 5 | 5 |
abs in the GUI: enter a number (e.g. -5), then click abs. The result replaces the current display value immediately — no = press needed.
Using max / min in the GUI: click max or min after entering the first number (just like pressing + or -), then enter the second number and press =.
Using abs in the CLI: type the number followed by abs, e.g. -7 abs. max and min use the standard binary format: 10 max 20.
Parenthesized expressions
The GUI supports full expression mode when( is entered. In this mode the entire expression string — including nested parentheses — is built character by character in the display and evaluated atomically when = is pressed. Internally the calculator replaces ^ with Python’s ** before calling eval, and it validates that only digits, spaces, and the characters +-*/^(). are present (regex ^[\d\s\+\-\*\/\^\(\)\.]+$).
The following expressions are all valid in GUI expression mode:
| Expression | Result |
|---|---|
(2+3)*4 | 20 |
2*(3+4) | 14 |
(5-2)*(6+4) | 30 |
((2+3)*4)/5 | 4.0 |
(2+3)^2 | 25 |
Parenthesized expression syntax is GUI-only. The CLI parser expects exactly two or three space-separated tokens (
num1 operator num2 or num function) and does not evaluate multi-operator strings. To compute (2+3)*4, launch the GUI with python src/gui.py.Because the expression-mode regex only allows digits and
+-*/^()., the words abs, max, and min are not usable inside a parenthesized expression in the GUI. Use those buttons in normal (non-parenthesis) mode.Error conditions
The table below lists every condition that causes the calculator to raise an error, the underlying Python exception or validation check that triggers it, and where the error surfaces.| Condition | Underlying cause | Error message | Interface |
|---|---|---|---|
| Division by zero | ZeroDivisionError raised by divide() | No se puede dividir por 0 (GUI) · No se puede dividir por cero (CLI, from exception message) | Both |
Negative base with even-root exponent (e.g. (-8)^0.5) | ValueError("Raíz negativa") raised by power() | Raíz negativa | Both |
Unbalanced parentheses (e.g. (2+3*4) | expression.count('(') != expression.count(')') check in equals_click | Paréntesis desbalanceados | GUI only |
| Invalid expression characters (e.g. letters inside expression mode) | Regex ^[\d\s\+\-\*\/\^\(\)\.]+$ does not match | Expresión inválida | GUI only |
Expression evaluation SyntaxError | Malformed expression string passed to eval | Sintaxis incorrecta | GUI only |
= pressed before the second number is entered | first_number set, operator set, current_value empty | Ingresa el segundo número | GUI only |
abs clicked with only - in the display | current_value == "-" check in unary_operation | Número incompleto | GUI only |
| Non-numeric token in normal mode | ValueError from float(current_value) (not Raíz negativa) | Entrada inválida | GUI only |
| Non-numeric token in CLI input | ValueError from float() conversion | Error: Ingresa números válidos | CLI only |
| Unknown operator in CLI (3-token input) | Operator not in the recognised set | Operador '…' no válido | CLI only |
| Unknown function in CLI (2-token input) | Function is not abs | Función '…' no válida | CLI only |
| Wrong number of tokens in CLI | len(parts) is not 2 or 3 | Formato inválido | CLI only |
