#Chap9 Q1- Alternative import math class Line(): def __init__(self, coordinate1, coordinate2): self.x1 = coordinate1[0] self.y1 = coordinate1[1] self.x2 = coordinate2[0] self.y2 = coordinate2[1] def length(self): d = math.sqrt((self.x2 - self.x1)**2 + (self.y2 - self.y1)**2) return d def slope(self): m = (self.y2 - self.y1)/(self.x2 - self.x1) return m co1 = (3,2) co2 = (8,10) li = Line(co1, co2) lineLength = li.length() lineSlope = li.slope() print(f'The length is {lineLength}') print(f'The slope is {lineSlope}')