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

小學課后服務 Python少兒編程 提高篇:11-自制鐘表3 課件 (35張PPT)

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

小學課后服務 Python少兒編程 提高篇:11-自制鐘表3 課件 (35張PPT)

資源簡介

(共35張PPT)
Lorem ipsum dolor sit amet, consectetuer adipiscing elit. Aenean commodo ligula eget dolor. Cum sociis natoque tatibus et magnis dis parturient montes, nascetur ridiculus mus.
少兒編程課
時鐘(三)
畫筆方向
seth ()
分隔字符串并返回列表
split('分隔符')
顯示畫筆
st ()
split指令獲取列表
a = 'a1b1c1d1e'
b = a.split('1')
print(b)
split('分隔符'):拆分字符串。通過指定分隔符對字符串進行切片,并返回分割后的字符串列表。
運行結果:
['a', 'b', 'c', 'd', 'e']
seth指令
seth (或setheading):畫筆的起始方向。
(90)
(0)
(-90)
(180)或(-180)
指針位置公式
秒針:s * 6
分針:m * 6
時針:h * 30 + m * 0.5
clear
清 空
if
如 果
sleep
休 眠
true

本節目標
秒針的運動規律
秒針當前位置
秒針消失
秒針出現在下一位置
經過一秒
…… 一直循環
sleep指令
sleep(秒數):讓程序休眠(停止工作)一定秒數。
for x in range(5):
print(strftime("%I:%M:%S", localtime()))
for x in range(5):
sleep(1) #讓循環間隔一秒再進行
print(strftime("%I:%M:%S", localtime()))
運行結果:
運行結果:
休眠工具
from time import localtime,strftime,sleep
休眠
t1.up()
t1.right(s * 6)
t1.fd(60)
t1.st()
改寫代碼
以顯示當前秒針位置的代碼為基礎,在程序后面添加休眠和隱藏顯示畫筆命令,并建立循環。
秒針的循環代碼
秒針顯示當前位置
休眠一秒
隱藏秒針
進入下一秒
while True:
tt = strftime('%I:%M:%S', localtime())
ts = tt.split(':')
s = int(ts[2]) #獲取秒
   t1.seth (90)
   t1.up()
   t1.goto(0, 0) #畫筆返回圓心位置
   t1.right(s * 6)
   t1.fd(60)
   t1.st () #顯示畫筆
   sleep(1) #等待一秒
   t1.ht () #隱藏畫筆
秒針運動
反思總結
分針的運動規律
當秒針運動到零點,分針開始運動。
while True:
tt = strftime('%I:%M:%S', localtime())
ts = tt.split(':')
s = int(ts[2])
t1.seth(90)
t1.up()
t1.goto(0,0)
t1.right(s * 6)
t1.fd(60)
t1.st()
對循環進行分析
在while循環中,由于sleep方法的存在,每循環一次,時間會發生變化。
當“s=0”時,重新繪制分針。
while True:
tt = strftime('%I:%M:%S', localtime())
ts = tt.split(':')
m = int(ts[1])
s = int(ts[2])
t1.seth(90)
t1.up()
t1.goto(0,0)
t1.right(s * 6)
t1.fd(60)
t1.st()
獲取分鐘的數值
獲取每一次循環中分鐘的數值
繪制分針
根據當前“m”數值繪制分針
while True:
……
if s == 0:
t2.seth (90)
t2.up()
t2.goto(0,0)
t2.right(m * 6)
t2.down()
t2.fd(50)
sleep(1)
讓分針運動
時針的運動規律
同分針一樣,當秒針運動到零點,重新繪制時針。
獲取小時的數值
while True:
tt = strftime('%I:%M:%S', localtime())
ts = tt.split(':')
h = int(ts[0])
m = int(ts[1])
s = int(ts[2])
t1.seth(90)
t1.up()
t1.goto(0,0)
t1.right(s * 6)
t1.fd(60)
t1.st()
獲取每一次循環中小時的數值
繪制時針
根據當前“m”和“h”的數值繪制時針
if s == 0 :
……
t3.seth (90)
t3.up()
t3.goto(0,0)
t3.right(h* 30 + m * 6)
t3.down()
t3.fd(50)
sleep(1)
讓時針運動
重復繪制
繪制分針時,前一個分針沒有消失。
clear指令
clear():清空當前畫筆繪制的內容。
import turtle
t = turtle.Turtle()
t.forward(100)
import turtle
t = turtle.Turtle()
t.forward(100)
t.clear() #清空
畫筆繪制的內容被清空。
清空畫筆
反思總結
項目代碼(一)
項目代碼(二)
項目代碼(三)
項目代碼(四)

展開更多......

收起↑

資源預覽

<pre id="tfb94"><li id="tfb94"></li></pre>

<bdo id="tfb94"><rt id="tfb94"></rt></bdo>
  • <menu id="tfb94"><dl id="tfb94"></dl></menu><i id="tfb94"><acronym id="tfb94"><sub id="tfb94"></sub></acronym></i>

    1. 主站蜘蛛池模板: 城步| 聂拉木县| 梨树县| 河北区| 泾川县| 博野县| 清流县| 紫金县| 永州市| 磐安县| 海盐县| 木里| 外汇| 明溪县| 鄂伦春自治旗| 玛多县| 乐安县| 房山区| 淮滨县| 永善县| 历史| 通渭县| 家居| 三原县| 陆川县| 招远市| 滨海县| 方山县| 晋中市| 双柏县| 新建县| 平谷区| 新宁县| 道真| 固镇县| 赫章县| 岗巴县| 当涂县| 长沙县| 秭归县| 安乡县|