下面展示一些內聯**片
。
# 七段數碼管
import turtle as t
import time
#畫一條線
def drawline
(draw)
: t.
penup()
t.fd(
10)t.
pendown()
if draw else t.
penup()
t.fd(
40)t.
penup()
t.fd(
10)t.
right(90
)def drawall
(num)
:drawline
(true)
if num in[2
,3,4
,5,6
,8,9
]else
drawline
(false)
drawline
(true)
if num in[0
,1,3
,4,5
,6,7
,8,9
]else
drawline
(false)
drawline
(true)
if num in[0
,2,3
,5,6
,8,9
]else
drawline
(false)
drawline
(true)
if num in[0
,2,6
,8]else
drawline
(false)
#下半部分畫完 4條
t.left(90
)drawline
(true)
if num in[0
,4,5
,6,8
,9]else
drawline
(false)
drawline
(true)
if num in[0
,2,3
,5,6
,7,8
,9]else
drawline
(false)
drawline
(true)
if num in[0
,1,2
,3,4
,7,8
,9]else
drawline
(false)
#上半部分畫完 3條
t.penup()
t.left
(180
) t.fd(
20)def drawdate
(date)
:for i in date:
if i ==
"-":
t.pencolor
("green"
) t.
write
("時"
,font=
("arial",18
,"normal"))
t.fd(
40)elif i ==
"+":
t.pencolor
("pink"
) t.
write
("分"
,font=
("arial",18
,"normal"))
t.fd(
40)elif i ==
"=":
t.pencolor
("brown"
) t.
write
("秒"
,font=
("arial",18
,"normal"))
else
:drawall
(eval
(i)) # 把字元變成數字,再去比對
7段數碼管繪製
import turtle,time def drawgap turtle.speed 0 設定畫筆速度 fastest 0 fast 10 normal 6 slow 3 slowest 1 turtle.turtle screen.delay 0 畫筆速度無延遲turtle.penup turt...
7段數碼管繪製
import turtle,datetime def drawgap 繪製數碼管間隔 turtle.penup turtle.fd 5 def drawline draw 繪製單段數碼管 drawgap turtle.pendown if draw else turtle.penup turtle....
7段數碼管繪製
import turtle,datetime def drawgap 繪製數碼管間隔 turtle.penup turtle.fd 5 def drawline draw 繪製單段數碼管 drawgap turtle.pendown if draw else turtle.penup turtle....