Question: Question 1a: Distance Between Points (2 points) The distance d between points (To,yo) and (xi,y1) is defined as: Write a Python function distance (p, q)

 Question 1a: Distance Between Points (2 points) The distance d between

Question 1a: Distance Between Points (2 points) The distance d between points (To,yo) and (xi,y1) is defined as: Write a Python function distance (p, q) that takes two pairs of numbers, the coordinates of the points, and returns the distance between the points. # Use this code cell to run your tests def distance (p,q):# Write your answer in this cell # YOUR CODE HER raise NotImplementedError () distance ((1, 1), (1, 1))-0.0 distance( (5, 1), (1, 1)) - 4.0 distance ( (-1, -1), (7, 5))-10.0 Question 1b: Perimeter of a Polygon (2 points) The perimeter of a polygon is the sum of the length of all its sides. Write a Python function perimeter(p) that takes a possibly empty list p of pairs of numbers, the coordinates of the vertices, and returns the perimeter of the polygon. Use the function distance from above. You may assume that the list of vertices is given in the correct order. # Use this code cell to run your tests Write your answer in this cell # YOUR CODE HERE raise NotImplementedError () perimeter(0.0 perimeter ( [ ( 1, 1 ) ] ) 0.0 perimeter ( [ (1, 1), (4, 1)])-6.0 perimeter(, 1), (4, 1), (4, 5)])12.0

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!