Q. Write a program that reads from user -

(i) An hour between 1 to 12 and

(ii) Number of hours ahead. The program should then print the time after those many hours.

 

e.g.

Enter hour between 1-12 : 9

How many hours ahead : 4

Time at that time would be : 1 0'clock

 

Answer =

 

 

hour = int(input("Enter An hour between 1 to 12 :-"))
num = int(input("Enter Number of hours ahead :-"))
sum = hour + num
if sum <= 12 :
    print("Time is ",sum,"o clock")
else :
    print("Time is ",sum - 12,"o clock")

Post a Comment

You can help us by Clicking on ads. ^_^
Please do not send spam comment : )

Previous Post Next Post