if not isinstance(a+b+c,(int,float)): raise TypeError('bad operand type') s=b**2-4*a*c if s < 0: return '无实数根' else: x1 = (-b+math.sqrt(s))/(2*a) x2 = (-b-math.sqrt(s))/(2*a) return x1,x2
Sign in to make a reply
AlexMou54