Computer Networking: A Top-Down Approach (7th Edition)
Computer Networking: A Top-Down Approach (7th Edition)
7th Edition
ISBN: 9780133594140
Author: James Kurose, Keith Ross
Publisher: PEARSON
Bartleby Related Questions 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
expand button
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
Check Mark
Knowledge Booster
Background pattern image
Similar questions
Recommended textbooks for you
Text book image
Computer Networking: A Top-Down Approach (7th Edi...
Computer Engineering
ISBN:9780133594140
Author:James Kurose, Keith Ross
Publisher:PEARSON
Text book image
Computer Organization and Design MIPS Edition, Fi...
Computer Engineering
ISBN:9780124077263
Author:David A. Patterson, John L. Hennessy
Publisher:Elsevier Science
Text book image
Network+ Guide to Networks (MindTap Course List)
Computer Engineering
ISBN:9781337569330
Author:Jill West, Tamara Dean, Jean Andrews
Publisher:Cengage Learning
Text book image
Concepts of Database Management
Computer Engineering
ISBN:9781337093422
Author:Joy L. Starks, Philip J. Pratt, Mary Z. Last
Publisher:Cengage Learning
Text book image
Prelude to Programming
Computer Engineering
ISBN:9780133750423
Author:VENIT, Stewart
Publisher:Pearson Education
Text book image
Sc Business Data Communications and Networking, T...
Computer Engineering
ISBN:9781119368830
Author:FITZGERALD
Publisher:WILEY