Write a program that accepts seconds from the keyboard as integers. Your program should convert seconds into hours, minutes and seconds. Your output should like this :
Enter seconds: 13400
Hours: 3
Minutes: 43
Seconds: 20
Code:
def convert_seconds(seconds):
# Calculate hours, minutes, and remaining
seconds
hours = seconds // 3600
remaining_seconds = seconds % 3600
minutes = remaining_seconds // 60
seconds = remaining_seconds % 60
return hours, minutes, seconds
# Prompt the
user to enter seconds
seconds =
int(input("Enter seconds: "))
# Convert
seconds to hours, minutes, and seconds
hours, minutes,
seconds = convert_seconds(seconds)
# Display the
result
print("Hours:",
hours)
print("Minutes:",
minutes)
print("Seconds:",
seconds)
0 Comments