Fetch the repository succeeded.
import random
class Point:
def setx(self,xcoord):
self.x = xcoord
def sety(self,ycoord):
self.y = ycoord
def get(self):
return (self.x,self.y)
def move(self,dx,dy):
self.x += dx
self.y += dy
def getx(self):
return self.x
def gety(self):
return self.y
def calculate(a,b):
x1 = a.getx()
y1 = a.gety()
x2 = b.getx()
y2 = b.gety()
direction = ((x1-x2)**2+(y1-y2)**2)**(1/2)
return direction
p1 = Point()
p1.setx(random.randint(0,10))
p1.sety(9)
print('p1的坐标为:{}'.format(p1.get()))
p2 = Point()
p2.setx(random.randint(0,10))
p2.sety(3)
print('p2的坐标为:{}'.format(p2.get()))
distance = calculate(p1,p2)
print('p1与p2之间的距离为{0:.2f}'.format(distance))
此处可能存在不合适展示的内容,页面不予展示。您可通过相关编辑功能自查并修改。
如您确认内容无涉及 不当用语 / 纯广告导流 / 暴力 / 低俗色情 / 侵权 / 盗版 / 虚假 / 无价值内容或违法国家有关法律法规的内容,可点击提交进行申诉,我们将尽快为您处理。