Answered step by step
Verified Expert Solution
Question
1 Approved Answer
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 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
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started