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]
2 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]2 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
Help me with the question please..​
PIT_PIT [208]

First addition, then division

4 0
2 years ago
Assignment 1: silly sentences edhesive
Genrish500 [490]

Answer:

print("Let's play Silly Sentences!")

print(" ")

name=input("Enter a name: ")

adj1=input("Enter an adjective: ")

adj2=input("Enter an adjective: ")

adv=input("Enter an adverb: ")

fd1=input("Enter a food: ")

fd2=input("Enter another food: ")

noun=input("Enter a noun: ")

place=input("Enter a place: ")

verb=input("Enter a verb: ")

print(" ")

print(name + " was planning a dream vacation to " + place + ".")

print(name + " was especially looking forward to trying the local \ncuisine, including " + adj1 + " " + fd1 + " and " + fd2 + ".")

print(" ")

print(name + " will have to practice the language " + adv + " to \nmake it easier to " + verb + " with people.")

print(" ")

print(name + " has a long list of sights to see, including the\n" + noun + " museum and the " + adj2 + " park.")

Explanation:

Got it right. Might be a longer version, but it worked for me.

6 0
2 years ago
Power point how to insert diamond symbol
IceJOKER [234]
You got to "insert" and then you go to "shapes" and then you find the symbol you like and you drag and drop it onto the page. Then you can resize to the size and angle you would like it at.
4 0
3 years ago
What is not an operating system
Lostsunrise [7]
The answer is MS-Word
5 0
3 years ago
Most IT security threats originate with hackers.<br> Question 3 options:<br> True<br> False
kap26 [50]
The answer is True they do originate with hackers
6 0
3 years ago
Other questions:
  • Change control in application development is a formal process for changing written documentation into online documentation, and
    13·1 answer
  • Write a program in python that ask the user to enter a word and then capitalizes every other letter of that word
    15·1 answer
  • The "origin" of the cartesian plane in math is the point where x and y are both zero. Given a variable, origin of type Point-- a
    5·1 answer
  • Sites like Zillow get input about house prices from a database and provide nice summaries for readers. Write a program where the
    6·1 answer
  • Create a program that finds (n+1)! -factorial- of an integer n in C++.
    13·1 answer
  • Suppose the message 111010 is to be transmitted (beginning with the leftmost bit) using
    6·1 answer
  • Write a program that first gets a list of integers from input. The input begins with an integer indicating the number of integer
    6·1 answer
  • How is binary used in pixels and in sound?
    5·2 answers
  • What is the decimal number 86 when written as a
    9·1 answer
  • 1. The letters that appear after the dot after a file name are called the:
    15·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!