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
Difference between a lesson plan and scheme of work​
MariettaO [177]

SORRY BUT THERE IS No difference at all

5 0
3 years ago
Read 2 more answers
Select all the ways in which business professionals might use a spreadsheet in their jobs.
Dahasolnce [82]

Answer:

By making calculation.

Explanation:

Because spreadsheet is a calculation type software.

4 0
3 years ago
What is the primary reason that companies use third party tracking cookies?
morpeh [17]

Answer:

The most common use of third-party cookies is to track users who click on advertisements and associate them with the referring domain.

Explanation:

For example, when you click on an ad on a website, a third-party cookie is used to associate your traffic with the site where the ad appeared.

5 0
3 years ago
You begin your first day of responsibilities by examining the recent IS security breach at GearUp to get ideas for safeguards yo
pentagon [3]

Answer:

Sniffing is the correct answer to the given question .

Explanation:

The main objective of Sniffing is to leads and stealing the information interception by detecting the network activity this activity is done by the Sniffing process .When the information is sent through the networks, the information inside the data packet can be detected  by using a sniffer .The sniffer is used in sniffing process.Information is accessed  by the sniffer because the information packets that are sent in the network  are not secured.

By using the Sniffing technique the hackers hacked the company's improperly-secured wireless network and stole customers ' credit card details as well as employee social security numbers.

6 0
4 years ago
How to hack the school system
Verizon [17]

Why Would You Need To " Hack" Your Schools Console??

Your school has your computer administrated, Go to developer settings then reboot the computer.

3 0
3 years ago
Other questions:
  • Which best describes a computer bug? A piece of computer hardware that is out of date or has a newer version a piece of computer
    14·2 answers
  • If you touch a downed power line covered or bare, what’s the likely outcome?
    10·2 answers
  • A security system uses sensors at every door and window which will set off an alarm if any one of them is opened. There is also
    13·1 answer
  • Most internet connections use what transmission
    13·2 answers
  • For this lab, youhave to write a programnamedseriesFunction.cthat prompts user to enter two values, x and n. Then it would use a
    11·1 answer
  • Write a program that accepts a whole number as
    5·1 answer
  • Write a program that assigns values to
    15·1 answer
  • This the code from the last post I did
    8·1 answer
  • What’s your tiktok? if u have one
    10·2 answers
  • Identify and state the value of hardware components​
    12·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!