Discuss / Python / 我的方法可以解一元的,也可以解二元的嘿嘿

我的方法可以解一元的,也可以解二元的嘿嘿

Topic source

亭风_

#1 Created at ... [Delete] [Delete and Lock User]

import math def quadratic(a,b,c): for i in (a,b,c): if not isinstance(i,(int,float)): raise TypeError('您输入的数据类型不对') if a==0: if abs(b)>0: x=-c/b return x else: return '您输入的一元一次方程无解' if (bb-4ac)>=0: x1=(-b+sqrt(bb-4ac))/(2a) x2=(-b-sqrt(bb-4ac))/(2*a) return x1,x2 else: return '您输入的二元一次方程无解'

亭风_

#2 Created at ... [Delete] [Delete and Lock User]

老铁们,有需要交流的加我微信htf308429,经济学硕士在读

亭风_

#3 Created at ... [Delete] [Delete and Lock User]

当然,最后可以把(bb-4a*c)>0和<0分开讨论


  • 1

Reply