Answer to Question #273228 in Python for Shiny

Question #273228

1. Time measurement using song duration






Consider that Alice is cycling from point A to point B. During the cycling, Alice is listening to songs in her music player.






Given the following inputs:






1. The distance between A and B in metres






2. The speed at which Alice is traveling in metres per second






3. Duration of each song in her playlist in the






following format: mm:ss






the program should:






• Print the number of the song that Alice is listening when the cycling is completed from A to B






· Print Invalid input if any of the constraints mentioned in the constraints section is violated






Example 1






Consider the following inputs:






2000






5






Now consider the following list of songs:






05:30






02:04

1
Expert's answer
2021-11-29T10:31:23-0500
dis = int(input())
speed = int(input())
time = dis / speed
cnt = 0
bar = 0
l = list(map(str, input().split()))
ll = []
for i in l:
    foo = int(i[:2])*60+int(i[3:])
    ll.append(foo)
for i in ll:
    cnt += i
    bar +=1
    if cnt >= time:
        print(bar)
        break

Need a fast expert's response?

Submit order

and get a quick answer at the best price

for any assignment or question with DETAILED EXPLANATIONS!

Comments

No comments. Be the first!

Leave a comment

LATEST TUTORIALS
New on Blog
APPROVED BY CLIENTS