-- coding:(uft-8) --
import math
def quadratic(a,b,c,):
if not isinstance (a,(int,float)) or not isinstance (b,(int,float)) or not isinstance (c,(int,float)): raise TypeError('bad operand type')
if a == 0:
if b == 0:
if c == 0:
print ('任意数都为解')
else:
print ('无解')
else:
return -c/b
else:
x1 = (-b + math.sqrt(bb-4ac))/(2a)
x2 = (-b - math.sqrt(bb-4ac))/(2a)
return x1,x2
死了也要DO
-- coding:(uft-8) -- import math def quadratic(a,b,c,): if not isinstance (a,(int,float)) or not isinstance (b,(int,float)) or not isinstance (c,(int,float)):
raise TypeError('bad operand type') if a == 0: if b == 0: if c == 0: print ('任意数都为解') else: print ('无解') else: return -c/b else: x1 = (-b + math.sqrt(bb-4ac))/(2a) x2 = (-b - math.sqrt(bb-4ac))/(2a) return x1,x2