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
spayn [35]
3 years ago
8

I need to write a really simple python program to solve this issue. I have most of the program written but, when I run the secon

d example, the result is incorrect. Examples 1 and 3 work just fine.
Write a program to calculate the number of seconds since midnight. For example, suppose the time is 1:02:05 AM. Since there are 3600 seconds per hour and 60 seconds per minutes, it has been 3725 seconds since midnight (3600 * 1 + 2 * 60 + 5 = 3725). The program asks the user to enter 4 pieces of information: hour, minute, second, and AM/PM. The program will calculate and display the number of seconds since midnight. [Hint: be very careful when the hour is 12].

Examples for testing code:

Enter hour: 1 Enter minute: 2 Enter second: 5 Enter AM or PM: AM Seconds since midnight: 3725

Enter hour: 11 Enter minute: 58 Enter second: 59 Enter AM or PM: PM Seconds since midnight: 86339

Enter hour: 12 Enter minute: 7 Enter second: 20 Enter AM or PM: AM Seconds since midnight: 440

Here is the code that I have written: As I have said, It should be a simple program.

Thank you in advance for your help!!!!


hour = float(input("Enter hour:"))
minute = float(input("Enter minute:"))
second = float(input("Enter second:"))
am_pm = input ("Enter AM or PM:")
if am_pm == "am" and hour == 12:
hour = 0
seconds_since_midnight = ((3600 * hour) +(minute *60) + second)
print("Seconds since midnight:", seconds_since_midnight)
Computers and Technology
1 answer:
denis-greek [22]3 years ago
4 0

Answer:

hour = float(input("Enter hour:"))

minute = float(input("Enter minute:"))

second = float(input("Enter second:"))

am_pm = input ("Enter AM or PM:")

if am_pm == "AM":

   if hour == 12:

       hour = 0

   seconds_since_midnight = ((3600 * hour) +(minute *60) + second)

elif am_pm == "PM":

   seconds_since_midnight = ((3600 * (hour+12)) +(minute *60) + second)

print("Seconds since midnight:", int(seconds_since_midnight))

Explanation:

The point here is when PM is chosen, you need to add 12 to the hour. I added <em>elif</em>  part to satisfy this. Moreover, since the output is in integer format, you may need to apply type casting for <em>seconds_since_midnight</em> variable.

You might be interested in
Entering the formula =SUM(C5:C18) in cell C19 will result in which of the following?
frozen [14]
Well the result shown in C19 will show the sum of all cells from C5 to C18:
ie: C5 + C6+ C7+ C8+ C9+ C10+ C11+ C12+ C13+ C14+ C15+ C16+ C17+ C18

:)
3 0
2 years ago
Is the following statement true or false?
Alchen [17]

Answer:

The following statement is True.

Explanation:

Because when we are applying the pair t-test then, take differences of that pair and then treat it as an individual samples. Formula for the test is a statistic and in this case, it is also same as formula in the one-sample of t statistics.

Therefore, it will be an equivalent to the one-sample t-test.

6 0
2 years ago
A large global retail corporation has experienced a security breach, which includes personal data of employees and customers.
sergeinik [125]

The act that  Accenture would offer as the best solution to ensure enhanced security in the future is Data Protection program.

<h3>What is Accenture  about?</h3>

In Keeping client data protected, Accenture’s Information Security Client is known to be well built up with Data Protection program that can help client teams with a good approach and the security controls, etc.

Therefore, The act that  Accenture would offer as the best solution to ensure enhanced security in the future is Data Protection program.

Learn more about Accenture from

brainly.com/question/25682883

#SPJ1

5 0
2 years ago
Hiding/masking personal identifiers from a data set, so that the data set can never identify an individual, even if it is correl
Anettt [7]

Hiding/masking personal identifiers from a data set, so that the data set can never identify an individual, even if it is correlated with other data sets is known as anonymization.

<h3>What is anonymization?</h3>

The term anonymization is known as data masking and it is the standard solution in the case of data pseudonymisation. It is generally recognised by using masking and data is de- sensitised also that privacy could be maintained and private information remains safe for the support.

Data is generally identified by using masking and data is de- sensitised also that privacy could be maintained and private information remains safe for the support.

Therefore, Hiding/masking personal identifiers from a data set, so that the data set can never identify an individual, even if it is correlated with other data sets is known as anonymization.

Learn more about anonymization here:

brainly.com/question/4268168

#SPJ4

5 0
1 year ago
In the United States there are more women than men, but women are referred to as a minority group? Why are they considered a min
ziro4ka [17]
Cause they make up half the population of the united states of america
7 0
2 years ago
Read 2 more answers
Other questions:
  • Your organization wants to implement a 5-year rotation plan for all of its computing devices. What percentage of the computer fl
    10·2 answers
  • You '' friend or ''like'' a page o your favorite social media page that advertises a
    10·1 answer
  • 12. Kelly would like to know the average bonus multiplier for the employees. In cell C11, create a formula using the AVERAGE fun
    7·1 answer
  • There is usually a positive side and a negative side to each technology improvement. Select a technology you use every day and c
    5·1 answer
  • Given a Fahrenheit value temperatureFahrenheit, write a statement that assigns temperatureCelsius with the equivalent Celsius va
    9·1 answer
  • 1. The programmer intends for this pseudocode to display three random numbers in the range of 1 through 7. According to the way
    12·1 answer
  • Suppose Client A initiates a Telnet session with Server S. At about the same time, Client B also initiates a Telnet session with
    13·1 answer
  • Messages that have been accessed or viewed in the Reading pane are automatically marked in Outlook and the message subject is no
    10·2 answers
  • Write steps for converting decimal to binary numbers?
    13·1 answer
  • • Do you think documentaries are best delivered in media such as films or documentary?
    10·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!