SoFunction
Updated on 2024-11-20

python3 implementation of the countdown effect

In this article, we share the example of python3 to achieve the countdown effect of the specific code for your reference, the specific content is as follows

# 

import turtle,time

def drawGap():  # Plotting digital pipe intervals
    ()
    (5)

def drawLine(draw):   # Drawing a single-segment digital pipe
    drawGap()
    () if draw else ()
    (40)
    drawGap()
    (90)
  
def drawDigit(digit): # Draw a seven-segment digital pipe based on the numbers. It is better to draw the 10 numbers in a seven-segment digital pipe by yourself so that you can understand it better.
    drawLine(True) if digit in [2,3,4,5,6,8,9] else drawLine(False)   # A cross in the middle
    drawLine(True) if digit in [0,1,3,4,5,6,7,8,9] else drawLine(False) # A vertical down on the right
    drawLine(True) if digit in [0,2,3,5,6,8,9] else drawLine(False)   # The bottom one
    drawLine(True) if digit in [0,2,6,8] else drawLine(False)         # A vertical down the left side
    
    (90)
    drawLine(True) if digit in [0,4,5,6,8,9] else drawLine(False)     # One vertical above the left
    drawLine(True) if digit in [0,2,3,5,6,7,8,9] else drawLine(False)  # The top one
    drawLine(True) if digit in [0,1,2,3,4,7,8,9] else drawLine(False)  # The upper right hand vertical

    

def drawDate():   
    ("red")
    i=9
    while i>=0 :
        drawDigit(i)
        ("white")
        drawDigit(8)
        ("red")
        i-=1
                   
def main():
    (800, 350, 200, 200)
    ()
    (-300)
    (5)
    drawDate()
    ()
    () 
    
main()

Countdown effect

This is the whole content of this article.