Q. Write a program that reads from user  - (i)an hour between 1 to 12 and (ii) number of hours ahead . the program should the print the time after those many hours.

Enter hours between 1 to 12: 8

How many hours a head: 5

Time at that time would be 1 o’clock


You can understand by Watching video :-



Answer :-

time = int(input("Enter an hour between 1 to 12 = "))
headhour = int(input("Enter the a head hour = "))
sum = time + headhour
print("Time at that time would be",(sum<= 12 and sum)or sum-12,"o’clock" )

Output :-

Enter an hour between 1 to 12 = 8
Enter the a head hour = 5
Time at that time would be 1 o’clock

>>> 

Enter an hour between 1 to 12 = 11
Enter the a head hour = 6
Time at that time would be 5 o’clock

>>>

Post a Comment

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

Previous Post Next Post