遇到一个ELIF语法错误,我是python新手,不知道为什么会遇到这个错误
print("Résolution de l'équation du second degré : ax² + bx + c = 0")
chaineA= input("Coefficient de a ?: ")
a= float(chaineA)
chaineB= input("Coefficient de b ?: ")
b= float(chaineB)
chaineC= input("Coefficient de c ?: ")
c= float(chaineC)
delta=((b**2)-(4*a*b))
solut1= (-b + (delta**0.5)/(2*a))
solut2= (-b - (delta**0.5)/(2*a))
solut3= (-b/2*a)
if delta >= 0.0:
print("Deux solutions: ")
print("x1 =" , solut1)
print("x2 =" , solut2)
elif delta = 0.0:
print("Une solution")
print("x =" , solut3)
elif delta <= 0.0:
print("Pas de solution")
提前谢谢
您使用了单
=
而不是==
通过在elif中仅使用一个=,它认为您正在尝试将0.0分配给增量。应该是:
这将比较delta和0.0,如果它们相同,则在elif中运行代码
相关问题 更多 >
编程相关推荐