1answer.
Ask question
Login Signup
Ask question
All categories
  • English
  • Mathematics
  • Social Studies
  • Business
  • History
  • Health
  • Geography
  • Biology
  • Physics
  • Chemistry
  • Computers and Technology
  • Arts
  • World Languages
  • Spanish
  • French
  • German
  • Advanced Placement (AP)
  • SAT
  • Medicine
  • Law
  • Engineering
velikii [3]
3 years ago
7

Complete the function ending_time that determines the final clock time after a task has been completed. The function takes three

arguments that provide the current time of day, as well as the total time in seconds that it will take to complete the task: hour: the current hour of the day (0 - 23) minute: the current minute of the day (0 - 59) second: the current second of the day (0 - 59) time_taken: the number of seconds it will take to complete the task (greater than 0) Assume all inputs are valid. time_taken can be arbitrarily large! As an example, consider the test case: 2, 59, 40, 22. This means that the current hour is 2, the current minute is 59, the current second is 40, and the time to complete the task is 22 seconds. So the first three function arguments represent the time 2:59:40 am.
Computers and Technology
1 answer:
Ivanshal [37]3 years ago
8 0

Answer:

  1. def ending_time(hour, minutes, seconds, work_time):
  2.    if((seconds + work_time) // 60 > 0):
  3.        minutes = minutes + (seconds + work_time) // 60
  4.        seconds = (seconds + work_time) % 60    
  5.        if(minutes // 60 > 0):
  6.            hour = hour + (minutes // 60)
  7.            minutes = minutes % 60
  8.    else:
  9.        seconds = seconds + work_time  
  10.    return str(hour) + ":" + str(minutes) + ":" + str(seconds)
  11. print(ending_time(2,30,59, 12000))

Explanation:

The solution code is written in Python 3.

Firstly create a function ending_time that takes the four required input parameters.

Next, create an if statement to check if the numerator of (seconds + work_times) divided by 60 is over zero. If so, increment the minute and reassign the remainder of the seconds to the variable (Line 2-4).

Next, create another if statement again to check if the numerator of (current minutes) divided by 60 is over zero, if so increment the hour and reassign the remainder of the minutes to the variable (Line 6-8)

Otherwise, just simply add the work_time to the current seconds

At last return the time output string (Line 12).

You might be interested in
Complete the following sentences using each of the words provided ONCE only. KEYBOARD DESKTOP STORE PRINTER COMPUTER MOUSE MONIT
WARRIOR [948]

Answer:

Explanation:

Monitor is an electronic device that retrieves, and processes shows you what is going on in the computer.

Desktop is the first image you see on your screen when the computer is is used for telling the computer what to do.

keyboard

is used for typing documents. Printer is used for putting documents on paper. CD Bay you can insert a CD or Compact Disc. is is box inside and shaped

8 0
1 year ago
"You are working on a Debian distribution of Linux. You need to install a package, but you do not want to manually install all t
Stella [2.4K]

Answer:

apt-get

Explanation:

apt-get can be used to manually install a package, without need to manually install all the dependencies for the package.

7 0
3 years ago
2.Consider the following algorithm and A is a 2-D array of size ???? × ????: int any_equal(int n, int A[][]) { int i, j, k, m; f
Elis [28]

Answer:

(a) What is the best case time complexity of the algorithm (assuming n > 1)?

Answer: O(1)

(b) What is the worst case time complexity of the algorithm?

Answer: O(n^4)

Explanation:

(a) In the best case, the if condition will be true, the program will only run once and return so complexity of the algorithm is O(1) .

(b) In the worst case, the program will run n^4 times so complexity of the algorithm is O(n^4).

5 0
3 years ago
Using selection sort, how many times longer will sorting a list of 40 elements take compared to a list of 5 elements
Hoochie [10]

It will take 8 times more time to sort a 40-element list compared to the time spent on a 5-element list.

We can arrive at this answer as follows:

  • We can see that if we divide a group of 40 elements into groups containing 5 elements, we will have 8 groups.
  • In this case, the time it would take to sort the list of one group of 5 elements would be repeated 8 times so that we could sort all the groups and their elements.

Another way to do this is to divide the number 40 by 5. We would have the number 8 as a result, which indicates that we would need 8 times more time to sort a list of 40 elements, compared to a list of 5 elements.

You can get more information about lists at this link:

brainly.com/question/4757050

5 0
2 years ago
Computing hardware, computers using vacuum tubes were called the first generation; transistors and diodes, the second; integrate
boyakko [2]
I think this is true but like think about the computer hardware and stuff
8 0
2 years ago
Other questions:
  • The ____ is a new feature in versions of microsoft office, starting with office 2007; it consists of tabs, which contain groups
    5·1 answer
  • In no less than two paragraphs, explain the risks and compliance requirements of moving data and services into the cloud.
    11·1 answer
  • .In Python, comments begin with the comment marker and continue ______.
    14·1 answer
  • If you copy a drawing from the Internet and use it in a report, you might be violating the artist's
    8·1 answer
  • Which of the following is an online library?
    8·2 answers
  • Discuss, in detail, the usefulness of graphics and images in program development. Explain the importance of the interface of a c
    7·1 answer
  • If a friend gave a used Wii disc to someone, and they put it in their Wii, could they play it? Nintendo Switch games can only be
    14·1 answer
  • Consider our authentication protocol 4.0, in which Alice authenticates herself to Bob, which we saw works well (i.e., we found n
    15·1 answer
  • ANSWER QUICKLY!!!
    5·1 answer
  • Resource _____ let you view, manage, and automate tasks on multiple aws resources at a time.
    9·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!