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 accepts a rich variety of expression formats beyond simple arithmetic. From natural language phrases like 9 squared to algebraic equations like 2x+4=10, this page documents every form of input the REPL understands, with examples drawn directly from the source.

Arithmetic Operators

All standard arithmetic operators are supported. Expressions are evaluated using Python’s eval under a restricted safe dictionary, so standard operator precedence applies.
OperatorMeaningExampleResult
+Addition3+25
-Subtraction10-46
*Multiplication3*412
/Division15/35.0
**Exponentiation2**38
^Exponentiation (alias)2^38
The ^ operator is automatically rewritten to ** before evaluation. Both forms produce identical results.

Fractions

Calculator App parses fraction notation and converts it to Python’s fractions.Fraction type internally, giving exact rational arithmetic rather than floating-point approximations. Simple fractions use the standard a/b notation:
1/2 + 1/3
= 5/6
3/4 - 1/4
= 1/2
Mixed numbers are written with a space between the whole part and the fractional part:
2 1/2 + 1/4
= 2 3/4
1/2 * 2
= 1
When the result of a fraction calculation has a denominator of 1, Calculator App returns a plain integer. When it is improper (numerator greater than denominator), it is displayed as a mixed number.

Natural Language

Calculator App understands a set of English phrases and rewrites them into standard expressions before evaluation. The transformation is case-insensitive.
Natural language phraseRewrites toExample inputResult
{n} squared({n})**29 squared81
{n} cubed({n})**35 cubed125
sqrt of {n}sqrt({n})sqrt of 164.0
square root of {n}sqrt({n})square root of 255.0
sqrt {n}sqrt({n})sqrt 164.0
Natural language phrases only match literal numbers in the expression (e.g., 9 squared). To square a variable or sub-expression, use ** or ^ directly.

Variables

The evaluator maintains a variable store that is injected into every expression before evaluation. Variable values are substituted as raw string replacements, so a stored value of 5 turns every occurrence of the variable name into the literal string 5 before eval runs. Assigning a variable uses name=value syntax. Because any input containing both = and a letter is first routed to the equation solver (see Equations below), typing x=5 is handled as a one-variable equation and the solver returns the solution directly:
x=5
x = 5
Due to the order of routing checks in the REPL, inputs of the form name=value where the name contains a letter are always processed as equations, not stored as variables. The variable store can be populated programmatically but is not writable from the REPL prompt using letter-named variables.

Equations

When the input contains = and at least one letter on the left-hand side, Calculator App routes the input to its equation solver rather than the standard evaluator. Format: expression = value where the expression includes a single-letter variable.
2x+4=10
x = 3
6+x=7
x = 1
x^2-4=0
x = -2
Implicit multiplication — writing a digit immediately before a letter (e.g., 2x) is automatically expanded to 2*x by the solver before evaluation. You do not need to write the * explicitly in equation expressions.
The solver first attempts an algebraic approach when the left-hand side contains explicit multiplication (the * operator) but no exponentiation (**2), and falls back to a brute-force integer search over the range −100,000 to 100,000. The search returns the first integer solution found; if an equation has multiple solutions only one result is reported.
The solver finds only the first matching integer in the search range. For x^2-4=0 the brute-force scan encounters x = -2 before x = 2 and returns that single result.

Math Functions

The following functions and constants are available in any expression. They live in the evaluator’s safe dictionary and map directly to Python’s math module.
NameDescriptionExampleResult
sqrt(x)Square rootsqrt(25)5.0
sin(x)Sine (radians)sin(0)0.0
cos(x)Cosine (radians)cos(0)1.0
tan(x)Tangent (radians)tan(0)0.0
log(x)Natural logarithmlog(e)1.0
piπ constantpi3.14159…
eEuler’s numbere2.71828…
Functions can be composed with arithmetic operators:
sin(pi/2)
= 1.0
sqrt(9) + cos(0)
= 4.0

Special Commands

Two special keywords are handled by the REPL before any expression parsing occurs.

quit

Exits the Calculator App REPL immediately. No expression is evaluated.
> quit

meme

Toggles meme mode on or off. When meme mode is ON, certain iconic expressions return joke results instead of their real values (e.g., 9+10 returns 21).
> meme
Meme mode: ON 😂
Meme mode is off by default and toggles each time you type meme. Type it again to restore normal calculation behaviour.

Build docs developers (and LLMs) love