Skip to main content

Documentation Index

Fetch the complete documentation index at: https://mintlify.com/Seaus-tech/Calculator-App/llms.txt

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

Calculator App supports all fundamental arithmetic operations directly from the terminal prompt. Expressions are evaluated using Python’s eval with a restricted namespace, so operator precedence follows standard Python rules — parentheses first, then exponentiation, then multiplication and division, then addition and subtraction.

Supported Operators

OperatorSymbol(s)ExampleResult
Addition+2+35
Subtraction-10-46
Multiplication*3*412
Division/15/35
Exponentiation^ or **2^3 or 2**38

Exponentiation: ^ and **

Both caret (^) and double-asterisk (**) are accepted as exponentiation operators. Before evaluation, evaluator.py uses a regex substitution to convert any ^ into ** so Python’s eval can process it:
expr = re.sub(r'(\d+(?:\.\d+)?|\w+)\^(\d+(?:\.\d+)?|\w+)', r'\1**\2', expr)
This means 2^3 and 2**3 produce identical results.
> 2^3
= 8
> 2**3
= 8
> 9**2
= 81

Operator Precedence

Calculator App uses standard Python operator precedence. No configuration is needed — expressions are evaluated exactly as a Python interpreter would evaluate them.
  1. Parentheses(2+3)*420
  2. Exponentiation2**3+19
  3. Multiplication / Division3*4+214
  4. Addition / Subtraction10-4+28
> (2+3)*4
= 20
> 2**3+1
= 9
> 3*4+2
= 14

Integer vs Float Results

The type of result returned depends on the operands and the operation:
  • Integer result — when both operands are integers and the operation produces a whole number (e.g., 2+35, 3*412).
  • Float result — when division is involved or the result is non-integer (e.g., 15/35.0 in Python 3, 7/23.5).
> 2+3
= 5
> 10-4
= 6
> 3*4
= 12
> 15/3
= 5.0
> 7/2
= 3.5

Error Handling

Division by Zero

Returns Invalid - Division by zero when a denominator evaluates to 0.

Syntax Error

Returns Invalid - Syntax error for malformed expressions like 2++3.
> 5/0
= Invalid - Division by zero
> 2++3
= Invalid - Syntax error

Build docs developers (and LLMs) love