Answers for "solve a second degree equation in python"

0

solve a second degree equation in python

import math
print ("The second degree equation comes in the form")
print("ax²+bx+c")
a =int (input("Enter a: "))
b =int (input("Enter b: "))
c =int (input("Enter c: "))

d = (b**2)-(4*a*c) 

if d < 0:
    print ("This equation has no real solution")
elif d == 0:
    x = (-b+math.sqrt(d))/2*a
    print ("This equation has one solutions: ", x)
else:
    x1 = (-b+math.sqrt(d))/2*a
    x2 = (-b-math.sqrt(d))/2*a
    print ("This equation has two solutions: ", x1, " and", x2)
Posted by: Guest on June-19-2021

Code answers related to "solve a second degree equation in python"

Python Answers by Framework

Browse Popular Code Answers by Language