源码
import math
import turtle as t
from 三角函数得数 import cos, sin, tan
t.setup(1000, 800, 0, 0)
def write_num_x_y(x, y, num):
t.penup()
t.goto(x, y)
t.write(num, align="right", font=("楷体", 12, "bold"))
def write_line(x,y):
t.pendown()
t.goto(x, y)
t.penup()
def write_line_curve(x, y):
if y>-300+33+203:
print("w")
else:
if y>= -333:
t.pendown()
t.goto(x, y)
t.penup()
if __name__ == '__main__':
y_setnum = 1000
x_setnum = 0
first_y = -300
first_x = -400
first_y += 33
while True:
first_y += 66
write_num_x_y(first_x, first_y, f"{y_setnum/1000}")
t.goto(first_x ,first_y)
write_line(first_x+10, first_y)
y_setnum += 25
if y_setnum > 1175:
first_y = -300
break
first_x += 20
while True:
first_x += 100
x_setnum += 1
write_num_x_y(first_x, first_y, f"{x_setnum}π")
t.goto(first_x-10, first_y+20)
write_line(first_x-10,first_y+30)
if x_setnum > 7:
first_x = -300
break
mark_line_x = first_x-90
mark_line_y = first_y+33
t.goto(mark_line_x, mark_line_y)
write_line(mark_line_x, 300)
t.goto(mark_line_x,mark_line_y)
write_line(410, mark_line_y)
t.color("red")
curve_first_x = mark_line_x
curve_first_y = mark_line_y
in_x = 0
while True:
in_y = tan(in_x)
if in_x % 20 == 0 and in_x != 0:
write_line(curve_first_x+in_x*10, curve_first_y+in_y)
t.goto(curve_first_x+in_x*10, curve_first_y + in_y)
elif in_x == 0:
t.goto(curve_first_x+in_x*10, curve_first_y + in_y)
else:
write_line_curve(curve_first_x+in_x*10, curve_first_y+in_y)
print(in_y)
in_x += 1
if in_x > 80:
break
print(cos(float(9 % 20/10)*math.pi)*66)
t.done()
pass
if __name__ == '__main__':
pass
实现画出边界线的代码
mark_line_x = first_x-90
mark_line_y = first_y+33
t.goto(mark_line_x, mark_line_y)
write_line(mark_line_x, 300)
t.goto(mark_line_x,mark_line_y)
write_line(410, mark_line_y)
实现画出标记不同坐标的符号值的代码
first_y += 33
while True:
first_y += 66
write_num_x_y(first_x, first_y, f"{y_setnum/1000}")
t.goto(first_x ,first_y)
write_line(first_x+10, first_y)
y_setnum += 25
if y_setnum > 1175:
first_y = -300
break
first_x += 20
while True:
first_x += 100
x_setnum += 1
write_num_x_y(first_x, first_y, f"{x_setnum}π")
t.goto(first_x-10, first_y+20)
write_line(first_x-10,first_y+30)
if x_setnum > 7:
first_x = -300
break
画出曲线的代码
t.color("red")
curve_first_x = mark_line_x
curve_first_y = mark_line_y
in_x = 0
while True:
in_y = tan(in_x)
if in_x % 20 == 0 and in_x != 0:
write_line(curve_first_x+in_x*10, curve_first_y+in_y)
t.goto(curve_first_x+in_x*10, curve_first_y + in_y)
elif in_x == 0:
t.goto(curve_first_x+in_x*10, curve_first_y + in_y)
else:
write_line_curve(curve_first_x+in_x*10, curve_first_y+in_y)
print(in_y)
in_x += 1
if in_x > 80:
break