【发布时间】:2018-06-20 09:12:17
【问题描述】:
我为uri在线法官编写了这段代码(问题号1036)......这是一个Bhaskara公式......
import cmath
A,B,C=input().split()
A = float(A)
B = float(B)
C = float(C)
D = (B*B)-(4*A*C)
if((D== -D)|(A==0)):
print("Impossivel calcular")
else:
T = cmath.sqrt(D)
x1 = (-B+T)/(2*A)
x2 = (-B-T)/(2*A)
print("R1 = %.5f" %x1)
print("R2 = %.5f" %x2)
但是当我提交这个程序时...发生了运行时错误...
Traceback (most recent call last): File "Main.py", line 14, in
print("R1 = %.5f" %x1)
TypeError: can't convert complex to float
Command exited with non-zero status (1)
请帮我解决这个问题。
【问题讨论】:
标签: python-3.x