猫史档案馆


【Python作品分享】让Turtle再次伟大 【反比例函数】【教程贴】

用户:BlueHackerBlueHacker查看:0 回复:0 评论:0 创建时间:2022-04-16T16:47:42


【作品展示】

center_image

 

【作品介绍】

make turtle great again!

本程序将绘制所有y=k*x**(-1)(k ∈ N*)的图像!

 

【作品源代码】

print('Turtle盛宴')
import turtle
t = turtle.Pen()
t.speed(0)
t.goto(-300, 0)
t.goto(300, 0)
t.goto(0, 0)
t.goto(0, 300)
t.goto(0, -300)
a = turtle.Pen()
a.speed(0)


def InverseFunction(k):

    def go(x_goto, k1):
        t.goto(x_goto * 50, (k1/x_goto) * 50)
    def go2(x_goto, k1):
        a.goto(x_goto * 50, (k1/x_goto) * 50)

    t.up()
    go(1/7, k)
    t.down()

    a.up()
    go2(-1/7, k)
    a.down()

    # for i in range(100):
        # go(10-i/10,k)
    for i in range(70):
        go(k/(7-i/10), k)
        go2(-k/(7-i/10), k)


sums = 1
while 1:
    print('y=',sums,'· x^(-1)')
    InverseFunction(sums)
    sums += 1

turtle.done()

 

【提示】

部分含有Python第三方库相关内容的作品,在海龟编辑器网页端无法运行哦!如遇到这种情况,可以打开下面的链接,下载海龟编辑器客户端:

https://python.codemao.cn


回复

上一页1 页 / 共 0下一页