一个小小的一元二次方程,不该的呀
import math
def equation(a,b,c):
if not isinstance(a+b+c,(int,float)):
raise TypeError(‘bad operand type’)
elif b**2-4ac<0:
raise TypeError(‘no real solver’)
else:
x1=(-b+math.sqrt(b2-4ac))/2a
x2=(-b-math.sqrt(b2-4ac))/2a
return x1,x2
print(‘equation(2,3,1)=’,equation(2,3,1))
Learn and Record2
最新推荐文章于 2024-09-12 20:06:16 发布