import math
def delta(a,b,c):
    return (b**2 - 4*a*c)

print ("soluzione di equazione di secondo grado")
ok=False
while ok == False:
    a=float(input("\ninserire a"))
    if a != 0:
        ok=True


b=float(input("\ninserire b "))
c=float(input("\ninserire c "))
d=delta (a,b,c)
if d > 0:
    x1 = (-b+math.sqrt(d))/(2*a)
    x2 = (-b-math.sqrt(d))/(2*a)
    print("\nx1=",x1, "- x2=", x2)

else:
    if d<0:
        print ("\nnon ci sono soluzioni reali")
    else:
        x1=-b/(2*a)

Embed on website

To embed this project on your website, copy the following code and paste it into your website's HTML: