import math class point: def __init__(self, x, y, z): self.x = x self.y = y self.z = z p1 = point(10,14,0) p2 = point(14,14,0) distanceByTwoPoints = math.sqrt((p1.y-p2.y)**2 + (p1.x-p2.x)**2)
Here is what the above code is Doing:
1. We create a class called point.
2. We create a constructor that takes in three parameters: x, y, and z.
3. We create two objects of the class point, p1 and p2.
4. We calculate the distance between p1 and p2 using the formula for distance between two points.