random.shuffle()
random.sample()

撲克牌洗牌:

輸出結果:

撲克牌洗牌:
import random
cards = list(range(1,53)) ##len(cards) = 52
random.shuffle(cards)
num=13
card1 = cards[0:num]
card2 = cards[num:num*2]
card3 = cards[num*2:num*3]
card4 = cards[num*3:]
print(“card1:”,card1)
print(“card2:”,card2)
print(“card3:”,card3)
print(“card4:”,card4)

推薦hahow線上學習python: https://igrape.net/30afN

![Python: 使用 flat_list.extend( List[pandas.Series] ) 實現 pandas.DataFrame 列擴展教學 Python: 使用 flat_list.extend( List[pandas.Series] ) 實現 pandas.DataFrame 列擴展教學](https://i2.wp.com/savingking.com.tw/wp-content/uploads/2025/04/20250421141348_0_14cedf.png?quality=90&zoom=2&ssl=1&resize=350%2C233)






![Python TQC考題604 眾數, cnt[L.index(n)]+=1, L[cnt.index(max(cnt))], if L.count(n)>maxcnt: Python TQC考題604 眾數, cnt[L.index(n)]+=1, L[cnt.index(max(cnt))], if L.count(n)>maxcnt:](https://i0.wp.com/savingking.com.tw/wp-content/uploads/2022/04/20220430181911_73.png?quality=90&zoom=2&ssl=1&resize=350%2C233)

近期留言