中文字幕精品无码一区二区,成全视频在线播放观看方法,大伊人青草狠狠久久,亚洲一区影音先锋色资源

小學(xué)課后服務(wù) Python少兒編程 入門篇:15-撲克游戲之準(zhǔn)備 課件 (12張PPT)

資源下載
  1. 二一教育資源

小學(xué)課后服務(wù) Python少兒編程 入門篇:15-撲克游戲之準(zhǔn)備 課件 (12張PPT)

資源簡介

(共12張PPT)
Lorem ipsum dolor sit amet, consectetuer adipiscing elit. Aenean commodo ligula eget dolor. Cum sociis natoque penatibus et magnis dis parturient montes, nascetur ridiculus mus.
少兒編程課
撲克游戲之準(zhǔn)備
隨機(jī)數(shù)
import random
random.randint(1,10):隨機(jī)生成1~10范圍內(nèi)任意一個(gè)整數(shù)。
random.shuffle():
將列表中的所有元素隨機(jī)排序
隨機(jī)數(shù)方法
列表
random.shuffle( )
li=['a',b','c','d','e']
random.shuffle( li )
import random
li=['a',b','c','d','e']
random.shuffle(li)
print(li)
運(yùn)行結(jié)果:
['d','b','e','a','c']
隨機(jī)結(jié)果
隨機(jī)排序
import random
li=['a',b','c','d','e']
for i in range(5):
random.shuffle(li)
print(li)
['b', 'c', 'a', 'd', 'e']
['c', 'a', 'd', 'e', 'b']
['c', 'e', 'a', 'd', 'b']
['a', 'c', 'e', 'b', 'd']
['e', 'd', 'c', 'a', 'b']
運(yùn)行結(jié)果:
追加數(shù)據(jù)
cards=[] #定義一個(gè)空列表
append(內(nèi)容):向列表中追加內(nèi)容
cards.append(1)
cards.append(2)
cards.append(3)
print(cards)
[1, 2, 3]
運(yùn)行結(jié)果:
cards=[1,2,3]
cards.append(4)
print(cards)
插入數(shù)據(jù)
insert(位置,內(nèi)容):在列表的指定位置插入內(nèi)容
cards=[1,2,3]
cards.insert(0,0)
print(cards)
運(yùn)行結(jié)果:
[1, 2, 3, 4]
運(yùn)行結(jié)果:
[0, 1, 2, 3]




構(gòu)成元素
A
Q
J
10
K
9
8

A
Q
J
A
K
9
8

連接符
cards.append(' '+'4')
print(cards)
cards=[]
+:左右的內(nèi)容為字符串,則為連接符
運(yùn)行結(jié)果:
[' 4']
雙重for循環(huán)
for x in range(10):
#需要重復(fù)執(zhí)行的代碼
#需要重復(fù)執(zhí)行的代碼
for y in range(10):
#需要重復(fù)執(zhí)行的代碼
循環(huán)中的代碼需要縮進(jìn)4個(gè)空格
洗牌代碼
import random
num = ['A', 'K', 'Q', 'J', '10', '9', '8', '7', '6', '5', '4', '3', '2']
type = [' ', ' ', ' ', ' ’]
cards = [] # 紙牌空列表
for i in type:
for j in num:
cards.append(i + j)
random.shuffle(cards) # 將紙牌列表全部打亂
將組合后的牌存放到列表中

展開更多......

收起↑

資源預(yù)覽

  • <menuitem id="wfhyu"><abbr id="wfhyu"></abbr></menuitem>

    <bdo id="wfhyu"></bdo>
  • <bdo id="wfhyu"></bdo>
    主站蜘蛛池模板: 固阳县| 屯留县| 青河县| 永州市| 板桥市| 长海县| 大埔县| 会宁县| 宁陕县| 曲松县| 成都市| 大港区| 遵义县| 盖州市| 平定县| 长寿区| 道真| 济源市| 舟曲县| 泰来县| 龙口市| 日喀则市| 沙河市| 武川县| 藁城市| 沧源| 时尚| 洛南县| 独山县| 红安县| 新化县| 普兰店市| 松桃| 大埔区| 宜丰县| 屯留县| 松滋市| 阳春市| 西充县| 察雅县| 平塘县|