2021-2022-1 20211424 《信息安全专业导论》打印两点距离

import random

n1 = random.randrange(1,10)
n2 = 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(n1,24,n1,31)
print(p1.lenth())

 

posted @ 2021-12-04 19:52  WWWKnight  阅读(26)  评论(0)    收藏  举报