当前位置:   article > 正文

python编程 从入门到实践 第九章学习笔记 9-14习题答案_python9-14

python9-14
  1. from random import randint
  2. class Die():
  3. def __init__(self,sides = 6):
  4. self.sides = sides
  5. def roll_die(self):
  6. x = randint(1,self.sides)
  7. print(x)
  8. zhishaizi_1 = Die(6)
  9. for side in range(6):
  10. zhishaizi_1.roll_die()
  11. print("\n")
  12. zhishaizi_2 = Die(10)
  13. for side in range(10):
  14. zhishaizi_2.roll_die()
  15. print("\n")
  16. zhishaizi_3 = Die(20)
  17. for side in range(20):
  18. zhishaizi_3.roll_die()

声明:本文内容由网友自发贡献,不代表【wpsshop博客】立场,版权归原作者所有,本站不承担相应法律责任。如您发现有侵权的内容,请联系我们。转载请注明出处:https://www.wpsshop.cn/w/喵喵爱编程/article/detail/992931
推荐阅读
相关标签
  

闽ICP备14008679号