1.代码
#1、七段数码管的绘制.py
#2、导入库模块
from random import *
from time import *
from turtle import *
#3、绘制单段间隔
def drawGap():
penup()
fd(5)
#4、绘制单段数码管
def drawLine(draw):
drawGap();
if draw:
pendown()
else:
penup()
fd(40)
drawGap()
right(90)
#5、随机颜色
def pencolort():
pencolor(random(),random(),random())
#6、根据数字绘制七段数码管
def drawDigit(digit):
#第1段
pencolor(random(),random(),random())
drawLine(True) if digit in [2,3,4,5,6,8,9] else drawLine(False)
#第2段
pencolor(random(),random(),random())
drawLine(True) if digit in [0,1,3,4,5,6,7,8,9] else drawLine(False)
#第3段
pencolor(random(),random(),random())
drawLine(True) if digit in [0,2,3,5,6,8] else drawLine(False)
#第4段
pencolor(random(),
10-24
280
![](https://csdnimg.cn/release/blogv2/dist/pc/img/readCountWhite.png)
10-27
1127
![](https://csdnimg.cn/release/blogv2/dist/pc/img/readCountWhite.png)
12-02
1500
![](https://csdnimg.cn/release/blogv2/dist/pc/img/readCountWhite.png)
06-01
“相关推荐”对你有帮助么?
-
非常没帮助
-
没帮助
-
一般
-
有帮助
-
非常有帮助
提交