当前位置:   article > 正文

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

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

在这里插入图片描述

import output06th
output06th.drawLineDo()

turtle.done()
  • 1
  • 2
  • 3
  • 4

在这里插入图片描述

在output06th.py中的代码

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()


  • 1
  • 2
  • 3
  • 4
  • 5
  • 6
  • 7
  • 8
  • 9
  • 10
  • 11
  • 12
  • 13
  • 14
  • 15
  • 16
  • 17
  • 18
  • 19
  • 20
  • 21
  • 22
  • 23
  • 24
  • 25
  • 26
  • 27
  • 28
  • 29

在这里插入图片描述

声明:本文内容由网友自发贡献,不代表【wpsshop博客】立场,版权归原作者所有,本站不承担相应法律责任。如您发现有侵权的内容,请联系我们。转载请注明出处:https://www.wpsshop.cn/w/小桥流水78/article/detail/969054
推荐阅读
相关标签
  

闽ICP备14008679号