2021-02-08 数据类型---作业题
作者:互联网
作业题1
import random
result = {}
user_list = ['姗姗','圆圆','飞飞']
# 1、生成一副扑克牌
total_poke_list = [('小王',14),('大王',15)]
color_list = ['♥️','♣️','♦️','♠️']
num_list = []
for num in range(1,14):
num_list.append(num)
for coler in color_list:
for num in num_list:
item = (coler,num,)
total_poke_list.append(item)
## print(total_poke_list)
## print(len(total_poke_list))
# 2、发牌给各用户
for user in user_list:
score = 0
index = random.randint(0,len(total_poke_list) - 1)
# print(index)
poke = total_poke_list.pop(index)
value = poke[1]
if poke[1] > 10:
value = 0.5
score += value
print('给{}发的牌{} {},目前玩家-->{}所有牌的牌面面值总和为:{}'.format(user,poke[0],poke[1],user,score))
while True:
choice = input('请问是否还需要继续发牌:( 输入y继续发牌,输入n不发牌:)')
if choice.upper() == 'N':
break
if choice.upper() not in {'Y','N'}:
print('输入错误,请重新输入:')
continue
index = random.randint(0, len(total_poke_list) - 1)
print(index)
poke = total_poke_list.pop(index)
value = poke[1]
if poke[1] > 10:
value = 0.5
score += value
print('给{}发的牌{} {},目前玩家-->{}所有牌的牌面面值总和为:{}'.format(user, poke[0], poke[1], user, score))
if score > 11:
print('用户{}分数已超过11分,标签:02,poke,数据类型,08,list,score,user,print,total
来源: https://blog.csdn.net/xemal369/article/details/113763640