Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

ps Del SENG 265 A01/A02 Page 10 Question 22 Weight s0 A text file containe a seq

ID: 3706526 • Letter: P

Question

ps Del SENG 265 A01/A02 Page 10 Question 22 Weight s0 A text file containe a sequence ofx & y coordinates. These represent the endpoints of line regnents (ie, in example 1, the first Iine segment is from (0,0) to [o,S), the nest segment is frons (0, s] to [5, s), etc). Example ile I 8 5 Example file 2 3 5 18 3 2 1 Every sach file contains information for at least one line segment. You may not assume a maximum number of such line segments. a) Wite a Python function conputeDist coordl coord2 to compute and return the straight-ine distance between a pair of coordinates [xl,yll, 2,y2]: The exponentiation operator in Python denoted byYou can obtain the square root of a number by taking it to the power of 0.5. (Some marks will be given for the quality of your answer.)

Explanation / Answer

def compute_dist(coord1, coord2): x1, y1 = coord1 x2, y2 = coord2 return (((y1-y2)**2) + ((x1-x2)**2))**0.5