(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

Answers

Answer 1

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.

(Convert Milliseconds To Hours, Minutes, And Seconds) Write A Function That Converts Milliseconds To

Related Questions

If i wanted to change my phones simcard, does anything need transferring, or is it an easy swap?

Answers

Most likely not but I think you’ll have to log in your account like if you have an Apple phone . You’ll have to log into your Apple ID

What feature in the Windows file system allows users to see only files and folders in a File Explorer window or in a list of files from the dir command to which they have been given at least read permission?

Answers

Answer:

Access based enumeration

Explanation:

The access based enumeration is the feature which helps the file system to allow users for seeing the files and folders for which they have read access from the direct command.

Access based enumeration: This feature displays or shows only the folders and files that a user has permissions for.

If a user do not have permissions (Read) for a folder,Windows will then hide the folder from the user's view.

This feature only function when viewing files and folders are in a shared folder. it is not active  when viewing folders and files in a local system.

Other Questions
Reading a stream of consciousness narrative is like The homes of the Indians were copied by the English, being ready adaptations of natural and plentiful resources. Wigwams in the South were of plaited rush or grass mats; of deerskins pinned on a frame; of tree boughs rudely piled into a cover, and in the far South, of layers of palmetto leaves. In the mild climate of the Middle and Southern states a 'half-faced camp,' of the Indian form, with one open side, which served for windows and door, and where the fire was built, made a good temporary home. In such for a time, in his youth, lived Abraham Lincoln. Bark wigwams were the most easily made of all; they could be quickly pinned together on a light frame. In 1626 there were thirty home-buildings of Europeans on the island of Manhattan, now New York, and all but one of them were of bark."Alice Morse Earle, Home Life in Colonial Days, 1898 Americans Indians had significant, immediate influence on the colonists and their communities on the Atlantic Seaboard because (1 point) permanent villages aided the colonists in forming political alliances and allocating resources found in the Americas the colonists arrived with a need to build shelters but didn't understand the materials or tools available the weather conditions on the Atlantic Seaboard were foreign to the colonists, and they sought help from the native peoples they were familiar with the farming techniques that the colonists needed to establish their permanent communities Which describes a climate effect on the rate of weathering? Cold climates favor mechanical weathering. Chemical reactions occur slower at higher temperatures. Lower precipitation levels lead to more chemical reactions. The chemical reaction rates of minerals are not impacted by temperature. please help.. GP is geometric progression I NEED HELP PLEASE, THANKS! Describe each Newton Law. :) 5.The total length of 2 pieces of rope is108cm. If one piece is 18cm shorter, what isthe length of the longer piece? What are the coordinates of the image of R for a dilation with center (0,0) and scale factor 3? Why did the agricultural revolution begin? What are the like terms in the algebraic expression? Negative a squared b + 6 a b minus 8 + 5 a squared b minus 6 a minus b Negative a squared b and negative 6 a Negative a squared b and 5 a squared b 6 a b and 5 a squared b 6 a b and negative 6 a PLEEEEEEEEEEEASE HELP The function f(n) represents an arithmetic sequence where the first term is 5 and each term increases by 5. What is f(8)? Record adjusting journal entries 100 of the following for year ended December 31Assume no other adjusting entries are made during the yearSalaries Payable.: At year-end, salaries expense of $24,000 has been incurred by the company, but is not yet paid to employees. Interest Payable: At its December 31 year-end, the company owes $675 of interest on a line-of-credit loan. That interest will not be paid until sometime in January of the next year. Interest Payable: At its December 31 year-end, the company holds a mortgage payable that has incurred $1,300 in annual interest that is neither recorded nor paid. The company intends to pay the interest on January 7 of the next year. Health insurance can be a complicated matter. In your opinion, do you think it would be better to have a lower premium (the amount you pay every month) and a higher deductible (the amount of money you pay up front for medical services), OR a slightly higher monthly premium and a lower deductible? Why? help me asap plz and thx u Let f be the function that determines the area of a circle (in square cm) that has a radius of r cm. That is, f ( r ) represents the area of a circle (in square cm) that has a radius of r cm.Use function notation to complete the following tasks a. Represent the area (in square cm) of a circle whose radius is 4 cm. b. Represent how much the area (in square cm) of a circle increases by when its radius increases from 10.9 to 10.91 cm. Prepare summary journal entries to record the following transactions for a company in its first month of operations. 1. Raw materials purchased on account, $86,000. 2. Direct materials used in production, $38,500. Indirect materials used in production, $23,000. 3. Paid cash for factory payroll, $50,000. Of this total, $38,000 is for direct labor and $12,000 is for indirect labor. 4. Paid cash for other actual overhead costs, $7,375. 5. Applied overhead at the rate of 125% of direct labor cost. 6. Transferred cost of jobs completed to finished goods, $62,600. 7. Sold jobs on account for $90,000 g(2). The jobs had a cost of $62,600 g(1). How do Newton's laws of motion explain why it is important to keep the ice smooth on a hockey rink so that players canpass a puck as quickly as possible?OSmooth ice reduces the inertia of the hockey puck.Smooth ice increases the force used to accelerate the hockey puck.Smooth ice reduces the unbalanced forces that would slow the hockey puck.Smooth ice decreases the reaction force that the ice exerts on the hockey puck.Save and Fxit Math help asap! [Function Inverses] If ABC and CBD are supplementary angles, then mABC + mCBD = 180 represents the definition of Question 2 options: A) complementary angles. B) supplementary angles. C) triangle sum. D) congruence. Which major architectural influence is illustrated by the photo above? The use of Corinthian columns and semicircular arches demonstrates the influence of classical architecture. The inclusion of glass windows points towards access to sophisticated glass manufacturing from the Arab world. The presence of geometric patterns represents a uniquely northern European addition to the structure. The use of decorative tile along the covered walkway is a common technique borrowed from Byzantine architecture. 4. The dimensions of a triangular pyramid are shown below. The height ofthe pyramid is 6 inches. What is the volume in cubic inches? Fill in the missing numbers for the following income statement. (Do not round intermediate calculations.) Sales $668,600Cost 431,300Depreciation 103,700 EBIT Taxes (24%) Net Income a. Calculate the OCF. (Do not round intermediate calculations.) b. What is the depreciation tax shield?