Discuss / Python / 作业,请指正

作业,请指正

Topic source

天朝子民

#1 Created at ... [Delete] [Delete and Lock User]
    if not isinstance(a,(int,float)) and instance(b,(int,float)) and (c,(int,float)):
        raise TypeError('bad operand type')
    else:
        m=b*b-4*a*c
        if m<0:
            return '无解'
        else:
            return (-b+math.sqrt(m))/(2*a),(-b-math.sqrt(m))/(2*a)

火野剑去

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

def quadratic(a, b, c): if a == 0: return if bb - 4ac > 0: return (-b+math.sqrt(bb -4ac))/(1.02a), (- b-math.sqrt(bb - 4ac))/(1.02a) elif bb -4ac == 0: return -1(b/1.02a), -1(b/1.02a) else: return

print(quadratic(2, 3, 1))

print(quadratic(1, 3, -4))

大家有没有建QQ群?要没有的话,我这里建了一个廖老师的python自学群,廖雪峰Python自学群 426323764 大家加入一块学习吧!


  • 1

Reply