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
nikdorinn [45]
3 years ago
5

Write a program that converts a time in 12-hour format to 24-hour format. The program will prompt the user to enter a time in HH

:MM:SS AM/PM form. (The time must be entered exactly in this format all on one line.) It will then convert the time to 24 hour form. You may use a string type to read in the entire time at once, including the space before AM/PM, or you may choose to use separate variables for the hours, minutes, seconds and AM/PM.
Computers and Technology
1 answer:
podryga [215]3 years ago
8 0

Answer:

This program is written in Python

inputtime = input("HH:MM:SS AM/PM: ")

splittime = inputtime.split(":")

secondAM = splittime[2].split()

if secondAM[1] == "AM":

   print(splittime[0]+":"+splittime[1]+":"+secondAM[0])

elif secondAM[1] == "PM":

   HH = int(splittime[0])

   HH = HH + 12

   print(str(HH)+":"+splittime[1]+":"+secondAM[0])

   

Explanation:

This line prompts user for input

inputtime = input("HH:MM:SS AM/PM: ")

This line splits the input string to HH, MM and "SS AM/PM"

splittime = inputtime.split(":")

This line splits "SS AM/PM" to SS and AM/PM

secondAM = splittime[2].split()

This line checks if time is AM

if secondAM[1] == "AM":

This line prints the equivalent time

   print(splittime[0]+":"+splittime[1]+":"+secondAM[0])

Else;

elif secondAM[1] == "PM":

The equivalent 24 hour is calculated

   HH = int(splittime[0]) + 12

This line prints the equivalent time

   print(str(HH)+":"+splittime[1]+":"+secondAM[0])

You might be interested in
]
loris [4]
B. Which promotes a chemical reaction
5 0
3 years ago
You give an object a more meaningful name by setting the object’s _________________ property.
viva [34]

Answer:

The correct answer to this question is "Name".

Explanation:

In the programming language, the object is a part of the object-oriented programming language (oops).In all (oops) programming language we use class and object. where class is a collection of data member and member function, and object is a real-world entity. An Object is an instance of a Class. When a class is created, no memory is assigned but when we create the object of the class then memory is allocated.

In this question except option (d), all options are wrong.

7 0
3 years ago
Please someone participate in my typing race ...
dsp73

Answer:

what is typing race

this link can not be clicked

8 0
3 years ago
After you enter the details for the first selected recipient in the New Address List dialog box, click _______ to add another re
masha68 [24]
B. New Entry

I hope this helps
8 0
3 years ago
Read 2 more answers
Describe personal computer skills using three adjectives?
Volgvan

Answer:

proficient with Microsoft word Excel and PowerPoint

Explanation:

compost and send over 150 images microsoftop creating and the formatting simple office budget speed sheets on Microsoft Excel Bros and its documents Microsoft word

5 0
2 years ago
Read 2 more answers
Other questions:
  • Write a short Python function, is_multiple(n, m), that takes two integer values and returns True is n is a multiple of m, that i
    9·1 answer
  • Where is your network strongest? Where is it weakest? How have you developed your network thus far? How has that influenced who
    5·1 answer
  • Which philosopher believed that if we carefully examine the contents of our experience, we find that there are only two distinct
    10·1 answer
  • ITS MAKING ME TYPE URL CODES NOW!
    6·1 answer
  • What is better apple or andriod
    11·2 answers
  • A great way to obtain Hands-On training in a real quick environment is to complete a ??
    12·1 answer
  • Consider the following code:
    5·1 answer
  • Create a list with 5 numbers and find the smallest and largest number in the list and also the sum and product of the numbers in
    9·1 answer
  • The sun emits invisible _____> A) electromagnetic waves B) Waves C) Radiation D) Wavelength E) Ultraviolet Light
    8·1 answer
  • PYTHON:
    11·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!