作业题1
import random
result = { }
user_list = [ '姗姗' , '圆圆' , '飞飞' ]
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)
for user in user_list:
score = 0
index = random. randint( 0 , len ( total_poke_list) - 1 )
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分,💥了' . format ( user) )
score = 0
break
result[ user] = score
print ( result)