Question: python 1. In this lab to calculate the Euclidean Distance between two points you need to define a class that takes two points and then

python
1. In this lab to calculate the Euclidean Distance between two points you need to define a class that takes two points and then calculate the distance between them. a. The shortest distance between two points in any dimension is termed the Euclidean distance. It is the square root of the sum of squares of the difference between two points. ) OP P. (*) Euclidean distance (d) = V(x,x) + (2x) b. Use the code below to understand how it should be implemented. class Coordinate: "A coordinate made up of an x and y value definits (self, x, y): Sets the x and y values self x = x selfx=y def distance(self, other): " Returns the euclidear, distance between two points x diff. sq. = (self,x-other x)**2 x.diff_sq=(selfy-other.y)**2 retum (x.diff. sq.+x_diff sq)**0.5 c = Coordinate(3.4) origin = Coordinate(0,0) print(c.x, origin x) print(c-x. origin) print(c.distance(origin)) print(Coordinate distancec, origin)) print(origin.distancec) c. Modify the class method distance to use the sqrto) built-in function instead. d. Take a screenshot of your code and the output and submit it. e. What is the difference between the last three lines in the code? How many objects do we have? print(c.distance(origin)) print(Coordinate distancec, origin) print(origin distance(c))
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
