-2
a = int(input("Please enter the value of a: "))
b = int(input("Please enter the value of b: "))
c = int(input("Please enter the value of c: "))
root_1 = (-b + ((b**2) - 4*a*c)**0.5)/2*a
root_2 = (-b - ((b**2) - 4*a*c)**0.5)/2*a
if root_1 < 0 or root_2 < 0:
root = "No real roots"
elif root_1 > 0 or root_2 > 0:
root = "Two real roots"
elif root_1 == 0 or root_2 == 0:
root = "One real root"
print("The values you entered have", root)
您好,我有复杂和int给我一个错误的问题。有针对这个的解决方法吗?提前致谢。类型复杂与int
你有什么问题?你在哪里使用'复杂'?什么是错误? – wallyk
TypeError:unorderable types:complex()
当我输入a = 2,b = 2和c = 2时,结果是一个复数,并给出了我粘贴在上述消息中的错误。 –