Question: Python Coms 104 Section 1- Fall 2017 Question 4 Part 1: In Geometry, the equation of a straight line is given by Page 5 of
Python Coms 104 Section 1- Fall 2017 Question 4 Part 1: In Geometry, the equation of a straight line is given by Page 5 of 6 y mx + b ; where, m= slope or gradient The siope of a line passes through the two points (x1,V1) and (x2.2) can be calculated as, Slope = y-y, Complete the following function called find sope which takes the (xy) coordinates of two points .e. 4 integer values) as input parameters (xl,y1,x2, y2). caiculate the slope point value) that passes through those two points and return Points-10] Note: . Slope must be calcula Assumption: x-coordlinates of the two points are never equa ted as floating-point value, (Hint: Use floating point division) ates of the two points are never equal. That is, the line is NOT paraNel to y axis. (Therefore, the divide by zero error will never occur,) : Assumption: ython preaisely calculates the fractions instead of giving rounded values. (For example, 10 is not rounded to some fixed decimal places.) # Function to calculate and return the slope of a line that passes through # (x1,y1) and (x2,y2) def find slope (xi,yl,x2,y2) Slope = (87-y')/(X2-X.) Part 2: You can do this part whether or not you did Part 1. Suppose there are two lines L1. L2 with slopes mi, m2 respectively. Then, If m1 equels m2 , then L1 and L2 are Parallel. Otherwise, if the product of m1 and m2 (that is, m1 * m2 ) equals to-1, then L1 and 12 are Perpendicular . Otherwise, L1 and L2 are neither Parallel nor Perpendicular. Assume that the function find slope from the Part 1 is correctly implemented and located in a module called myLineFunctions.py find slope (x1,y1,x2,y2):Return slope of the line that passes through the two points (x1,yl) and (x2,y2) Complete the Python script (that is, the user interface) given in the next page, which takes coordinates of four points (say. S1. ElS2, E2) and display whether the two lines passes through S1, E1 and S2, E2 are either Parallel or Perpendicular or Neither
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
