Location via proxy:   [ UP ]  
[Report a bug]   [Manage cookies]                

Python Final Proj

Download as txt, pdf, or txt
Download as txt, pdf, or txt
You are on page 1of 4

PYTHON FINAL PROJECT

GROUP:16
THIS PROJECT CREATED BY:
1.ARINDAM MAJI(62)
2.RAHUL BHAT(63)
3.SOUBHIK SAMANTA(61)

PROBLEM STATEMENT:

Design an application where user will input two dates.

1. user's date of birth in DD/MM/YY format.


2. Current (Present day) date in DD/MM/YY format.
My app will calculate and let the user know how many days that person survived in
this world.

CODE:

print("|||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||")
print("||||||||||||KNOW HOW MANY DAYS YOU WILL SURVIVED|||||||||||||")
print("|||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||")
def part1(birth_day,birth_month,birth_year):

birth_year_days=0
days=30
for i in range(1,birth_month+1):
#for leap year...........
if i == 1 and birth_year%4==0 and (birth_year%100!=0 or birth_year %
400==0) :
birth_year_days=(31-birth_day+1)+5+(12-birth_month)*30
elif i == 2 and birth_year%4==0 and (birth_year%100!=0 or birth_year %
400==0) :
birth_year_days=(29-birth_day+1)+6+(12-birth_month)*30
elif i == 3 and birth_year%4==0 and (birth_year%100!=0 or birth_year %
400==0) :
birth_year_days=(31-birth_day+1)+5+(12-birth_month)*30
elif i == 4 and birth_year%4==0 and (birth_year%100!=0 or birth_year %
400==0) :
birth_year_days=(30-birth_day+1)+5+(12-birth_month)*30
elif i == 5 and birth_year%4==0 and (birth_year%100!=0 or birth_year %
400==0) :
birth_year_days=(31-birth_day+1)+4+(12-birth_month)*30
elif i == 6 and birth_year%4==0 and (birth_year%100!=0 or birth_year %
400==0) :
birth_year_days=(30-birth_day+1)+4+(12-birth_month)*30
elif i == 7 and birth_year%4==0 and (birth_year%100!=0 or birth_year %
400==0) :
birth_year_days=(31-birth_day+1)+3+(12-birth_month)*30
elif i == 8 and birth_year%4==0 and (birth_year%100!=0 or birth_year %
400==0) :
birth_year_days=(31-birth_day+1)+2+(12-birth_month)*30
elif i == 9 and birth_year%4==0 and (birth_year%100!=0 or birth_year %
400==0) :
birth_year_days=(30-birth_day+1)+2+(12-birth_month)*30
elif i == 10 and birth_year%4==0 and (birth_year%100!=0 or birth_year %
400==0) :
birth_year_days=(31-birth_day+1)+1+(12-birth_month)*30
elif i == 11 and birth_year%4==0 and (birth_year%100!=0 or birth_year %
400==0) :
birth_year_days=(30-birth_day+1)+1+(12-birth_month)*30
elif i == 12 and birth_year%4==0 and (birth_year%100!=0 or birth_year %
400==0) :
birth_year_days=(31-birth_day+1)+0+(12-birth_month)*30

#for not leap year...............


elif i in [1,5] and birth_year%4!=0 and (birth_year%100==0 or birth_year %
400!=0) :
birth_year_days=(31-birth_day+1)+4+(12-birth_month)*30
elif i == 6 and birth_year%4!=0 and (birth_year%100==0 or birth_year % 400!
=0) :
birth_year_days=(30-birth_day+1)+4+(12-birth_month)*30
elif i == 2 and birth_year%4!=0 and (birth_year%100==0 or birth_year % 400!
=0) :
birth_year_days=(28-birth_day+1)+6+(12-birth_month)*30
elif i == 3 and birth_year%4!=0 and (birth_year%100==0 or birth_year % 400!
=0) :
birth_year_days=(31-birth_day+1)+5+(12-birth_month)*30
elif i == 4 and birth_year%4!=0 and (birth_year%100==0 or birth_year % 400!
=0) :
birth_year_days=(30-birth_day+1)+5+(12-birth_month)*30
elif i == 7 and birth_year%4!=0 and (birth_year%100==0 or birth_year % 400!
=0) :
birth_year_days=(31-birth_day+1)+3+(12-birth_month)*30
elif i == 8 and birth_year%4!=0 and (birth_year%100==0 or birth_year % 400!
=0) :
birth_year_days=(31-birth_day+1)+2+(12-birth_month)*30
elif i == 9 and birth_year%4!=0 and (birth_year%100==0 or birth_year % 400!
=0) :
birth_year_days=(30-birth_day+1)+2+(12-birth_month)*30
elif i == 10 and birth_year%4!=0 and (birth_year%100==0 or birth_year %
400!=0):
birth_year_days=(31-birth_day+1)+1+(12-birth_month)*30
elif i == 11 and birth_year%4!=0 and (birth_year%100==0 or birth_year %
400!=0):
birth_year_days=(30-birth_day+1)+1+(12-birth_month)*30
elif i == 12 and birth_year%4!=0 and (birth_year%100==0 or birth_year %
400!=0):
birth_year_days=(31-birth_day+1)+0+(12-birth_month)*30

