《python语言程序设计》2018版第6章第42题Turtle:绘制sin函数,使用程序清单6-14中的函数简化5.52代码

python 复制代码
import output06th
output06th.drawLineDo()

turtle.done()

在output06th.py中的代码

python 复制代码
import turtle
import math


def drawLineDo():
    turtle.speed(40)
    turtle.penup()
    turtle.goto(-175, 50 * math.sin((-175 / 100 * 2 * math.pi)))
    turtle.pendown()
    for x in range(-175, 176):
        turtle.goto(x, 50 * math.sin((x / 100 * 2 * math.pi)))

    turtle.penup()
    turtle.goto(-300, 0)
    turtle.pendown()
    turtle.goto(300, 0)
    turtle.penup()
    turtle.goto(0, 300)
    turtle.pendown()
    turtle.goto(0, -300)
    turtle.penup()
    turtle.goto(-100, -15)
    turtle.write("-2\u03c0")
    turtle.goto(100, -15)
    turtle.write("2\u03c0")
    turtle.hideturtle()
    turtle.done()
相关推荐
倔强青铜三29 分钟前
苦练Python第46天:文件写入与上下文管理器
人工智能·python·面试
用户2519162427114 小时前
Python之语言特点
python
刘立军4 小时前
使用pyHugeGraph查询HugeGraph图数据
python·graphql
数据智能老司机8 小时前
精通 Python 设计模式——创建型设计模式
python·设计模式·架构
数据智能老司机9 小时前
精通 Python 设计模式——SOLID 原则
python·设计模式·架构
c8i10 小时前
django中的FBV 和 CBV
python·django
c8i10 小时前
python中的闭包和装饰器
python
这里有鱼汤13 小时前
小白必看:QMT里的miniQMT入门教程
后端·python
TF男孩1 天前
ARQ:一款低成本的消息队列,实现每秒万级吞吐
后端·python·消息队列
该用户已不存在1 天前
Mojo vs Python vs Rust: 2025年搞AI,该学哪个?
后端·python·rust