Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- from math import sqrt
- class Punkt2D(object):
- def __init__(self, x , y):
- self.x = x
- self.y = y
- def odl(self, other):
- return sqrt(((other.x - self.x)*(other.x - self.x)+(other.y - self.y)*(other.y - self.y)))
- class Punkt3D(Punkt2D):
- def __init__(self, x, y, z):
- super().__init__(x, y)
- self.z = z
- def odl(self, other):
- return sqrt(((other.x-self.x)*(other.x-self.x)+(other.y-self.y)*(other.y-self.y)+(other.z-self.z)*(other.z-self.z)))
- ob1 = Punkt2D(1, 1)
- ob2 = Punkt2D(2, 2)
- ob3 = Punkt3D(1, 1, 1)
- ob4 = Punkt3D(3, 3, 3)
- print(ob1.odl(ob2))
- print(ob3.odl(ob4))
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement