Discuss / Python / 作业

作业

Topic source

蓬易Lava

#1 Created at ... [Delete] [Delete and Lock User]
if not isinstance(a,(int,float)) and isinstance(a,(int,float)) and isinstance(a,(int,float)) :
    raise TypeErroor('bad operand type')
if b*b-4*a*c<0:
    return none
else:
    x1=(-b+math.sqrt(b*b-4*a*c))/(2*a)
    x2=(-b-math.sqrt(b*b-4*a*c))/(2*a)
    return x1,x2

虫虫Aaron

#2 Created at ... [Delete] [Delete and Lock User]
  if not isinstance(a, (int, float)) or not isinstance(b, (int, float)) or not isinstance(c, (int, float)):
        raise TypeError('bad operand type')
  if b*b-4*a*c<0:
        return
  else:
        x1 = (-b + math.sqrt(b**2 - 4*a*c))/ (2*a)
        x2 = (-b - math.sqrt(b**2 - 4*a*c))/ (2*a)
        return x1,x2

  • 1

Reply