# -*- coding: utf-8 -*-import mathdef quadratic(a, b, c): x1=0 x2=0 if not isinstance(a,(int,float)) or not isinstance(a,(int,float)) or not isinstance(a,(int,float)): raise TypeError('bad operand type') if a == 0: print('分母a不能为0!') elif ((b*b-4*a*c)<0): print('负数无法开平方!') 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,x2d = quadratic('0',3,1)if d==None: print('此方程误解!')else: print(d)
Sign in to make a reply
落落96897