Many people keep time using a 24 hour clock (11 is 11am and 23 is 11pm, 0 is midnight). If it is currently 13 and you set your alarm to go off in 50 hours, it will be 15 (3pm). Write a Python program to solve the general version of the above problem. Your program should first prompt the user for the time now (in hours) and for the number of hours to wait for the alarm, then store those values as type int variables time_now and wait_time respectively, and finally print the time on the 24 hour clock when the alarm will go off.

Respuesta :

Answer:

The program written in Python is as follows;

time_now = int(input("Time: "))

wait_time = int(input("Alarm: "))

time_now = time_now + wait_time%24

if time_now < 12:

     print(str(time_now)+"am")

else:

     time_now = time_now - 12

     print(str(time_now)+"pm")

Explanation:

This line prompts user for current time

time_now = int(input("Time: "))

This line prompts user for the alarm hours

wait_time = int(input("Alarm: "))

This line calculates the time of the alarm

time_now = time_now + wait_time%24

The following if statement determines if the time will be am or pm

If the time is less than 12, then the time will be in am

if time_now < 12:

     print(str(time_now)+"am")

If otherwise,  then the time will be in pm

else:

     time_now = time_now - 12

     print(str(time_now)+"pm")

The Code is below

Learn more:https://brainly.com/question/13246418

Ver imagen Omm2
Ver imagen Omm2