Question: weite a python code In Prac 2 you wrote a program to calculate and display i-stop time/percentage. In that program, you displayed seconds as minutes

weite a python code
weite a python code In Prac 2 you wrote a program to
calculate and display "i-stop" time/percentage. In that program, you displayed seconds as

In Prac 2 you wrote a program to calculate and display "i-stop" time/percentage. In that program, you displayed seconds as minutes and seconds, example: 1-stop on in seconds: 62 Time stopped in seconds: 161 1-stop ON: Time Stopped: Percentage: im 2s 2m 41s 38.50931677018634 Note: the original program from prac 2 was about i-stop values for a car, but this has nothing to do with that context. The technique for figuring out minutes and seconds from just seconds is the same, so you can copy your work, but do change any references to the old context. Write a simple program using a function that takes in a number of seconds and returns a string that can be used to display that value in minutes and seconds. Notice that the function DOES NOT PRINT. We want to use the string in different ways, so this function's job is simply to create/return a formatted string. Write a main program that displays a bunch of different seconds values in minutes and seconds using a loop. Example output: Note: Think about how this was generated... There's no user input; it starts at 0, goes to ? in steps of ? Try and do the same in your program. @ seconds is Om os 635 seconds is 10m 355 1270 seconds 15 21m 105 1985 seconds is 31m 45s 2540 seconds is 42m 205 3175 seconds is 52m 555 2540 seconds is 42m 205 3175 seconds is 52m 55s To help you understand SRP even more, let's think about what this function should return. Should it return something like? 635 seconds is 10m 35s Well, what if we wanted to use the same function for different kinds of tasks? Let's do that now... Add another small part to this same program - after the loop - that asks the user for their favourite duration in seconds, then prints it in minutes and seconds, like Favourite duration in seconds: 639 You love 10m 39s So... If our function returned something like 635 seconds is 18m 35s, then we could NOT use it for this task, even though it's really similar Do we need a second function that returns something like you love ... ? NO! That would be repeating ourselves, and we know.. DRY. So... we need to remember SRP. This function has one job, and it's not printing or returning a whole n seconds is ..., it's ONLY the bit that formats the seconds (argument) in minutes and seconds... which we can now reuse in different situations! SRP leads to function reusability and helping us not repeat ourselves :)

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!