七段电子数码管的绘制"/>
python之七段电子数码管的绘制
# 七段电子数码管的绘制.py# 导入库模块 # import turtle # turtle.penup() # import turtle as tl # tl.done() from turtle import * from random import * import time speed(10) #a = ['red', 'yellow', 'green', 'blue', 'pink', 'orange']# 绘制单段间隔 def drawGap():up()fd(5)# 绘制单段数码管(单个数字) def drawLine(draw):if draw:down()else:up()fd(40)drawGap()right(90)# 根据数字绘制七段数码管(多个数字) def drawDigit(digit):pencolor(random(),random(),random())drawLine(True) if digit in [2, 3, 4, 5, 6, 8, 9] else drawLine(False)pencolor(random(),random(),random())drawLine(True) if digit in [0, 1, 3, 5, 6, 7, 8, 9] else drawLine(False)pencolor(random(),random(),random())drawLine(True) if digit in [0, 2, 3, 5, 6, 8, 9] else drawLine(False)pencolor(random(),random(),random())drawLine(True) if digit in [0, 2, 6, 8] else drawLine(False)
更多推荐
python之七段电子数码管的绘制
发布评论