日韩性视频-久久久蜜桃-www中文字幕-在线中文字幕av-亚洲欧美一区二区三区四区-撸久久-香蕉视频一区-久久无码精品丰满人妻-国产高潮av-激情福利社-日韩av网址大全-国产精品久久999-日本五十路在线-性欧美在线-久久99精品波多结衣一区-男女午夜免费视频-黑人极品ⅴideos精品欧美棵-人人妻人人澡人人爽精品欧美一区-日韩一区在线看-欧美a级在线免费观看

歡迎訪問 生活随笔!

生活随笔

當(dāng)前位置: 首頁(yè) > 编程资源 > 综合教程 >内容正文

综合教程

python——筛子游戏

發(fā)布時(shí)間:2023/12/19 综合教程 37 生活家
生活随笔 收集整理的這篇文章主要介紹了 python——筛子游戏 小編覺得挺不錯(cuò)的,現(xiàn)在分享給大家,幫大家做個(gè)參考.
 1 import random
 2  
 3 def roll_dice(numbers = 3,points = None):
 4  print('----- 搖骰子 -----')
 5  if points is None:
 6   points = []
 7  while numbers > 0:
 8   point = random.randrange(1,7)
 9   points.append(point)
10   numbers = numbers - 1
11  return points
12  
13 def roll_result(total):
14  isBig = 11 <= total <=18
15  isSmall = 3 <= total <= 10
16  if isBig:
17   return '大'
18  elif isSmall:
19   return '小'
20  
21 def start_game():
22  your_money = 1000
23  while your_money > 0:
24   print('----- 游戲開始 -----')
25   choices = ['大','小']
26   your_choice = input('請(qǐng)下注,大 or ?。?)
27   your_bet = input('下注金額:')
28   if your_choice in choices:
29    points = roll_dice()
30    total = sum(points)
31    youWin = your_choice == roll_result(total)
32    if youWin:
33     print('骰子點(diǎn)數(shù):',points)
34     print('恭喜,你贏了 {} 元,你現(xiàn)在有 {} 元本金'.format(your_bet,your_money + int(your_bet)))
35     your_money = your_money + int(your_bet)
36    else:
37     print('骰子點(diǎn)數(shù):',points)
38     print('很遺憾,你輸了 {} 元,你現(xiàn)在有 {} 元本金'.format(your_bet, your_money - int(your_bet)))
39     your_money = your_money - int(your_bet)
40   else:
41    print('格式有誤,請(qǐng)重新輸入')
42  else:
43   print('游戲結(jié)束')
44  
45 start_game()

總結(jié)

以上是生活随笔為你收集整理的python——筛子游戏的全部?jī)?nèi)容,希望文章能夠幫你解決所遇到的問題。

如果覺得生活随笔網(wǎng)站內(nèi)容還不錯(cuò),歡迎將生活随笔推薦給好友。