编程语言
首页 > 编程语言> > python 绘制sinx

python 绘制sinx

作者:互联网

 

 code

import turtle
import math

turtle.speed(0)
turtle.penup()
turtle.goto(-175, 50 * math.sin((-175/100) * 2 * math.pi))
turtle.pendown()
turtle.color("red")
for x in range(-175, 176):

    turtle.goto(x, 50 * math.sin((x/100) * 2 * math.pi))

turtle.color("black")
turtle.penup()
turtle.goto(-100, -15)
turtle.write("-2\u03c0", font=("黑体", 15))
turtle.pendown()

turtle.penup()
turtle.goto(100, 15)
turtle.write("2\u03c0", font=("黑体", 15))
turtle.pendown()

turtle.penup()
turtle.goto(-160, 0)
turtle.pendown()
turtle.goto(160, 0)
turtle.write("x", font=("宋体",15))
turtle.goto(150, 10)
turtle.goto(160, 0)
turtle.goto(150, -10)

turtle.penup()
turtle.goto(0, -160)
turtle.pendown()
turtle.goto(0, 160)
turtle.write("y", font=("宋体",15))
turtle.goto(-10, 150)
turtle.goto(0, 160)
turtle.goto(10, 150)
turtle.done()

 

 

标签:turtle,15,goto,sinx,penup,python,绘制,pendown,160
来源: https://www.cnblogs.com/sea-stream/p/10804936.html