工作基数以及数字二极管部分

运用编写函数打印当前日期和时间

#1、导入库模块

#2、绘制单段间隔

#3、绘制单段数码管

#4、根据数字绘制七段数码管

#5、获得要输出的数字

#6、主函数(设置画布与画笔等)

#7、调用主函数

#1、导入库模

#import turtle    #导入海龟图库import,用这种方式导入,方法前面必须添加库名turtle

#import turtle as tl #如果用这种方式导入库方法前面必须添加库的别名

from turtle import * #用这种方式导入,方法前面不能添加库名turtle

from random import * #导入随机库模块

#2、绘制单段间隔

def drawGap():

    penup()  #将画壁设置为飞行模式

    fd(5)    #画笔向前行进5像素

       

#3、绘制单段数码管

def drawline(draw):   #定义函数,注意参数draw

    drawGap()       #调用drawGap()函数

    if draw:

        pendown()        #将画壁设置工作模式

    else:

        penup()

    fd(20)               #向前进20像素

    drawGap()

    right(90)       #将画笔前进方向右或者向下旋转90

   

#4、根据数字绘制七段数码管

def drawDigit(digit):

     #1

    pencolor(random(),random(),random())    #借用随机函数生成随机颜色

    drawline(True) if digit in [2,3,4,5,6,8,9] else drawline(False#用条件表达式判断画单端管

     #2

    pencolor(random(),random(),random())

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

     #3

    pencolor(random(),random(),random())

    drawline(True) if digit in [2,3,4,5,6,8,9] else drawline(False#用条件表达式判断画单端管

     #4

    pencolor(random(),random(),random())

    drawline(True) if digit in [0,2,3,5,6,8,9,] else drawline(False#用条件表达式判断画单端管

    left(90)        #将画笔方向向上,旋转90

     #5

    pencolor(random(),random(),random())

    drawline(True) if digit in [0,2,6,8] else drawline(False#用条件表达式判断画单端管

     #6

    drawline(True) if digit in [0,2,3,5,7,8,9] else drawline(False#用条件表达式判断画单端管

     #7

    drawline(True) if digit in [0,1,2,3,4,7,8,9] else drawline(False#用条件表达式判断画单端管

    left(180)

   

    penup()

    fd(20)    #数字之间的间隙为20

   

  File "<ipython-input-32-e8b2a2b84fc6>", line 2

    def drawDigit(digit):

                         ^

SyntaxError: unexpected EOF while parsing

import random

random.random()

评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值