You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
<spanstyle="font-size:0.5em;"> * this may or may not be an exageration </span>
11
+
12
+
Simple parser for math expressions in strings.
11
13
12
14
## Examples
13
15
14
16
It can do simple equations
15
17
```py
16
18
>>>from math_parser import resolve_expr
17
-
>>>print(resolve_expr("2^2"))
19
+
>>> resolve_expr("2^2")# simple calculations
18
20
4
19
-
```
20
-
21
-
Complicated-ish expressions (brackets, order of operations)
22
-
```py
23
-
>>>from math_parser import resolve_expr
24
-
>>>print(resolve_expr("3+(5/7*2-6)"))
21
+
>>> resolve_expr("3+(5/7*2-6)") # complicated-ish expressions (brackets & order of operations)
25
22
-1.5714285714285712
26
-
```
27
-
28
-
Variable support
29
-
```py
30
-
>>>from math_parser import resolve_expr
31
-
>>>print(resolve_expr("a*12", a=3))
23
+
>>> resolve_expr("a*12", a=3) # custom variable support
32
24
36
25
+
>>> resolve_expr("½ × ⅗") # auto-replaces supported symbols and spaces
26
+
0.3
27
+
>>> resolve_expr("1+2+3+4+5+6+7*7")
28
+
70
29
+
>>>
33
30
```
34
31
35
-
One day someone's going to tell me this is [extremely inefficient](https://github.com/QwireDev/MathParser/blob/master/math_parser.py) and they'll probably be right.
0 commit comments