Write a program that asks the user to enter a positive integer n. assuming that this integer is in seconds, your program should convert the number of seconds into days, hours, minutes, and seconds in pyth
Answers
Answered by
4
Source code:
n = int(input("Enter a positive integer: "))
nn = float(n)
print()
if n >= 0:
d = nn/86400
h = nn/3600
m = nn/60
print(n, "seconds is equivalent to:")
print(d, "days")
print(h, "hours")
print(m, "minutes")
elif n < 0:
print("Enter a positive integer.")
We're converting the integer into a float since we can't be sure that during division, int(n) will be fully divisible by the given values. Hence it's most suitable to convert it into float values so that decimal values are accepted during division.
Similar questions