使用海龟绘图。输入多个点,将这些点都两两相连。
import turtle
def con_line(xpoint_set,ypoint_set):
"""将输入点两两相连"""
turtle.pensize(2)
turtle.speed(1)
n=0
for i,j in zip(xpoint_set,ypoint_set):
turtle.penup()
turtle.goto(i,j)
turtle.pendown()
n += 1
m = 0
for x, y in zip(xpoint_set, ypoint_set):
m += 1
if m >= n:
turtle.goto(x,y)
turtle.penup()
turtle.goto(i,j)
turtle.pendown()
turtle.hideturtle()
turtle.done()
if __name__ == '__main__':
xpoint_set = list(map(int,input("x点集:").split(" ")))
ypoint_set = list(map(int,input("y点集:").split(" ")))
con_line(xpoint_set,ypoint_set)
![在这里插入图片描述](https://img-blog.csdnimg.cn/a9645e70db764114a777136571ba22ed.gif#pic_center)