##### Solve simple equation in Python
 Solve simple equation in Python kmll Unladen Swallow Posts: 3 Threads: 2 Joined: Nov 2020 Reputation: Nov-01-2020, 03:32 PM Hi, I am fairly new to working with mathematics in Python and I am wondering how I can use Python so solve an eqations like this: 0.4x - 0.38 = 0.58 Thanks Reply deanhystad So-and-so of the Yard Posts: 2,690 Threads: 12 Joined: Feb 2020 Reputation: Nov-01-2020, 03:43 PM For solving symbolic math equations take a look at SymPy Reply jefsummers Da Bishop Posts: 1,157 Threads: 1 Joined: May 2019 Reputation: Nov-01-2020, 03:57 PM Or use basic algebra to solve for x then print the result 0.4x - 0.38 = 0.58 0.4x = 0.58 + 0.38 = 0.96 x = 0.96/0.4 `print(0.96/0.4)```Output:2.4`` Reply kmll Unladen Swallow Posts: 3 Threads: 2 Joined: Nov 2020 Reputation: Nov-01-2020, 04:11 PM (Nov-01-2020, 03:43 PM)deanhystad Wrote: For solving symbolic math equations take a look at SymPy Thanks for the advise. But I did and I did not quite understand how I can use if for an equation similar to the one I listed above so I was hoping for a concrete solution/example. Reply deanhystad So-and-so of the Yard Posts: 2,690 Threads: 12 Joined: Feb 2020 Reputation: Nov-01-2020, 04:34 PM I have never used SymPy myself, but from this tutorial I think it looks fairly straight forward: https://pythonforundergradengineers.com/...tions.html My first shot would be: ```from sympy import symbols, Eq, solve x = symbols('x') eq = Eq('0.4x - 0.38 - 0.58') solution = solve((eq), (x))```There may be a way to solve an equation without first putting it in the form equation = 0. I don't know. kmll likes this post Reply

 Possibly Related Threads… Thread Author Replies Views Last Post how to solve complex equations in python HoangF 3 268 Dec-26-2021, 07:04 PM Last Post: HoangF NotImplementedError: pseudo-class is not implemented - how to Update Python to solve apollo 1 1,171 May-16-2021, 08:03 AM Last Post: buran Python gives " -0.0 " as solution for an equation akar 2 813 Aug-27-2020, 12:15 PM Last Post: akar Asking for help in solving a single variable nonlinear equation using Python ! NDP 0 1,186 Feb-15-2019, 12:03 PM Last Post: NDP How do I code this equation in python (factor ceiling(2^127-1)) Pleiades 5 2,544 Apr-23-2018, 03:01 AM Last Post: Skaperen

Forum Jump:

### User Panel Messages

##### Announcements
Announcement #1 8/1/2020
Announcement #2 8/2/2020
Announcement #3 8/6/2020