import random
a = random.randrange(1,10)
b = random.randrange(1,10)
class PointLenth:
    def __init__(self,x,y,x1,y1):
        self.x=x
        self.x1=x1
        self.y=y
        self.y1=y1
    def lenth(self):
        dx=(self.x)-(self.x1)
        dy=(self.y)-(self.y1)
        distance=(dx**2+dy**2)**0.5
        print(distance)

p1=PointLenth(a,22,b,21)
print(p1.lenth())
print(' 运行完毕!')

 

posted on 2021-12-04 09:24  20211422王俊凯  阅读(35)  评论(0编辑  收藏  举报