Discuss / Python / 作业

作业

Topic source

微尘初心

#1 Created at ... [Delete] [Delete and Lock User]
def product(x=0, y=1, *args):    result = x * y    if args:        for number in args:            result = result * number    return resultif product(5) != 5:    print('测试失败1')if product(5, 6) != 30:    print('测试失败2')if product(5, 6, 7) != 210:    print('测试失败3')if product(5, 6, 7, 8) != 1680:    print('测试失败4')try:    product()    print('ok')except Exception as e:    with ('log.txt', 'w') as f:        f.write(e)

  • 1

Reply