Skip to content

szmania/Expression_Solver

Repository files navigation

Expression Solver

Description

This applicaiton takes an expression as a string and solves it.

It is capable of handling parenthesis, exponentiation, multiplicaiton, division, addition and subtraction. The program also recognizes when a number outside of the parenthesis is touching the parenthesis, noting that this indicates multiplicaiton. All results return in whole numbers, rounded.

Usage

Operators

Parenthesis "(" and ")".

Exponentiation "^". ie: 2^2 is 2 to the power of 2.

Multiplication "*".

Division "/".

Addition "+".

Subtraction "-".

Arguments

-e, --expr <expression>

Expression as string. ie: (4+1)(5^2)/2

--logFile <logging file>

(Optional) File to output log to. ie: "log.log". Default is "expressionSolver.log".

--logLevel <loglevel>

(Optional) Logging level. ie: "WARN", "INFO", "DEBUG"

Examples

input 1:

python expressionSolver.py --expr "(1 * 4) + (5 * 2)" --logFile log.log --logLevel WARN

output 1:

(1 * 4) + (5 * 2) = 14

input 2:

python expressionSolver.py --expr "4^3(9 / 1)"

output 2:

4^3(9 / 1) = 576

About

Solves string expressions. ie: (1 - 2) + 3 - (5 / 7)

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages