python课后题答案第五章_Python语言程序设计基础(第2版) 课后题 第五章

#e7.2DrawSevenSegDisplay.py

import turtle, datetime

def drawGap(): #绘制数码管间隔

turtle.penup()

turtle.fd(5)

def drawLine(draw): #绘制单段数码管

drawGap()

turtle.pendown() if draw else turtle.penup()

turtle.fd(40)

drawGap()

turtle.right(90)

def drawDigit(d): #根据数字绘制七段数码管

drawLine(True) if d in [2,3,4,5,6,8,9] else drawLine(False)

drawLine(True) if d in [0,1,3,4,5,6,7,8,9] else drawLine(False)

drawLine(True) if d in [0,2,3,5,6,8,9] else drawLine(False)

drawLine(True) if d in [0,2,6,8] else drawLine(False)

turtle.left(90)

drawLine(True) if d in [0,4,5,6,8,9] else drawLine(False)

drawLine(True) if d in [0,2,3,5,6,7,8,9] else drawLine(False)

drawLine(True) if d in [0,1,2,3,4,7,8,9] else drawLine(False)

turtle.left(180)

turtle.penup()

turtle.fd(20)

def drawDate(date):

turtle.pencolor("red")

for

你可能感兴趣的:(python课后题答案第五章)