Question: Hello! I cannot import anything from library (such as itertools). And I have to open a .txt file and read the input lines from the

 Hello! I cannot import anything from library (such as itertools). And

Hello! I cannot import anything from library (such as itertools). And I have to open a .txt file and read the input lines from the .txt

This code is in PYTHON 3

Thank you! ^_^

Here are the input lines:

3 20 2 30 6 10 7 2 60 1 30 5 4 15 1 25 2 30 3 10 5 -1

Bill and Ted are taking a road trip But the odometer in their car is brokeu, so they don't know bow mauy miles they have div Fortunately, Bill has a working stopwatch, so they can record their speed and the total time they bave driven. Unfortunately, their record kecping stratcgy is a littlie odd, so they need help computing the total distance driven. You are to write a program to do this computation. For example, if their log shows Speed in miles per hour Total elapsed time in hours 20 30 this me n thev drove 2 hours at 20 miles per hour, hen 6-2 4 hours at 30 miles per hour. hen 7-6 elapsed time is always since the beginning of the trip, not since the previous entry in 1 hour 10 miles per hour. The distance driven LS hen (2)(20) (4H30) +1)(10) 40 120 10 170 miles. Note that he c Input: The Lupul cu l i ls ufone or more dala scl ach sei star s it a te cou aLuing au n cge! " ,, 10 ollowed bv n paus o.f values onc par per LLuc. he irs va uc , 1s I e specu Lu uules per hour and I c second value is the total cla sed time. Both and t are integer s 90 and I 2. The values forz are always in strictlv nereasng order. A value of l or n signals the end of the input. Output: For cach input set, print the distanceven, fllowed by a spac, fllowed by the word "miles". Example input Example output: 170 niles e nilas 9 niles 23 2 68 1 30 5 15 1 25 2 3 1a 5

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!