Home > other >  Python seven segment digital tube drawing letters A - H
Python seven segment digital tube drawing letters A - H

Time:10-13

Inquired of god, how do you use the Python seven segment digital tube drawing code letters A - H

CodePudding user response:

refer to the original poster Lynnzzz response:
inquired of god, and how to use Python seven segment digital tube drawing code letters A - H

The import turtle, datetime
Def drawLine (draw) : # draw single segment digital tube
Turtle. Pendown () if the draw the else turtle. Penup ()
Turtle. Fd (40)
Turtle. Right (90)
Def drawDigit (d) : # according to the seven segment digital tube digital map
DrawLine (True) if d,3,4,5,6,8,9 [2] in else drawLine (False)
DrawLine (True) if d in,1,3,4,5,6,7,8,9 [0] else drawLine (False)
DrawLine (True) if d in,2,3,5,6,8,9 [0] else drawLine (False)
DrawLine (True) if d in,2,6,8 [0] else drawLine (False)
Turtle. Left (90)
DrawLine (True) if d in,4,5,6,8,9 [0] else drawLine (False)
DrawLine (True) if d in,2,3,5,6,7,8,9 [0] else drawLine (False)
DrawLine (True) if d in,1,2,3,4,7,8,9 [0] else drawLine (False)
Turtle. Left (180)
Turtle. Penup ()
Turtle. Fd (20)
Def drawDate (date) : # to output digital
For I in date:
DrawDigit (eval) (I) # note: through the eval () function will Numbers to integers
Def the main () :
Turtle. Setup (800, 350, 200, 200)
Turtle. Penup ()
Turtle. Fd (300)
Turtle. Pensize (5)
DrawDate (datetime. Datetime. Now (). Strftime (' % Y % m % d))
The original code to rewrite

CodePudding user response:

Can write a class object LED digital tube

CodePudding user response:

refer to the second floor JMZL response:
can write a class object LED digital tube

How to write just learning Python is unlikely to??

CodePudding user response:

reference Lynnzzz reply: 3/f
Quote: refer to the second floor JMZL response:
can write a class object LED digital tube

How to write just learning Python is unlikely to?

Write a function to destroy the light of draw seven digital tube,
Translation in a way to display characters, characters shown here to build a dictionary, 1 corresponding to those those who destroy the light is bright, the value with a list of 1 s and 0 s in there, to the character that pipe is light is put out
  • Related