def quar(a,b,c):
if not isinstance(a,(int,float))|isinstance(b,(int,float))|isinstance(c,(int,float)):
raise TypeError('Wrong Type inputing!')
else:
from math import sqrt
tmp1=b**2-4*a*c
if tmp1>0:
return '%.04f'%float((-b+sqrt(tmp1))/(2*a)),'%.04f'%((-b-sqrt(tmp1))/(2*a))
elif tmp1==0:
return -b/(2*a)
else:
return 'No rational answer!'

聽
以上就是使用Python写一个求实数内二次方程解的函数 的详细内容,更多请关注php中文网其它相关文章!
python怎么学习?python怎么入门?python在哪学?python怎么学才快?不用担心,这里为大家提供了python速学教程(入门到精通),有需要的小伙伴保存下载就能学习啦!
Copyright 2014-2025 https://www.php.cn/ All Rights Reserved | php.cn | 湘ICP备2023035733号