标签:class pre turtle 绘制 port 距离 pen style color
定义多点坐标_绘制折线_并计算起始点和终点的距离
源码
import turtle import math # 定义多个坐标点 x1, y1 = 100, 100 x2, y2 = 100, -100 x3, y3 = -100, -100 x4, y4 = -100, 100 # 绘制折线 turtle.penup() turtle.goto(x1, y1) turtle.pendown() turtle.goto(x2, y2) turtle.goto(x3, y3) turtle.goto(x4, y4) # 计算起点和终点的距离 distance = math.sqrt((x4 - x1)**2 + (y4 - y1)**2) turtle.write(distance)
标签:class pre turtle 绘制 port 距离 pen style color
原文地址:https://www.cnblogs.com/cherish-lwy/p/10489898.html