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
asambeis [7]
2 years ago
12

(Convert milliseconds to hours, minutes, and seconds) Write a function that converts milliseconds to hours, minutes, and seconds

using the following header: def convertMillis(millis): The function returns a string as hours:minutes:seconds. For example, convertMillis(5500) returns the string 0:0:5, convertMillis(100000) returns the string 0:1:40, and convertMillis(555550000) returns the string 154:19:10. Write a test program that prompts the user to enter a value for milliseconds and displays a string in the format of hours:minutes:seconds. Sample Run Enter time in milliseconds: 555550000 154:19:10

Computers and Technology
1 answer:
ivanzaharov [21]2 years ago
4 0

Answer:

I am writing the Python program. Let me know if you want the program in some other programming language.

def convertMillis(millis):  #function to convert milliseconds to hrs,mins,secs

   remaining = millis  # stores the value of millis to convert

   hrs = 3600000  # milliseconds in hour

   mins = 60000  # milliseconds in a minute

   secs = 1000  #milliseconds in a second

   hours =remaining / hrs  #value of millis input by user divided by 360000

   remaining %= hrs  #mod of remaining by 3600000

   minutes = remaining / mins  # the value of remaining divided by 60000

   remaining %= mins  #mod of remaining by 60000

   seconds = remaining / secs  

#the value left in remaining variable is divided by 1000

   remaining %= secs  #mod of remaining by 1000

   print ("%d:%d:%d" % (hours, minutes, seconds))

#displays hours mins and seconds with colons in between

   

def main():  #main function to get input from user and call convertMillis() to #convert the input to hours minutes and seconds

   millis=input("Enter time in milliseconds ")  #prompts user to enter time

   millis = int(millis)  #converts user input value to integer

   convertMillis(millis)   #calls function to convert input to hrs mins secs

main() #calls main() function

Explanation:

The program is well explained in the comments mentioned with each line of code. The program has two functions convertMillis(millis) which converts an input value in milliseconds to hours, minutes and seconds using the formula given in the program, and main() function that takes input value from user and calls convertMillis(millis) for the conversion of that input. The program along with its output is attached in screenshot.

You might be interested in
Which option allows to change date and time​
tester [92]
The Windows key has the Windows logo on it. Right-click the Date/Time display on the taskbar and then choose Adjust Date/Time from the shortcut menu. The Date and Time dialog box appears. Click the Change Date and Time button.
4 0
3 years ago
Read 2 more answers
The Internet has been around for quite a while, but it did not have much impact on our everyday lives until the appearance of th
pishuonlain [190]

Answer:

The answer is "WWW".

Explanation:

WWW stands for World Wide Web, It is a combination of all Internet resources and users, that uses the hypertext transfer protocol. It provides world information that is available on the internet that is the expression of human knowledge. It is also known as a domain name that introduces resources or individual instances of the entire collection.

6 0
3 years ago
The application that Scott is writing has a flaw that occurs when two operations are attempted at the same time, resulting in un
Luden [163]

The type of flaw that the application is said to  have is known to be called race condition.

<h3>What is meant by race condition?</h3>

A race condition is known to be a form of unwanted situation that takes place when a device or system tries to carry out two or more operations at the same given time, but due to the nature of the device or system, the operations had to b be done in the right sequence to be carried out correctly.

Therefore, The type of flaw that the application is said to  have is known to be called race condition.

Learn more about race condition from

brainly.com/question/13445523

#SPJ1

3 0
2 years ago
Read 2 more answers
What color typically indicates the speaker port on a sound card?
allsm [11]
The answer to this question would be: Lime green

The lime green color code is for audio output for speaker or headphones. Color coding is greatly helpful to make sure that the port you are using is correct. Using the color you can determine what kind of input or output the port is for. There is a few others color coding like pink for analog microphone input, or light blue for audio input of analog line.
4 0
3 years ago
Read 2 more answers
"HotelExp” is a 3-D range name applied to the workbook shown.
Ganezh [65]

Answer:

all cells in the B column of any worksheet in this workbook

Explanation:

It seems each worksheet covers total expenses for each month, and hence workbook must have 12 such with one month for each worksheet. Also, the 3D range is a special option in Excel to reference all cells or a selected group of cells for all the worksheets. However, it should be all B cells as B2: B4 apart from this, others in B column also has expenses. And hence, the above option is the correct one.

3 0
2 years ago
Other questions:
  • Janelle is organizing an outline for an investigative report about the benefits of taking a 30-minute walk each day. which of th
    11·2 answers
  • A ____ can interpret physical addressing information.
    11·1 answer
  • Which of the following statements is true?
    12·1 answer
  • What is renewable energy
    12·1 answer
  • Drag each storage device to its category.
    7·1 answer
  • How to upgrade from office home to office professional
    13·1 answer
  • You are configuring a switch that has three hosts attached to FastEthernet 0/2 through 0/4. All three hosts are part of a public
    10·1 answer
  • The set of rules for how computers talk to one another is called
    12·1 answer
  • Question 2
    7·1 answer
  • assuming the default gateway is connected to the internet, what type of internet access would this server have?
    14·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!