Guest User

Untitled

a guest
May 24th, 2018
117
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.59 KB | None | 0 0
  1. def product(*plus):
  2. value=1
  3. for n in plus:
  4. value=value*n
  5. return value
  6. print('product(5) =', product(5))
  7. print('product(5, 6) =', product(5, 6))
  8. print('product(5, 6, 7) =', product(5, 6, 7))
  9. print('product(5, 6, 7, 9) =', product(5, 6, 7, 9))
  10. if product(5) != 5:
  11. print('测试失败!')
  12. elif product(5, 6) != 30:
  13. print('测试失败!')
  14. elif product(5, 6, 7) != 210:
  15. print('测试失败!')
  16. elif product(5, 6, 7, 9) != 1890:
  17. print('测试失败!')
  18. else:
  19. try:
  20. product()
  21. print('测试失败!')
  22. except TypeError:
  23. print('测试成功!')
Add Comment
Please, Sign In to add comment