In a modify task you take code and adapt it so that it does something else. This time the starter code is not finished: the calculations and the outputs have been left blank, and filling them in is your job.
A running app needs to convert a total number of seconds into minutes and remaining seconds. 130 seconds, for example, is 2 minutes and 10 seconds.
The editor starts you off with this program:
print("Enter total seconds:")
total_seconds = int(input())
full_minutes =
remaining_seconds =
print("Minutes: " + str())
print("Seconds: " + str())
Run it as it is and Python stops with a SyntaxError, because an = with
nothing after it is not a complete line of code.
Complete the program so that it:
full_minutes,remaining_seconds,str().Choose your operators carefully. An ordinary / gives
130 / 60 = 2.1666666666666665, which is neither the number of whole minutes
nor the number of seconds left over. One of the two lines needs the operator
that counts whole times, and the other needs the operator that gives what is
left over.
Leave the question and the two print lines’ text exactly as they are.
The question, followed by two lines where MINUTES and SECONDS are the two
values you calculated:
Enter total seconds:
Minutes: MINUTES
Seconds: SECONDS
Input:
130
Output:
Enter total seconds:
Minutes: 2
Seconds: 10
Input:
3725
Output:
Enter total seconds:
Minutes: 62
Seconds: 5
The minutes are not turned into hours: 3725 seconds is 62 minutes, not 1 hour and 2 minutes.
Make sure that you check for the following things:
= signs.// counts how many whole times one number fits into another, and % gives
what is left over. Check that each line uses the right one.str() has a variable inside its brackets: str() on its own outputs
nothing.Minutes: and Seconds: are still exactly as
they were.