Discuss / Python / 20180819作业

20180819作业

Topic source

JoyElaine

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

import math

def quadratic(a,b,c): if not isinstance(a,(int,float)): raise TypeError('bad operand type') elif not isinstance(b,(int,float)): raise TypeError('bad operand type') elif not isinstance(c,(int,float)): raise TypeError('bad operand type') elif a==0: print('a!=0') else: s=math.sqrt(b*2-4ac) x1=(-b+s)/2a x2=(-b-s)/2*a return x1,x2 print('quadratic(2,3,1)=',quadratic(2,3,1)) print('quadratic(1,3,-4)',quadratic(1,3,-4))

JoyElaine

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

才发现直接贴在这里,会有缺失的


  • 1

Reply