Here is code for a Point class in Python.
import math
def square(x):
return x*x
class Point:
def __init__(self, x, y):
self.x = x
self.y = y
def getX(self):
return self.x
def getY(self):
return self.y
def distance(self, p):
return math.sqrt(square(self.x-p.getX()) + square(self.y-p.getY()))
p = Point(0,0)
q = Point(3,4)
r = Point(1,1)
print p.distance(q)
print p.distance(r)
Write a Randp class in Python.