program in python for addition of two time in hour and minute format


Write a program in python for addition of two time in hour and minute format


h1=int(input("Enter the hour 1 : "))

h2=int(input("Enter the hour 2 : "))

m1=int(input("Enter the minute 1 : "))

m2=int(input("Enter the minute 2 : "))

h3=h1+h2+(m1+m2)//60

m3=(m1+m2)%60

print("time 1 = ",h1,":",m1)  

print("time 2 = ",h2,":",m2)

print("time 3 = ",h3,":",m3)


Output:-

Enter the hour 1 : 2

Enter the hour 2 : 3

Enter the minute 1 :  45

Enter the minute 2 :  35


time 1 =  2 : 45

time 2 =  3 : 35

time 3 =  6 : 20



Post a Comment

0 Comments