oriented

Object-Oriented Programming

import numpy as np
class Coordinate(object):  #class tells python you are making an object. #class name/type(parent object)
    def __init__(self, x, y):  #defines attributes that let us interact with the object
        self.x = x  #these attributes only work with its class
        self.y = y

    def distance(self, dist):  #defines attributes that let us interact with the object
        dist = numpy.linalg.norm(x-y)
        x_diff_sq = (self.x-other.x)**2 #these attributes only work with its class
        y_diff_sq = (self.y-other.y)**2
        return(x_diff_sq + y_diff_sq)**0.5
#self is a parameter that references the instance of this class |  
#methods like __init__ are like a function that only work with this class
c = Coordinate(3,4)
zero = Coordinate (0,0)
print(c.distance(zero))