Question: Python.. 2. Create a class called Line which is meant to represent a line on the plane. You should use the Point class that we
Python..
2. Create a class called Line which is meant to represent a line on the plane. You should use the Point class that we developed. The Point class should be used in the Line class. The class Line has the following methods. (a) The initializer takes two tuples (each of length 2) as inputs which represent the 2 points that define the line (for example, we might create a Line by writing L = Line((3,4),(5,8)) ). (b) Write a method slope which takes no inputs and returns the slope of the line. For example, on the line above, L.slope() should return 2. Return the string undefined if the slope is undefined. (c) Write a method onLine which takes one tuple (of length 2) as input, which is meant to represent a point. It returns a boolean: True if the given point is on the line, and False if it is not. (d) Override the <= so that in comparing 2 lines, it returns a boolean: True if the second line has a slope that is at least as large as the first, and False otherwise. (e) Override the + so that you can add a Line object and a Point object (i.e. the Line first and the Point second). The result should be a Line object which is shifted according to the point, i.e. if the point has coordinates (x, y), then every point on the line is shifted x steps in the horizontal direction and y steps in the vertical direction. 1
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
