Skip to content

A math expression parser in python

License

Notifications You must be signed in to change notification settings

Middledot/math_parser

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

21 Commits
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Math Parser

1 function

1 equation

23* memory leaks

1 result

* this may or may not be an exageration

Simple parser for math expressions in strings.

Examples

It can do simple equations

>>> from math_parser import resolve_expr
>>> resolve_expr("2^2")  # simple calculations
4
>>> resolve_expr("3+(5/7*2-6)")  # complicated-ish expressions (brackets & order of operations)
-1.5714285714285712
>>> resolve_expr("a*12", a=3)  # custom variable support
36
>>> resolve_expr("½ × ⅗")  # auto-replaces supported symbols and spaces
0.3
>>> resolve_expr("1+2+3+4+5+6+7*7") 
70
>>>

Source?