標題:
亂數 (四) - 抽撲克牌
[打印本頁]
作者:
tonyh
時間:
2022-7-16 14:50
標題:
亂數 (四) - 抽撲克牌
本帖最後由 tonyh 於 2022-7-16 14:52 編輯
from random import shuffle
suit=["♠️", "♥️", "♦️", "♣️"]
order=["A", "2", "3", "4", "5", "6", "7", "8", "9", "10", "J", "Q", "K"]
deck=[]
for i in suit:
for j in order:
deck.append(i+j)
shuffle(deck)
for i in range(5):
print(deck.pop()) #後五張
#print(deck[i]) #前五張
複製代碼
作者:
李沛昂
時間:
2022-7-16 15:05
from random import *
suit=["♠️", "♥️", "♦️", "♣️"]
order=["A", "2", "3", "4", "5", "6", "7", "8", "9", "10", "J", "Q", "K"]
deck=[]
for i in suit:
for j in order:
deck.append(i+j)
shuffle(deck)
for i in range(5):
print(deck[i],end=" ")
print()
for i in range(5):
print(deck.pop(),end=" ")
複製代碼
作者:
王捷恩
時間:
2022-7-16 15:08
from random import shuffle
suit=["♠️", "♥️", "♦️", "♣️"]
order=["A", "2", "3", "4", "5", "6", "7", "8", "9", "10", "J", "Q", "K"]
deck=[]
for i in suit:
for j in order:
deck.append(i+j)
shuffle(deck)
print(deck)
for i in range(5):
print(deck.pop())
複製代碼
歡迎光臨 種子論壇 | 高雄市資訊培育協會學員討論區 (http://istak.org.tw/seed/)
Powered by Discuz! 7.2