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
Which spreadsheet toolbar displays options such as Cut and Paste?
Lilit [14]
The answer would be ''Drawing Toolbar'' and you can find this inside your mouse area, where u click the right button (right side) and it shows a small chart/toolbar where it gives you the options to copy, cut, paste and more.
6 0
3 years ago
Read 2 more answers
question 2 what are some types of software that you'd want to have an explicit application policy for? check all that apply.
zaharov [31]

The types of software that you'd want to have an explicit application policy are:

  • Filesharing software
  • video games

  • Explicit application policy are simply refered to as legal rights that are stated regarding ownership or company. It is actual substance of an agreement

  • Video games and filesharing software is of not really important in som business. So therefore, having explicit policies showing why or not this type of software is permitted on systems is okay.

Conclusively, we can say that Filesharing software and video games can require an explicit application policy.

Learn more from

brainly.com/question/12730075

4 0
3 years ago
To apply a style to one or more elements on a web page, configure a css ________.
saul85 [17]
External style sheet

element {
background-color: #ffffff

}
5 0
3 years ago
What does HTML stand for?
Wittaler [7]

Hypertext Markup Language

5 0
3 years ago
Read 2 more answers
A = 250; B = 325. which of the following statements is true? A ==B A>B A =B
Ivanshal [37]

Answer:

lollol

Explanation:

7 0
3 years ago
Other questions:
  • ​_____ describes the process of using computer software to extract large amounts of data from websites. A. Sentiment analysis B.
    10·1 answer
  • Presentation software allows business professionals to _____.
    14·2 answers
  • Write a C or C program A6p2.c(pp) that accepts one command line argument which is an integer n between 2 and 4 inclusive. Genera
    9·1 answer
  • Writing a program in a language such as c or java is known as _____ the program.
    10·1 answer
  • Vhat is output by the code below?<br><br> PLEASE HELP!! TIME LIMIT!!
    5·1 answer
  • This is not homework but how do you fix this I’ve tried everything
    9·1 answer
  • Exactly how thin is the air in outer space?
    10·1 answer
  • A rugby team has 15 players. A bus company has big buses that can carry 48 passengers and small buses that can carry 10 passenge
    10·1 answer
  • Write an application program in C++ to implement a class Fibonacci to print Fibonacci series upto N using member function series
    9·1 answer
  • G. What are handheld computers? Write its types.​
    7·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!