自由式学习
992人加入学习
(0人评价)
Python基础知识-pycharm版
价格 免费
承诺服务
该课程属于 1443-李同学-算法方向-计算机视觉-就业:是 请加入后再学习

定义多点坐标_汇出折线_并计算起始点和终点距离

import turtle

#定义多个点坐标

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((x1-x4)**2+(y1-y4)**2)

turtle.write(distance)

 

[展开全文]

turtle和math模块都是需要导入的

开方,math。sqrt()

 

[展开全文]

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((x1 - x4) ** 2 +(y1 - y4)**2) turtle.write(distance)

[展开全文]

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,x1)

turtle.pendown()

.....

.....

.....

distance=math.sqrt((x1-x4)**2+(yi-y4)**2)

turtle.write(distance)

[展开全文]