|
发表于 2021-11-29 11:53:33
|
显示全部楼层
- import turtle
- import numpy as np
- # y = a ^ x
- screen = turtle.Screen()
- screen.setworldcoordinates(-11, -1, 11, 4)
- a = 1.1 #
- x1 = np.linspace(-10, 10, 50)
- y1 = [a ** x for x in x1]
- turtle.penup()
- turtle.setpos(x1[0], y1[0])
- turtle.pendown()
- for i in range(1, len(x1)):
- turtle.goto(x1[i], y1[i])
- screen.mainloop()
复制代码
- import turtle
- import numpy as np
- screen = turtle.Screen()
- # y = x ^ 2
- screen.setworldcoordinates(-11, -1, 11, 125)
- x2 = np.linspace(-10, 10, 100)
- y2 = [x ** 2 for x in x2]
- turtle.penup()
- turtle.setpos(x2[0], y2[0])
- turtle.pendown()
- for i in range(1, len(x2)):
- turtle.goto(x2[i], y2[i])
- screen.mainloop()
复制代码 |
|