码迷,mamicode.com
首页 > 编程语言 > 详细

Python_猜大小

时间:2016-12-28 19:51:12      阅读:286      评论:0      收藏:0      [点我收藏+]

标签:role   int   art   port   ice   random   range   else   import   

 1 # 需要在python3上执行
 2 import random
 3 def game ():
 4     point1 = random.randrange(1,7)
 5     point2 = random.randrange(1,7)
 6     point3 = random.randrange(1,7)
 7     print("<<<<<<<GAME START>>>>>>>")
 8     result = point3 + point2 + point1
 9     Big = range(11,19)
10     Small = range(3,11)
11     cai = input("Big or Small: ")
12     print(<<<<<<ROLE THE DICE!>>>>>>)
13     i = 1
14     if cai == Big:
15         if result in Big:
16             print("点数是"+ str([point3, point2, point1]),"You Win!")
17         else:
18             print("点数是"+ str([point3, point2, point1]),"You Lose!")
19     elif cai == Small:
20         if result in Small:
21             print("点数是"+ str([point3, point2, point1]),"You Win")
22         else:
23             print("点数是"+ str([point3, point2, point1]),"You Lose!")
24     else:
25         print("仅允许输入 “Big” 或 “Small”")
26         game()
27     while i>0:
28         game()
29 game()

 

Python_猜大小

标签:role   int   art   port   ice   random   range   else   import   

原文地址:http://www.cnblogs.com/xuelei-0728/p/6230157.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!