IN PYTHON PLEASE Part II: Tracking Packages (20 points) Complete the function pa
ID: 3704664 • Letter: I
Question
IN PYTHON PLEASE
Part II: Tracking Packages (20 points) Complete the function package-tracking ), which takes three arguments, in this order: 1. packages.info: a list of tuples containing two values: the name of the city that a package was sent from and the name of the city that the package was sent to CSE 101 - Spring 2018 Lab #10 Page 2 2. locations: a dictionary that maps a city's name to its 2D coordinate position, stored as a tuple 3. cost.schedule: a list of 4 integers that represent how much it costs to ship a package various distances: Meaning Value cost.schedule [0] the cost to ship a packageExplanation / Answer
SOLUTION:
The below data shows with respect to the given information;
def package_tracking(packages_info,locations,cost_schedule):
packages=[]
for i in packages_info:
sender=locations[i[0]]
receiver=locations[i[1]]
distance=((receiver[0]-sender[0])**2+(receiver[1]-sender[1])**2)**.5
if distance>=500:
cost=cost_schedule[3]
elif distance >=300:
cost=cost_schedule[2]
elif distance>=100:
cost=cost_schedule[1]
else:
cost=cost_schedule[0]
packages.append(Package(sender,receiver,cost,distance))
return packages