Question

In: Computer Science

Many people keep time using a 24 hour clock (11 is 11am and 23 is 11pm,...

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. Ask the user for the time now (in hours), and then ask for the number of hours to wait for the alarm. Your program should output what the time will be on the clock when the alarm goes off.

Using python

Solutions

Expert Solution

# Python program to print when the time when alarm is going to turn off

# Getting the inputs from User

presentTime = int(input("Enter current time: "))

turnoffTime = int(input("Enter a Turn Off time: "))

# presentTime is the current time of the system in 24 hour format 13 for example

#turnoffTime is the time after which the alarm is going to Off 50 for example

shutdownTime= presentTime+(turnoffTime % 24)

# The time at which Alarm is going to turn off is given by the above equation

# for the given example shutdownTime is 13+(50%24) = 13+2 = 15

if(shutdownTime < 24): #Since the time doesn't exceed 24 we taken this if eLse loop

                print("Alarm goes Off at: ",shutdownTime," hours")

else:

                print("Alarm goes off at: ",shutdownTime-24," hours")

output:


Related Solutions

Many people keep time using a 24 hour clock (11 is 11am and 23 is 11pm,...
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. Ask the user for the time now (in hours), and then ask for the number of hours to wait for the alarm. Your program should output what...
Write a Bash script clock.sh that once/second will print the time in the 24-hour clock format...
Write a Bash script clock.sh that once/second will print the time in the 24-hour clock format HH:MM:SS. See "man date" for a command to produce this format of time. rubric clock.sh prints h:m:s in 24-hour clock format clock.sh prints time 1/second
A person vomits frequently over a 24-hour period. They can keep down water but that is...
A person vomits frequently over a 24-hour period. They can keep down water but that is about it. Their bowl movements are normal consistency but infrequent. What acid-base imbalance will result.
MT scores: 11, 11, 16, 17, 19, 20, 21, 21 23 24 24 26 26 27...
MT scores: 11, 11, 16, 17, 19, 20, 21, 21 23 24 24 26 26 27 27 28 28 28 29 30 31 31 32 33 35 37 38 38 39 42 44 Questions for Class MT Score Distribution Analysis 1. Create a boxplot of MT scores. 2. Compute the probability that a randomly selected student from the class scored higher than 20. 3. Are the MT scores normally distributed? Why or why not? 4. Assuming a normal fit, compute...
MT scores: 11, 11, 16, 17, 19, 20, 21, 21 23 24 24 26 26 27...
MT scores: 11, 11, 16, 17, 19, 20, 21, 21 23 24 24 26 26 27 27 28 28 28 29 30 31 31 32 33 35 37 38 38 39 42 44 Questions for Class MT Score Distribution Analysis 1. Create a histogram of MT scores. 2. Describe the shape of the MT scores distribution. 3. Compute the mean and standard deviation. 4. Compute the 5-number summary. 5. Create a boxplot of MT scores. 6. Compute the probability that...
- At Cosi, 2 people make 10 salads in an hour and 3 people make 24...
- At Cosi, 2 people make 10 salads in an hour and 3 people make 24 salads in an hour What is the average product of the 3 person team? - At Cosi, 2 people make 10 salads in an hour and 3 people make 24 salads in an hourWhat is the average product of the 2 person team? - At Cosi, 2 people make 10 salads in an hour and 3 people make 24 salads in an hour What...
Explain the working principle of 12- Hour digital clock using an electronic or block diagram.
Explain the working principle of 12- Hour digital clock using an electronic or block diagram.
In JAVA Write a program that converts a time from 24-hour notation to 12-hour notation. Assume...
In JAVA Write a program that converts a time from 24-hour notation to 12-hour notation. Assume the user will enter the time as a 4-digit number with no colon. Define an exception class called InvalidTimeFormatException. If the user enters an invalid time lime 1065 or 2515, the program should throw and handle an InvalidTimeFormatException. NOTE: Assume the user will enter the time as a 4-digit number with no colon. SAMPLE OUTPUT: Enter time in 24-hour notation: 1614 That is the...
Write a program to convert the time from 24-hour notation to 12-hour notation and vice versa....
Write a program to convert the time from 24-hour notation to 12-hour notation and vice versa. Your program must be menu driven, giving the user the choice of converting the time between the two notations. Furthermore, your program must contain at least the following functions: a function to convert the time from 24-hour notation to 12-hour notation; a function to convert the time from 12-hour notation to 24-hour notation; a function to display the choices; function(s) to get the input;...
Write a program to convert the time from 24-hour notation to 12-hour notation and vice versa....
Write a program to convert the time from 24-hour notation to 12-hour notation and vice versa. Your program must be menu driven, giving the user the choice of converting the time between the two notations. Furthermore, your program must contain at least the following functions: a function to convert the time from 24-hour notation to 12-hour notation; a function to convert the time from 12-hour notation to 24-hour notation; a function to display the choices; function(s) to get the input;...
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT