• API
• FAQ
• Tools
• Trends
• Archive
daily pastebin goal
90%
SHARE
TWEET

# seconds_converter

a guest Mar 1st, 2013 37 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
1. minutes_per_hour = 60
2. hours_per_day = 24
3. days_per_week = 7
4. weeks_per_year = 52
5.
6. seconds_per = {'seconds': 1, 'minutes': 60}
7. seconds_per['hours'] = seconds_per['minutes'] * minutes_per_hour
8. seconds_per['days'] = seconds_per['hours'] * hours_per_day
9. seconds_per['weeks'] = seconds_per['days'] * days_per_week
10. seconds_per['years'] = seconds_per['weeks'] * weeks_per_year
11.
12. print("This program will tell you how many seconds are in a certain number of years, weeks, days, hours, minutes, and seconds.")
13.
14. user_input = {}
15. units = ['years', 'weeks', 'days', 'hours', 'minutes', 'seconds']
16. for unit in units:
17.     user_input[unit] = int(input("Please input the number of {}: ".format(unit)))
18. print("Computing...")
19.
20. seconds = []
21. for unit, num in user_input.items():
22.     seconds.append(num * seconds_per[unit])
23. seconds = str(sum(seconds))
24. print("Done!")
25.
26. output = "There are {} seconds in {} years, {} weeks, {} days, {} hours, {} minutes, and {} seconds."
27. print(output.format(seconds, *[user_input[unit] for unit in units]))
RAW Paste Data
Top