我想知道为什么我的Python代码无法解决二次方程问题。我已经查看过它,没有发现任何错误。
print("This program will solve quadratic equations for you")
print("It uses the system 'ax**2 + bx + c'")
print("a, b and c are all numbers with or without decimal \
points")
print("Firstly, what is the value of a?")
a = float(input("\n\nType in the coefficient of x squared"))
b = float(input("\n\nNow for b. Type in the coefficient of x"))
c = float(input("\n\nGreat. now what is the c value? The number alone?"))
print("The first value for x is " ,(-b+(((b**2)-(4*a* c))* * 0.5)/(2*a)))
print("\n\nThe second value for x is " ,(-b-(((b * * 2)-(4*a*c))** 0.5)/(2*a)))
当a=1,b=-4和c=-3时,我期望得到-1和4,但实际得到的是5.5和0.5。
a=1 b=-3
和 c=-4 我期望得到的是-1和4,但实际上我得到的是5.5和0.5。 - Michael Dunwoody