Coders Packet

Python program to convert number of days, hours, minutes and seconds to seconds

By Kunal bhati

Developing a program that reads the number of days, hours, minutes, and seconds from the user. Calculate and display the total number of seconds represented by that duration.

 

#Python program to convert a number of days, hours, minutes, and seconds to seconds

 

INPUT-

print("KUNAL BHATI A2305318038")

SECONDS_PER_MINUTE  = 60

SECONDS_PER_HOUR    = 3600

SECONDS_PER_DAY     = 86400

 

days    = int(input("Enter number of Days: "))

hours   = int(input("Enter number of Hours: "))

minutes = int(input("Enter number of Minutes: "))

seconds = int(input("Enter number of Seconds: "))

 

total_seconds = days * SECONDS_PER_DAY

total_seconds = total_seconds + ( hours * SECONDS_PER_HOUR)

total_seconds = total_seconds + ( minutes * SECONDS_PER_MINUTE)

total_seconds = total_seconds + seconds

 

print("Total number of seconds: ","%d"%(total_seconds))

OUTPUT - 

 

 

Download Complete Code

Comments

No comments yet