Discuss / Python / 函数练习

函数练习

Topic source

fridayily

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

def quadratic(a,b,c): if not isinstance(a,(int,float)): raise TypeError('bad oprand type') elif not isinstance(b,(int,float)): raise TypeError('bad oprand type') elif not isinstance(c,(int,float)):
raise TypeError('bad oprand type') import math d=bb-4ac if a==0: if b==0: raise TypeError('bad operand type') else: return -(c/b) elif(d<0): return TypeError('bad oprand type') elif(d==0): return -b/(2a) else: x1 = (-b+math.sqrt(d))/(2a) x2 = (-b-math.sqrt(d))/(2a) return x1,x2

fridayily

#2 Created at ... [Delete] [Delete and Lock User]
  • 乘号 怎么打印???

廖雪峰

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

用“插入代码”


  • 1

Reply