(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
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.
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...
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....
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 ?...
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...
___________________ is described as nature-oriented vacations , often taken in endangered areas, offered to travelers usually hailing from affluent cities or foreign nations....
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)?...
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....
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?...
WILL UPVOTE!
Question 5 (Multiple Choice)
To warm up before a run, Lucas walks for five minutes. Which of these accurately evaluates his choice of warm-up activity?
A) This activity is appropriate because it prepares muscles for more intense movement.
B) This activity is not appropriate because the ...