python之七段电子数码管的绘制

编程入门 行业动态 更新时间:2024-10-07 20:27:53

python之<a href=https://www.elefans.com/category/jswz/34/1741067.html style=七段电子数码管的绘制"/>

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之七段电子数码管的绘制

本文发布于:2024-02-07 06:12:16,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1754443.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:七段   数码管   电子   python

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!