1 Star 0 Fork 0

杨谨徽/代码托管

Create your Gitee Account
Explore and code with more than 13.5 million developers,Free private repositories !:)
Sign up
文件
This repository doesn't specify license. Please pay attention to the specific project description and its upstream code dependency when using it.
Clone or Download
计算两点间的距离 585 Bytes
Copy Edit Raw Blame History
杨谨徽 authored 2021-12-02 13:08 +08:00 . add 计算两点间的距离.
import random
class Point:
def __init__(self, x1, y1, x2, y2):
self.x1 = x1
self.y1 = y1
self.x2 = x2
self.y2 = y2
def getpoint(self):
print("点p1为({}, {})".format(d.x1, d.y1))
print("点p2为({}, {})".format(d.x2, d.y2))
def getdistance(self):
distance = float((self.x2 - self.x1) ** 2 + (self.y2 - self.y1) ** 2) ** 0.5
print("p1和p2间的距离为{}".format(distance))
d = Point(random.randint(-100, 100), 20 ,random.randint(-100, 100), 24)
d.getpoint()
d.getdistance()
Loading...
马建仓 AI 助手
尝试更多
代码解读
代码找茬
代码优化
1
https://gitee.com/SHIBATORI/code-hosting.git
git@gitee.com:SHIBATORI/code-hosting.git
SHIBATORI
code-hosting
代码托管
master

Search