-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathYears-Months-Weeks-Days Calculator.py
60 lines (35 loc) · 1.11 KB
/
Years-Months-Weeks-Days Calculator.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
"""
A simple calculator for years, months, weeks and days.
"""
number = input('Enter a Number for Calculation: ')
if number.isnumeric():
number = int(number)
# Begins Years
if number >= 365:
years = number // 365
yearsRemainder = number % 365
months = yearsRemainder // 30
monthsRemainder = yearsRemainder % 30
weeks = monthsRemainder // 7
weeksRemainder = monthsRemainder % 7
days = weeksRemainder // 1
print('Years: ' + str(years) + ', Months: ' + str(months) + ', Week: ' + str(weeks) + ', Days: ' + str(days))
# Begins Months
elif number < 365 and number >= 30:
months = number // 30
monthsRemainder = number % 30
weeks = monthsRemainder // 7
weeksRemainder = monthsRemainder % 7
days = weeksRemainder // 1
print('Months: ' + str(months) + ', Week: ' + str(weeks) + ', Days: ' + str(days))
# Begins Weeks
elif number < 30 and number >= 7:
weeks = number // 7
weeksRemainder = number % 7
days = weeksRemainder // 1
print('Week: ' + str(weeks) + ', Days: ' + str(days))
# Begins Days
elif number < 7:
print('Days: ' + str(number))
else:
print('Enter a Number!')