mirror of
https://github.com/hastagAB/Awesome-Python-Scripts.git
synced 2024-11-23 20:11:07 +00:00
Added Algebra Solver
This commit is contained in:
parent
f2a4a5be6b
commit
f33440837b
16
Algebra-Solver/Algebra-Solver.py
Normal file
16
Algebra-Solver/Algebra-Solver.py
Normal file
|
@ -0,0 +1,16 @@
|
||||||
|
#!/usr/bin/python3
|
||||||
|
|
||||||
|
from sympy import *
|
||||||
|
import sys
|
||||||
|
|
||||||
|
def solver(x):
|
||||||
|
sympy_eq = sympify("Eq(" + x.replace("=", ",") + ")")
|
||||||
|
result = solve(sympy_eq)
|
||||||
|
return result[0]
|
||||||
|
|
||||||
|
def main(x):
|
||||||
|
X = solver(x)
|
||||||
|
print("X = " + str(X))
|
||||||
|
|
||||||
|
if __name__ == "__main__":
|
||||||
|
main(sys.argv[1])
|
16
Algebra-Solver/README.MD
Normal file
16
Algebra-Solver/README.MD
Normal file
|
@ -0,0 +1,16 @@
|
||||||
|
# Python Algebra Solver
|
||||||
|
This python script will demonstrate how to solve a very simple algebra using sympy module
|
||||||
|
|
||||||
|
## Requirement
|
||||||
|
|
||||||
|
Python 3.xx or Python 2.xx
|
||||||
|
Sympy
|
||||||
|
```bash
|
||||||
|
pip install sympy
|
||||||
|
```
|
||||||
|
|
||||||
|
#Usage
|
||||||
|
Call python following with the simple algebra problem
|
||||||
|
```bash
|
||||||
|
$ python Solver.py "5 = X - 2"
|
||||||
|
```
|
Loading…
Reference in New Issue
Block a user