Discuss / Python / 交作业

交作业

Topic source
在此插入代码

def quadratic(a,b,c): deta=bb-4ac if deta<0: return 'there is not any key' elif deta==0: return 'there is only one key,'+(-b)/(2a) else: return 'there are two different key,',(-b+math.sqrt(deta))/(2a),'and',(-b-math.sqrt(deta))/(2a)

测试用例及结果

在此插入代码

print(quadratic(2, 3, 1)) ('there are two different key,', -0.5, 'and', -1.0)

在此插入代码

print(quadratic(1, 3, -4)) # => (1.0, -4.0) there are two different key, 1.0 and -4.0


  • 1

Reply