Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

PYTHON PROBLEM Current function: def distance_from (coord : (int,int), ps : {int:(int,int)}) -> [int]: pass 4. (4 pts) Define the distance from function, which has

PYTHON PROBLEMimage text in transcribed

Current function:

def distance_from (coord : (int,int), ps : {int:(int,int)}) -> [int]: pass

4. (4 pts) Define the distance from function, which has two arguments (a) an x,y coordinate in the form of a 2- tuple (x,y) where both are int and (b) a dictionary in the form [int: (int,int)) showing the ordinal of a point (1* point, 2d point. 3d point, etc.) as a key, and it associated value: an x.y coordinate in the form of 2 tuple (x,y). For example, ps1:(1,,2: (3,2),3: (3,-3),4: (-3,-4),5: (-2,-2),6:(3,3),7:(1,-1)) means that the 1st point is at coordinate (1,1); the 2 point is at coordinate (3,2); the 3d point is at coordinate (3, -3); etc. Examine the picture below (on the next page), showing the axes and these seven points. The distance from function. returns a list of ints (just the ordinals, not the points), sorted ascending by the distance each point is from the origin (points with equal distances should be sorted ascending by ordinal): for the ps dictionary above (and picture below) the result of calling distance from ( (0,0),ps) is [1,7,5,2,3,6,4].Notice that ordinals 1 and 7 are both the same distance from (0,0), so 1 comes before 7; same for ordinals 3 and 6.Your function body must contain exactly one statement: just a return statement; also, create no other extra/temporary lists other than the ones returned by calling sorted. 6: (3,3)

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Beginning VB 2008 Databases

Authors: Vidya Vrat Agarwal, James Huddleston

1st Edition

1590599470, 978-1590599471

More Books

Students also viewed these Databases questions

Question

What are Decision Trees?

Answered: 1 week ago

Question

What is meant by the Term Glass Ceiling?

Answered: 1 week ago