(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 s

1 answer
Question:

(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: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 secsmain() #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.

Similar Solved Questions

2 answers

Look at the image above. Which of the following choices belongs in box #2? a. settled by Spanish b. settled by land grantees c. established slave plantations d. protected by the presidio

Look at the image above. Which of the following choices belongs in box #2? a. settled by Spanish b. settled by land grantees c. established slave plantations d. protected by the presidio...
2 answers

Why do white people have to sit in front of the bus but us black people had to sit in the back like that's so rude.

why do white people have to sit in front of the bus but us black people had to sit in the back like that's so rude....
1 answer

How does one deal with inequalities again?

How does one deal with inequalities again?...
2 answers

One third of a number increased by 12 one thirdn + 12 n plus 12 over 3 one third(n + 12) n + one third(12)

one third of a number increased by 12 one thirdn + 12 n plus 12 over 3 one third(n + 12) n + one third(12)...
1 answer

Diversification may dissipate value if it is wrongly based on: a. transferring competencies. b. realizing economies of scope. c. rescuing core business. d. leveraging existing competencies. e. acquisitions and restructuring.

Diversification may dissipate value if it is wrongly based on: a. transferring competencies. b. realizing economies of scope. c. rescuing core business. d. leveraging existing competencies. e. acquisitions and restructuring....
1 answer

Wanda rode her bike 21/10 miles. Write a mixed number that shows how far Wanda rode her bike.

Wanda rode her bike 21/10 miles. Write a mixed number that shows how far Wanda rode her bike....
1 answer

A study of a new medical procedure selected 27 candidates from a pool of 583 potential candidates.Each of the candidates had an equal possibility of being chosen.Which sampling method was used ?

A study of a new medical procedure selected 27 candidates from a pool of 583 potential candidates.Each of the candidates had an equal possibility of being chosen.Which sampling method was used ?...
1 answer

What is another name for the triple entente

what is another name for the triple entente...
2 answers

Which numbers are rational? I. 2.2222222... II. 2.20220222... III.2.345

Which numbers are rational? I. 2.2222222... II. 2.20220222... III.2.345...
2 answers

Tell me about the culture of USA. ASAP IT'S URGENT! NO SPAM AND NO ROBOTS! GIVING BRAINLIEST! I NEED HOMEWORK HELP It can be an essay or a composition PLS ASAP

Tell me about the culture of USA. ASAP IT'S URGENT! NO SPAM AND NO ROBOTS! GIVING BRAINLIEST! I NEED HOMEWORK HELP It can be an essay or a composition PLS ASAP...
1 answer

___________________ is described as nature-oriented vacations , often taken in endangered areas, offered to travelers usually hailing from affluent cities or foreign nations.

___________________ is described as nature-oriented vacations , often taken in endangered areas, offered to travelers usually hailing from affluent cities or foreign nations....
1 answer

A prenatal vitamin and mineral supplement contains 4000 international units (IU) vitamin A in the form of beta-carotene. This amount is equivalent to how many retinol activity equivalents (RAEs)?

A prenatal vitamin and mineral supplement contains 4000 international units (IU) vitamin A in the form of beta-carotene. This amount is equivalent to how many retinol activity equivalents (RAEs)?...
2 answers

Carbohydrates, lipids, and proteins all contain carbon, hydrogen, and oxygen. Which one also contains nitrogen? A) carbohydrates. B) lipids. C) proteins. D) none of the above.

Carbohydrates, lipids, and proteins all contain carbon, hydrogen, and oxygen. Which one also contains nitrogen? A) carbohydrates. B) lipids. C) proteins. D) none of the above....
2 answers

Based on The Riddle of the Rosetta Stone, what is one way in which Thomas Young and Jean-François Champollion differed?

Based on The Riddle of the Rosetta Stone, what is one way in which Thomas Young and Jean-François Champollion differed?...
2 answers

In which country were the humanitarian goals of Clinton's Doctrine of Enlargement best represented? A.) Ireland B.) Kosovo C.) Rwanda D.) Somalia

In which country were the humanitarian goals of Clinton's Doctrine of Enlargement best represented? A.) Ireland B.) Kosovo C.) Rwanda D.) Somalia...
1 answer

At the movie theatre, child admission is $5.50 and adult admission is $8.60. On Wednesday, 131 tickets were sold for a total sales of $946.80 . How many adult tickets were sold that day?

At the movie theatre, child admission is $5.50 and adult admission is $8.60. On Wednesday, 131 tickets were sold for a total sales of $946.80 . How many adult tickets were sold that day?...
1 answer

What is the factor pair for the multiplication sentence below? 11 x 9 = 99 A. 9,99 B. 11.99 c. 11,9

What is the factor pair for the multiplication sentence below? 11 x 9 = 99 A. 9,99 B. 11.99 c. 11,9...
1 answer

The manager is responsible for training you about food safety in your job duties, which includes:

the manager is responsible for training you about food safety in your job duties, which includes:...
1 answer

Evaluate the expression 10 to the 2 power + (3 +5 to the power 2) -5

Evaluate the expression 10 to the 2 power + (3 +5 to the power 2) -5...

-- 0.016586--