Given two points in the plane (?,?) and (?,?), the slope of the line through them is the number ? given by
?=?−? ?−?
i.e. the difference in the y-coordinates divided by the difference in the x-coordinates, or rise/run. Recall the Point class defined in the series of examples found here. Below is a stripped down version of this class, with only the initializer (given), and two new class functions called slope(?,?) and colinear(?, ?, ?). The first returns the slope of the line through the points ? and ?. The second returns True if and only if the three points ?, ? and ? lie on a line.
Extracted text: Given two points in the plane (a, b) and (c, d), the slope of the line through them is the number m given by b – d m = а — с i.e. the difference in the y-coordinates divided by the difference in the x-coordinates, or rise/run. Recall the Point class defined in the series of examples found here. Below is a stripped down version of this class, with only the initializer (given), and two new class functions called slope(P, Q) and colinear(P, Q, R). The first returns the slope of the line through the points P and Q. The second returns True if and only if the three points P, Q and R lie on a line. Three such points are said to be colinear. A well known theorem in plane geometry states that P, Q and R are colinear if and only if the slope determined by P and Q equals the slope determined by Q and R. Complete the definitions of slope() and colinear() below. (Note that these are class functions so they have no self parameter, and are called as Point.slope() and Point.colinear(), respectively.) class Point: """Class representing a point in the x-y plane.""" def init (self, x, y): """Initialize a Point object.""" self.xcoord = x self.ycoord y #end init () def slope (P, Q): """Return the slope of the line through P and Q.""" # end slope () def colinear(P, Q, R): """Return true if and only if Points P, Q and R lie on a line.""" # end colinear # end Point class