Python Forum
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
equation
#6
(Nov-07-2019, 09:25 AM)MathisDELAGE Wrote: I'd like to fix an equation with this program is what it would be possible to please

Hi!

I don't see the equation(s) you want to fix.

I would approach the issue in a different way, for instance:
import math

aValue = float(input("Please, for the equation type:\nax\u00b2 + bx + c = 0\nenter the value of coefficient 'a':\n"))
bValue = float(input("Please, for the equation type:\nax\u00b2 + bx + c = 0\nenter the value of coefficient 'b':\n"))
cValue = float(input("Please, for the equation type:\nax\u00b2 + bx + c = 0\nenter the value of coefficient 'c':\n"))
d = (bValue**2) - (4*aValue*cValue)
sol1 = (-bValue-math.sqrt(d))/(2*aValue)
sol2 = (-bValue+math.sqrt(d))/(2*aValue)
print(f'The solutions are x1 = {sol1} and x2 = {sol2}.')
and for the sample equation 'x² - x - 2 = 0', it would produce the following output:
Output:
Please, for the equation type: ax² + bx + c = 0 enter the value of coefficient 'a': 1 Please, for the equation type: ax² + bx + c = 0 enter the value of coefficient 'b': -1 Please, for the equation type: ax² + bx + c = 0 enter the value of coefficient 'c': -2 The solutions are x1 = -1.0 and x2 = 2.0. >>>
All the best,
newbieAuggie2019

"That's been one of my mantras - focus and simplicity. Simple can be harder than complex: You have to work hard to get your thinking clean to make it simple. But it's worth it in the end because once you get there, you can move mountains."
Steve Jobs
Reply


Messages In This Thread
equation - by MathisDELAGE - Nov-07-2019, 09:25 AM
RE: equation - by ThomasL - Nov-07-2019, 01:04 PM
RE: equation - by perfringo - Nov-07-2019, 01:04 PM
RE: equation - by jefsummers - Nov-07-2019, 02:43 PM
RE: equation - by ThomasL - Nov-07-2019, 04:29 PM
RE: equation - by newbieAuggie2019 - Nov-07-2019, 04:50 PM

Forum Jump:

User Panel Messages

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