Question
Add code to the following script so that it uses the built-in zip function to find and print the average speed in miles/hr for five
Add code to the following script so that it uses the built-in zip function to find and print the average speed in miles/hr for five errands based on distance and time data collected by a GPS unit. The distance for each trip is given in miles in distanceList and the corresponding times are given in minutes and seconds in the same order in timeList. The time format separates minutes from seconds with a colon. Use string methods and built-in functions inside the zip loop to extract the numeric temporal values.
Script:
distanceList = [0.04, 0.05, 0.91, 0.16, 18] timeList = ['7m:13s', '11m:29s', '16m:48s', '3m:26s', '120m:0s']
###Hint 1: Inside the 'zip' loop, use several steps to extract the minutes and seconds ### and then convert to hours. ###Hint 2: To print a float with 2 or less decimal places, put ':.2f' inside the format place holder. ### Example, ### >>> speed = 5.1666666666667 ### >>> print 'Speed: {0:.2f} miles/hr'.format(speed) ### Speed: 5.17 miles/hr
The output should look like this:
>>>Distance: 0.04 Time: 7m:13s Speed: 0.33 miles/hr
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