《PYTHON 语言程序设计》2018版 第1章第21题改进中(十)做到这,这个题下轮再说吧


# 使用时单独引用time函数
class time_show:
    def __init__(self):
        self.__total_time = int(time.time())
        self.__current_hours = (self.__total_time // 3600) % 24 % 365 + 8
        self.__current_minute = self.__total_time % 3600 // 60
        self.__current_seconds = self.__total_time % 3600 % 24 % 365

    def show_time(self):
        print(f"Current hours {self.__current_hours}:{self.__current_minute}:{self.__current_seconds}")

    def get_hours(self):
        return self.__current_hours

    def get_minute(self):
        return self.__current_minute

    def get_second(self):
        return self.__current_seconds


a = time_show().get_second()

b = time_show().get_hours()
c = time_show().get_minute()
time_show().show_time()


def Draw_line(second, minute, hour):
    turtle.speed(30)
    axis_x = 0
    axis_y = 0
    turtle.penup()
    turtle.goto(axis_x, axis_y - 150)
    turtle.pendown()
    turtle.circle(150)
    turtle.penup()
    turtle.goto(axis_x, axis_y)
    turtle.dot(7, "blue")

    turtle.penup()
    turtle.goto(axis_x, axis_y)
    turtle.right(270+second)
    turtle.pendown()
    turtle.color("red")
    turtle.forward(100)
    turtle.penup()
    turtle.goto(axis_x, axis_y)
    turtle.right(0)

    turtle.penup()
    turtle.pensize(5)
    turtle.goto(axis_x, axis_y)
    turtle.right(270+minute)
    turtle.pendown()
    turtle.color('blue')
    turtle.forward(80)
    turtle.penup()
    turtle.goto(axis_x, axis_y)
    turtle.right(0)

    turtle.penup()
    turtle.pensize(5)
    turtle.goto(axis_x, axis_y)
    turtle.right(270+hour)
    turtle.pendown()
    turtle.color('black')
    turtle.forward(80)
    turtle.penup()
    turtle.goto(axis_x, axis_y)
    turtle.right(0)


Draw_line(a, b, c)

turtle.hideturtle()
turtle.done()

在这里插入图片描述

在这里插入图片描述

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

贾宝不是玉

谢谢各位兄弟们的关注,谢谢破费

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

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

余额充值