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.

Computer Networking: A Top-Down Approach (7th Edition)
7th Edition
ISBN:9780133594140
Author:James Kurose, Keith Ross
Publisher:James Kurose, Keith Ross
Chapter1: Computer Networks And The Internet
Section: Chapter Questions
Problem R1RQ: What is the difference between a host and an end system? List several different types of end...
icon
Related questions
Question

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.

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
Transcribed Image 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
Expert Solution
steps

Step by step

Solved in 2 steps

Blurred answer
Recommended textbooks for you
Computer Networking: A Top-Down Approach (7th Edi…
Computer Networking: A Top-Down Approach (7th Edi…
Computer Engineering
ISBN:
9780133594140
Author:
James Kurose, Keith Ross
Publisher:
PEARSON
Computer Organization and Design MIPS Edition, Fi…
Computer Organization and Design MIPS Edition, Fi…
Computer Engineering
ISBN:
9780124077263
Author:
David A. Patterson, John L. Hennessy
Publisher:
Elsevier Science
Network+ Guide to Networks (MindTap Course List)
Network+ Guide to Networks (MindTap Course List)
Computer Engineering
ISBN:
9781337569330
Author:
Jill West, Tamara Dean, Jean Andrews
Publisher:
Cengage Learning
Concepts of Database Management
Concepts of Database Management
Computer Engineering
ISBN:
9781337093422
Author:
Joy L. Starks, Philip J. Pratt, Mary Z. Last
Publisher:
Cengage Learning
Prelude to Programming
Prelude to Programming
Computer Engineering
ISBN:
9780133750423
Author:
VENIT, Stewart
Publisher:
Pearson Education
Sc Business Data Communications and Networking, T…
Sc Business Data Communications and Networking, T…
Computer Engineering
ISBN:
9781119368830
Author:
FITZGERALD
Publisher:
WILEY