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
lara [203]
3 years ago
13

Write a program to take in a time-of-day on the command-line as 3 integers representing hours, minutes, and seconds, along with

a 4th argument of additional seconds. Recompute the time by adding the additional seconds to the time in the first three command-line arguments. Output: - display the original time given on the command-line - display the newly computed time Example: python computeTime.py 5 59 32 30 Initial time: 5:59:32 Computed time: 6:00:02 {6:0:2 would also be acceptable}
Computers and Technology
1 answer:
nexus9112 [7]3 years ago
6 0

Answer:

In Python:

hh = int(input("Hour: ")) * 3600

mm = int(input("Minutes: ")) * 60

ss = int(input("Seconds: "))

seconds = int(input("Additional Seconds: "))

time = hh+ mm + ss + seconds

hh =  int(time/3600)

time = time - hh * 3600

mm = int(time/60)

ss = time - mm * 60

while(hh>24):

   hh = hh - 24

print(str(hh)+" : "+str(mm)+" : "+str(ss))

Explanation:

We start by getting the time of the day. This is done using the next three lines

<em>hh = int(input("Hour: ")) * 3600</em>

<em>mm = int(input("Minutes: ")) * 60</em>

<em>ss = int(input("Seconds: ")) </em>

Then, we get the additional seconds

<em>seconds = int(input("Additional Seconds: "))</em>

The new time is then calculated (in seconds)

<em>time = hh+ mm + ss + seconds</em>

This line extracts the hours from the calculated time (in seconds)

hh =  int(time/3600)

time = time - hh * 3600

This line extracts the minutes from the calculated time (in seconds)

mm = int(time/60)

This line gets the remaining seconds

ss = time - mm * 60

The following iteration ensures that the hour is less than 24

while(hh>24):

   hh = hh - 24

This prints the calculated time

print(str(hh)+" : "+str(mm)+" : "+str(ss))

You might be interested in
FOR ALL PLATO USERS:
aleksley [76]

You have to ask you teacher to show you which ones you got wrong and the answers to them.

6 0
4 years ago
Read 2 more answers
When looking at a poster from the Art Deco movement, what one design characteristic would you most expect to see?
Lelechka [254]
The correct answer is D. Repeated geometric shapes.
8 0
3 years ago
Identifying Characters
alina1380 [7]
The answer is d I just took the test
5 0
3 years ago
Read 2 more answers
Addison or Charli
Blizzard [7]

Answer:

1. Mum

2.Bro my sisters are more annoying

3.cat

Explanation:

yuh

3 0
3 years ago
Read 2 more answers
What movie would be greatly improved if it was made into a musical?
Lina20 [59]
Sixteen candles would be even better if it was a musical
3 0
3 years ago
Other questions:
  • What is an example of asynchronous communication
    7·1 answer
  • What does ACCU stand for?
    13·2 answers
  • What is an administrator?
    8·1 answer
  • A _____ is a web site that allows users to edit and change its content easily and rapidly.
    9·1 answer
  • System inputs and outputs are produced at the end of the: A. systems analysis phase of the SDLC. B. systems planning and selecti
    12·1 answer
  • Match the metric units with these measurements
    8·1 answer
  • At the beginning of Section 5.2, it is stated that multiprogramming and multiprocessing present the same problems, with respect
    8·1 answer
  • Write a calculate_sq_inches_of_good_pizza function that accepts the diameter of a pizza and returns the area of the pizza minus
    7·1 answer
  • 4.1 code practice python
    13·1 answer
  • Give 5 characteristics of bad capacitor<br> give 5 characteristics of good capacitor
    10·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!