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
What is the best programing language to use for building video games?
Alexxandr [17]

hey

I'm going to college for game design.

one of the best languages and the one I'm studying in is c# it is used in unity and many other game engines but there are many more. Just to list a few c++, Java, and many more it is up to you. if you would like more info about this just let me know By the way what game are you planning to make that is one of the most important factors

Hope this helps

-scav

6 0
3 years ago
2. The On and Off states are represented by _____________ class 7 number system​
Artist 52 [7]

Answer:

Binary maybe, I think so

4 0
2 years ago
Read 2 more answers
There are local administrators for each of the departments, excluding the IT. These local administrators will use the local admi
torisob [31]

Answer:

Listed below are the few ways Linux Server can be secured

1. Group policies: This is a way to ensure security by applying group policies and permissions both on the group level and the files level. Through proper permission configuration we can easily restrict other users from accessing those files and directories.

2. Implementation of the firewall: Implementing firewall in each of the Linux server will definitely help in securing your machine from outside threats. Iptables will help in filtering the network traffic that are entering into the system and even going out of the system.

3.Enabling SELINUX: Enabling SELINUX is another way to secure your system especially a Linux Server. Selinux is a powerful security that checks and allows applications to run into the system. It won't allow any untrusted application to run into the system.

6 0
3 years ago
How do airbags prevent injury?
NARA [144]

honestly i think ur answer would be D because it keeps you from flying out of the window

8 0
3 years ago
A man inside water, the pressure which acts on him is
suter [353]

Answer:

C. Liquid and atmospheric pressure

Explanation:

https://courses.lumenlearning.com/physics/chapter/11-4-variation-of-pressure-with-depth-in-a-fluid/

6 0
2 years ago
Other questions:
  • A deleted file or folder is not permanently deleted from a computer until which event occurs? The computer is restarted. The Rec
    13·2 answers
  • How do you delete text from a slide
    14·2 answers
  • All digital images are made up from varying rectangles of color, called _____________.
    6·2 answers
  • Which of the following terms are aspect ratios for devices? 'select all that apply
    11·1 answer
  • Some computer engineering students decided to revise the LC-3 for their senior project. In designing the LC-4, they decided to c
    13·1 answer
  • When a person or organization uses the services of another professional, that person or organization is called the _______
    15·1 answer
  • Ashley has many interests. She likes to read, listen to music, and play soccer with her friends. But her favorite thing to do is
    9·1 answer
  • The sun can be an excellent source of natural light.<br> True.<br> False.
    8·2 answers
  • Tools used to type text on Ms paint​
    12·1 answer
  • Which three statements are true of lossless compression?
    6·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!