answer.
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]
1 year 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]1 year 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
A large department store has been attaching tags with barcodes to merchandise, and employees use barcode readers to scan merchan
77julia77 [94]

The department store should consider using RFIDs (Radio Frequency Identification) for tracking inventory. Unlike the wireless barcodes, RFID uses radio waves to communicate with readers. One very common advantage of an RFID is the scanning range. Wireless barcodes, for instance, requires the reader to be close to the barcode before it can see it to scan it. However, RFID systems can scan a tag as long as it is within range. This is important because it reduces wastage of time on labor-intensive processes and increases task speed, convenience, and project turnover.

Many passive RFIDs use tags that are powered by electromagnetic energy. Such energy does not consume power.


8 0
1 year ago
Read 2 more answers
An administrator has been working within an organization for over 10 years. He has moved between different IT divisions within t
rodikova [14]

Answer:

User roles and access authorization

(Explanation of this question is given below in the explanation section.

Explanation:

As noted in question that a terminated employee comeback in office and installed some malicious script on a computer that was scheduled to run a logic bomb on the first day of the following month. And, that script will change administrator passwords, delete files, and shut down over 100 servers in the data center.

The following problem can be with that account

  • Unauthorized user access and privileges

The user may be given unauthorized access to system resources. If a user has unauthorized access to system resource then he can modify or destroy the system function easily.

  • The firewall may be disabled to detect the malicious script

The firewall should be enabled to detect such types of attack from unauthorized access to the system

  • Role

May be user role is not defined properly. If role would be defined according to user role then there are very fewer chances in doing unauthorized changes in the system that will result in an unexpected outage.

5 0
2 years ago
Poor quality lateral communication will result in which ofthe
zhuklara [117]

Answer:

b

Explanation:

b, lack of coordination

3 0
1 year ago
Read 2 more answers
The following code should take a number as input, multiply it by 8, and print the result. In line 2 of the code below, the * sym
Juli2301 [7.4K]

Answer:

num = int(input("enter a number:"))

print(num * 8)

Explanation:

num is just a variable could be named anything you want.

if code was like this num = input("enter a number:")

and do a print(num * 8)

we get an error because whatever the user puts in input comes out a string.

we cast int() around our input() function to convert from string to integer.

therefore: num = int(input("enter a number:"))

will allow us to do  print(num * 8)

6 0
2 years ago
In the State of Florida, the penalties for DUI become progressively more severe depending upon the number of convictions and the
sasho [114]
Blood Alcohol Level is the other evidence for more severe penalties.
7 0
1 year ago
Read 3 more answers
Other questions:
  • Rob creates a Course_Details table that has four columns: Course _ID, Course_Name, Semester and Credits. A course may have 0.5 c
    6·2 answers
  • A business wants to centralize its administrative tasks. At the same time, it wants the existing systems to manage and sustain t
    14·2 answers
  • A computer is a multipurpose device that accepts input, processes data, stores data, and produces output, all according to a ser
    9·1 answer
  • Which of the following is an Internet supervisory protocol? O DNS IP O both A and B O neither A nor B
    12·1 answer
  • Which one of the following is the best example of an authorization control? (a)- Biometric device (b)- Digital certificate (c)-A
    11·1 answer
  • Se dau lungimile a N cuvinte (0 &lt; N ≤ 5 000), formate din cel puțin un caracter. Să se afișeze lungimea minimă necesară R a u
    14·1 answer
  • 1.1.5 practice: analyzing business culture
    13·1 answer
  • Which statement is true about the purpose of a work in process constraint?
    15·1 answer
  • Calvin is an aspiring graphic designer. He wants to achieve Adobe Certified Expert certification in software that will be helpfu
    9·1 answer
  • What is Accenture's role in Multi-party Systems?
    12·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!