class Point(object):
def __init__(self,x=0,y=0,z=0):
self.x_coord = x ## setting the attribute x_coord
self.y_coord = y ## setting the attribute y_coord
self.z_coord = z
my_point = Point(2,3) ## creating an instance of Point called 'my_point'
#print(my_point.x_coord)
#print(my_point.y_coord)
my_point.z_coord = 1
print(my_point.z_coord)
new_point = Point()
new_point.z_coord
1
0
class Point(object):
def __init__(self,x=0,y=0):
self.x_coord = x
self.y_coord = y
def translate(self,x=0,y=0):
self.x_coord += x
self.y_coord += y
def print_point(self):
print("({:d},{:d})".format(self.x_coord, self.y_coord))
my_point = Point()
my_point.print_point()
my_point.translate(-1,2)
my_point.print_point()
my_point.translate(1,-2)
my_point.print_point()
(0,0) (-1,2) (0,0)