Skip to content

Instantly share code, notes, and snippets.

@jabbalaci
Created December 21, 2022 12:54
Show Gist options
  • Save jabbalaci/51ec3b89d00f156ce659b6bcf582cb11 to your computer and use it in GitHub Desktop.
Save jabbalaci/51ec3b89d00f156ce659b6bcf582cb11 to your computer and use it in GitHub Desktop.
Solving an equation with Sympy
#!/usr/bin/env python3
import sympy
from sympy.parsing.sympy_parser import parse_expr
def main():
text = "(4 + (2 * (x - 3))) / 4 = 150"
equation = "(4 + (2 * (x - 3))) / 4 - 150"
p = parse_expr(equation)
print(p)
x = sympy.Symbol("x")
result = sympy.solve(p, x)[0]
print("---")
print(result)
##############################################################################
if __name__ == "__main__":
main()
@jabbalaci
Copy link
Author

This gist belongs to the video https://www.youtube.com/watch?v=uYDEbo4BeMc

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment