Discuss / Python / day1

钱老板boss

#1 Created at ... [Delete] [Delete and Lock User]
if not (  isinstance(a,(int,float)) and isinstance(b,(int,float)) and isinstance(c,(int,float))   ):
    raise TypeError('bad operator')

delta = b*b-4*a*c
if delta < 0:
    print('方程无解!')
elif delta == 0:
    x = -b/(2*a)
    return x,x
else:
    x1 = (-b+math.sqrt(delta))/(2*a)
    x2 = (-b-math.sqrt(delta))/(2*a) 

return x1,x2

  • 1

Reply