Untitled

mail@pastecode.io avatar
unknown
plain_text
2 years ago
568 B
7
Indexable
Never
class point:
    """create a new point, at coordinate x,y cords # INSTANCE CREATION"""
    def __init__(self, x= 0, y= 0):
        self.x = x
        self.y = y
    
    def distance_from_origin(self):
        """ compute my distance from the origin #METHOD CREATION """
        return ((self.x **2) + (self.y **2)) ** 0.5
    def print(pt):
         print("({0}, {1})".format(pt.x, pt.y))
p= point(3,4)
#print(p.x)
#print(p.y)
#print(p.distance_from_origin())
print(print(p))

q = point(5,12)
#print(q.x)
#print (q.y)
#print (q.distance_from_origin())
print(print(q))