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

小學(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ù)覽

    <track id="r4fhd"></track>

    <pre id="r4fhd"><abbr id="r4fhd"><code id="r4fhd"></code></abbr></pre>
      <ul id="r4fhd"></ul>

        <menu id="r4fhd"></menu>
        1. 主站蜘蛛池模板: 光山县| 安顺市| 沂水县| 定南县| 凤台县| 育儿| 临沭县| 台湾省| 西乌珠穆沁旗| 松潘县| 张家港市| 阳谷县| 夏津县| 四川省| 岑溪市| 蒲江县| 南皮县| 两当县| 云安县| 仙居县| 拉萨市| 柳河县| 凤庆县| 嵊泗县| 洛阳市| 雷山县| 大埔区| 天祝| 香河县| 苏尼特右旗| 安新县| 合江县| 华阴市| 水富县| 夹江县| 大渡口区| 东平县| 昌乐县| 连山| 辽阳市| 新龙县|