Discuss / Python / daka

landingguymmm

#1 Created at ... [Delete] [Delete and Lock User]

     delta = b*b-4*a*c

     if not isinstance(a,(int, float)) and not isinstance(b,(int, float)) and not isinstance(c,(int, float)):

        raise TypeError('bad operand type')

     else:

         if delta < 0:

             print('无解')        

         else:

             x = (-b + math.sqrt(b**2 - 4*a*c))/(2*a)

             y = (-b - math.sqrt(b**2 - 4*a*c))/(2*a)

     return x, y

if not isinstance(a,(int, float)) and not isinstance(b,(int, float)) and not isinstance(c,(int, float)): 这行判断错了,要用or


  • 1

Reply