猫史档案馆


【Python作品分享】新的作品【求助帖】

用户:我是小军迷一只hhh我是小军迷一只hhh查看:0 回复:1 评论:0 创建时间:2022-01-03T14:08:07


【作品展示】

center_image

 

【作品介绍】

一个初中阶段常见函数绘制程序

目前由于未知原因非双曲线函数在x=0处也不生成图像

 

【作品源代码】

import turtle
import turtle as t


t.speed(255)
t.penup()
t.goto((-600), 0)
t.pendown()
t.forward(1200)
t.penup()
t.goto(0, (-480))
t.pendown()
t.left(90)
t.forward(960)
while True:
    try:
        t.penup()
        jiexishi = input('解析式(按“a,b,c,d”的形式输入y=ax^2+bx+c+d/x)')
        pos1 = jiexishi.split(',')
        print(pos1)
        for i in range((-600), 600, 1):
            m = (i / 50)
            if (pos1[3] == 0):
                t.goto((m * 50), (((float(pos1[0]) * m ** 2 + float(pos1[1]) * m) + float(pos1[2])) * 50))
                t.pendown()
            else:
                if (m != 0):
                    t.goto((m * 50), ((((float(pos1[0]) * m ** 2 + float(pos1[1]) * m) + float(pos1[2])) + float(pos1[3]) / m) * 50))
                    t.pendown()
                else:
                    t.penup()
        if (input('quit?') == 'y'):
            break
    except :
        print('error!')

 

【提示】

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

https://python.codemao.cn


回复

上一页1 页 / 共 1下一页
mornwindmornwind

反比例二次函数?被辅助线覆盖了吧

点赞0


评论