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]
3 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]3 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
___ a Word object in an Excel worksheet to activate the Word features. A. Ctrl-click. B. Shift-click C. Double-click D. Click
givi [52]
D.....................
8 0
3 years ago
Read 2 more answers
My window key dont work and I dont have a fn button, what can I do?<br> PLS help me.
Black_prince [1.1K]

Answer:

click on window button thought mouse or press esc and ctrl key at same time to open start menu option or to type window+r to open run dialog box

4 0
4 years ago
When computing effect size, the sample size is ________.
NNADVOKAT [17]
Sample size  is not taken into account

8 0
3 years ago
What is known as networking in the IT field?
Sidana [21]

Answer:

r u Kate tell me plz I love u baby tell me please

4 0
3 years ago
Given an array of integers check if it is possible to partition the array into some number of subsequences of length k each, suc
allochka39001 [22]

Answer:

Explanation:

Using Python as our programming language

code:

def partitionArray(A,k):

flag=0

if not A and k == 1:

return "Yes"

if k > len(A) or len(A)%len(A):

return "No"

flag+=1

cnt = {i:A.count(i) for i in A}

if len(A)//k < max(cnt.values()):

return "No"

flag+=1

if(flag==0):

return "Yes"

k=int(input("k= "))

n=int(input("n= "))

print("A= ")

A=list(map(int,input().split()))[:n]

print(partitionArray(A,k))

Code Screenshot:-

3 0
3 years ago
Other questions:
  • A(n) ____ is a system designed to handle only very basic applications with an absolute minimum amount of hardware required by th
    9·1 answer
  • Tiny charts embedded in cells that show a visual trend alongside the data are called __________.
    10·1 answer
  • When you buy an Xbox 360 can you play online for free
    12·2 answers
  • What is the system of phonographic disc recordings paired with a projector called?
    9·1 answer
  • This chapter uses the class rectangleType to illustate how to overload the operators +, *, ==, !=, &gt;&gt;, and &lt;&lt;. In th
    15·1 answer
  • Which of the following is not a protocal? <br><br>A) HTTP<br>B) FTP<br>C) WWW<br>D) HTTPS​
    15·2 answers
  • Why does everyone refer to dogs as being loyal
    11·2 answers
  • Select the correct answer.
    8·1 answer
  • The students of a college have to create their assignment reports using a word processing program. Some of the questions in thei
    9·1 answer
  • A)​What would be the state of the following list after each of the first four passes in a Bubble sort, sorting into ascending se
    5·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!