Python快速入门魔力手册pdf
链接:https://pan.baidu.com/s/1mv-ETpzHwc1n1iCzMf-8KA提取码:kcpz
复制这段内容后打开百度网盘手机App,操作更方便哦 谢谢分享 谢谢分享 可以使用 谢谢
{:7_139:} 非常感谢楼主的分享!! 谢谢楼主分享啦 感谢分享,收藏 谢谢大神共享!👍👍👍👍👍👍👍 谢谢分享 谢谢分享 谢谢分享 谢谢分享 本帖最后由 uglybeauty 于 2020-2-24 22:25 编辑
第五章综合练习题作业分享
import random
def roll_dice(numbers=3, points=[]):
print('<<<<< ROLL THE DICE >>>>>')
while numbers > 0:
point = random.randrange(1,6)
points.append(point)
numbers = numbers - 1
return points
def roll_result(total):
isBig = 11<=total<=18
isSmall = 3 <=total <=10
if isBig:
return 'Big'
elif isSmall:
return 'Small'
def start_game():
print('<<<<< GAME STARTS! >>>>>')
money = 10000
while money > 0:
print('You have:',money)
choices = ['Big','Small']
your_choice = input('Big or Small:')
your_bet = input('How much you wanna bet?:')
if your_choice in choices:
points = roll_dice()
total = sum(points)
youWin = your_choice==roll_result(total)
if youWin:
print('The points are:',points,'You Win!')
money = money+int(your_bet)
print('You gained',your_bet,',','You have',money,'now')
else:
print('The points are:',points,'You lose!')
money = money-int(your_bet)
print('You lost',your_bet,',','You have',money,'now')
else:
print('Invalid Words')
start_game()
start_game() 感谢分享 谢谢分享 谢谢楼主分享
你是最棒的 谢谢分享~~
页:
[1]
2