数码管代码
# 根据数字绘制七段数码管 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,3,4,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,1,2,6,8] else drawLine(False) left(90) # 第五段 pencolor(random(),random(),random()) drawLine(True) if digit in [0,1,4,5,6,8,9] else drawLine(False) # 第六段 pencolor(random(),random(),random()) drawLine(True) if digit in [0,2,3,5,6,7,8,9] else drawLine(False) # 第七段 pencolor(random(),random(),random()) drawLine(True) if digit in [0,2,3,4,7,8,9] else drawLine(False) left(180) penup() fd(20)