a=birth_year_days
return(a)

def part2(birth_year,current_year):

days=365
total_days=0
for i in range(birth_year+1,current_year):
if i%4==0 and (i%100!=0 or i%400==0):
days=days+1
total_days+=366
else:
days=days
total_days+=365
return(total_days)

def part3(current_day,current_month,current_year):

current_year_days=0
days=30
for i in range(1,current_month+1):
#for leap year........
if i == 1 and current_year%4==0 and (current_year%100!=0 or current_year %
400==0) :
current_year_days=current_day+(current_month-1)*30
elif i in [6,7] and current_year%4==0 and (current_year%100!=0 or
current_year % 400==0) :
current_year_days=current_day+2+(current_month-1)*30
elif i in [2,4,5] and current_year%4==0 and (current_year%100!=0 or
current_year % 400==0) :
current_year_days=current_day+1+(current_month-1)*30
elif i == 8 and current_year%4==0 and (current_year%100!=0 or current_year
% 400==0) :
current_year_days=current_day+3+(current_month-1)*30
elif i in [9,10] and current_year%4==0 and (current_year%100!=0 or
current_year % 400==0) :
current_year_days=current_day+4+(current_month-1)*30
elif i in [11,12] and current_year%4==0 and (current_year%100!=0 or
current_year % 400==0) :
current_year_days=current_day+5+(current_month-1)*30
elif i == 3 and current_year%4==0 and (current_year%100!=0 or current_year
% 400==0) :
current_year_days=current_day+(current_month-1)*30

#for non leap yea............


elif i == 1 and current_year%4!=0 and (current_year%100==0 or current_year
% 400!=0) :
current_year_days=current_day+(current_month-1)*30
elif i in [2,6,7] and current_year%4!=0 and (current_year%100==0 or
current_year % 400!=0) :
current_year_days=current_day+1+(current_month-1)*30
elif i in [4,5] and current_year%4!=0 and (current_year%100==0 or
current_year % 400!=0) :
current_year_days=current_day+0+(current_month-1)*30
elif i == 8 and current_year%4!=0 and (current_year%100==0 or current_year
% 400!=0) :
current_year_days=current_day+2+(current_month-1)*30
elif i in [9,10] and current_year%4!=0 and (current_year%100==0 or
current_year % 400!=0) :
current_year_days=current_day+3+(current_month-1)*30
elif i in [11,12] and current_year%4!=0 and (current_year%100==0 or
current_year % 400!=0) :
current_year_days=current_day+4+(current_month-1)*30
elif i == 3 and current_year%4!=0 and (current_year%100==0 or current_year
% 400!=0) :
current_year_days=current_day-1+(current_month-1)*30
return(current_year_days)

birth_date=input("Enter your birth date in the following format DD/MM/YYYY: ")


birth_day=int(birth_date.split("/")[0])
birth_month=int(birth_date.split("/")[1])
birth_year=int(birth_date.split("/")[2])

current_date=input("Enter current date in the following format DD/MM/YYYY: ")


current_day=int(current_date.split("/")[0])
current_month=int(current_date.split("/")[1])
current_year=int(current_date.split("/")[2])

print(part1(birth_day,birth_month,birth_year)+part2(birth_year,current_year)
+part3(current_day,current_month,current_year))

You might also like