Skip to content

Commit f56b15a

Browse files
authored
Add files via upload
1 parent 922ee5a commit f56b15a

File tree

1 file changed

+45
-0
lines changed

1 file changed

+45
-0
lines changed

sundays_calculator.py

Lines changed: 45 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,45 @@
1+
# WAP to calculate how many sundays have you lived from the day you were born. take input of birthday from user.
2+
3+
month = [31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31]
4+
5+
birthdate = int(input("Birth Day : "))
6+
birthmonth = int(input("Birth Month : "))
7+
birthyear = int(input("Birth Year : "))
8+
9+
todayday = input("What is today's day(M/Tu/W/Th/F/Sa/Su) : ")
10+
11+
currentdate = int(input("Current date : "))
12+
currentmonth = int(input("Current Month : "))
13+
currentyear = int(input("Current year: "))
14+
15+
dayslived = 0
16+
sundayslived = 0
17+
18+
for m in range(currentmonth - 1):
19+
dayslived += month[m]
20+
dayslived += currentdate
21+
22+
for m in range(birthmonth - 1, 12):
23+
if m == birthmonth - 1:
24+
dayslived += month[m] - birthdate + 1
25+
else:
26+
dayslived += month[m]
27+
28+
totalyears = currentyear - birthyear - 1
29+
dayslived += totalyears * 365
30+
31+
leapyear = [i for i in range(birthyear + 1, currentyear) if (i % 400 == 0) or (i % 4 == 0 and (i % 100 != 0))]
32+
dayslived += len(leapyear)
33+
34+
if (birthyear % 400 == 0 or (birthyear % 4 == 0 and birthyear % 100 != 0)) and birthmonth < 3 and birthdate != 29:
35+
dayslived += 1
36+
37+
if (currentyear % 400 == 0 or (currentyear % 4 == 0 and currentyear % 100 != 0)) and currentmonth >= 2:
38+
if currentmonth == 2 and currentdate == 29:
39+
dayslived += 1
40+
elif currentmonth > 2:
41+
dayslived += 1
42+
43+
sundayslived += dayslived // 7
44+
45+
print("Total Number Of Sunday's You Have Lived: ", sundayslived)

0 commit comments

Comments
 (0)