#4r: Codding in Python {DAY FINDER}
#Note:
Logic for this code was from my Mental Ability classes in my coaching center.
for j in range(1):
print('Only for 4-digit year')
date=int(input('Enter date: '))
month=str(input('Enter full name of month in CAPS ON: '))
year=int(input('Enter 4-digit year: '))
k=[]
if date<=31:
if month=='JANUARY' or month=='FEBRUARY' or month=='MARCH' or month=='APRIL' or month=='MAY' or month=='JUNE' or month=='JULY' or month=='AUGUST' or month=='SEPTEMBER' or month=='OCTOBER' or month=='NOVEMBER' or month=='DECEMBER':
aa=year
for i in range(0,aa+1,4):
k.append(i)
for t in (k):
if t%100==0 and t%400!=0:
k.remove(t)
if aa in (k):
mny={'JANUARY':1,
'FEBRUARY':4,
'MARCH':4,
'APRIL':7,
'MAY':2,
'JUNE':5,
'JULY':7,
'AUGUST':3,
'SEPTEMBER':6,
'OCTOBER':1,
'NOVEMBER':4,
'DECEMBER':6}
a=date
b=mny.get(month)
c=int(year/100)
y=((year-1)-(c*100))
d=y
if c%4==1:
o=5
if c%4==2:
o=3
if c%4==3:
o=1
if c%4==0 or c%4==4:
o=0
e=o
f=int(d/4)
day=((a+b+d+e+f)%7)
if day==1:
print(date,'th',month,year,'was/is/will be Monday.')
if day==2:
print(date,'th',month,year,'was/is/will be Tuesday.')
if day==3:
print(date,'th',month,year,'was/is/will be Wednesday.')
if day==4:
print(date,'th',month,year,'was/is/will be Thursday.')
if day==5:
print(date,'th',month,year,'was/is/will be Friday.')
if day==6:
print(date,'th',month,year,'was/is/will be Saturday.')
if day==0:
print(date,'th',month,year,'was/is/will be Sunday.')
else:
mny={'JANUARY':0,
'FEBRUARY':3,
'MARCH':3,
'APRIL':6,
'MAY':1,
'JUNE':4,
'JULY':6,
'AUGUST':2,
'SEPTEMBER':5,
'OCTOBER':0,
'NOVEMBER':3,
'DECEMBER':5}
a=date
b=mny.get(month)
c=int(year/100)
y=((year-1)-(c*100))
d=y
if c%4==1:
o=5
if c%4==2:
o=3
if c%4==3:
o=1
if c%4==0 or c%4==4:
o=0
e=o
f=int(d/4)
day=((a+b+d+e+f)%7)
if day==1:
print(date,'th',month,year,'was/is/will be Monday.')
if day==2:
print(date,'th',month,year,'was/is/will be Tuesday.')
if day==3:
print(date,'th',month,year,'was/is/will be Wednesday.')
if day==4:
print(date,'th',month,year,'was/is/will be Thursday.')
if day==5:
print(date,'th',month,year,'was/is/will be Friday.')
if day==6:
print(date,'th',month,year,'was/is/will be Saturday.')
if day==0:
print(date,'th',month,year,'was/is/will be Sunday.')
else:
print('Incorrect month')
else:
print('Incorrect date')
Download CODES here.
Logic for this code was from my Mental Ability classes in my coaching center.
for j in range(1):
print('Only for 4-digit year')
date=int(input('Enter date: '))
month=str(input('Enter full name of month in CAPS ON: '))
year=int(input('Enter 4-digit year: '))
k=[]
if date<=31:
if month=='JANUARY' or month=='FEBRUARY' or month=='MARCH' or month=='APRIL' or month=='MAY' or month=='JUNE' or month=='JULY' or month=='AUGUST' or month=='SEPTEMBER' or month=='OCTOBER' or month=='NOVEMBER' or month=='DECEMBER':
aa=year
for i in range(0,aa+1,4):
k.append(i)
for t in (k):
if t%100==0 and t%400!=0:
k.remove(t)
if aa in (k):
mny={'JANUARY':1,
'FEBRUARY':4,
'MARCH':4,
'APRIL':7,
'MAY':2,
'JUNE':5,
'JULY':7,
'AUGUST':3,
'SEPTEMBER':6,
'OCTOBER':1,
'NOVEMBER':4,
'DECEMBER':6}
a=date
b=mny.get(month)
c=int(year/100)
y=((year-1)-(c*100))
d=y
if c%4==1:
o=5
if c%4==2:
o=3
if c%4==3:
o=1
if c%4==0 or c%4==4:
o=0
e=o
f=int(d/4)
day=((a+b+d+e+f)%7)
if day==1:
print(date,'th',month,year,'was/is/will be Monday.')
if day==2:
print(date,'th',month,year,'was/is/will be Tuesday.')
if day==3:
print(date,'th',month,year,'was/is/will be Wednesday.')
if day==4:
print(date,'th',month,year,'was/is/will be Thursday.')
if day==5:
print(date,'th',month,year,'was/is/will be Friday.')
if day==6:
print(date,'th',month,year,'was/is/will be Saturday.')
if day==0:
print(date,'th',month,year,'was/is/will be Sunday.')
else:
mny={'JANUARY':0,
'FEBRUARY':3,
'MARCH':3,
'APRIL':6,
'MAY':1,
'JUNE':4,
'JULY':6,
'AUGUST':2,
'SEPTEMBER':5,
'OCTOBER':0,
'NOVEMBER':3,
'DECEMBER':5}
a=date
b=mny.get(month)
c=int(year/100)
y=((year-1)-(c*100))
d=y
if c%4==1:
o=5
if c%4==2:
o=3
if c%4==3:
o=1
if c%4==0 or c%4==4:
o=0
e=o
f=int(d/4)
day=((a+b+d+e+f)%7)
if day==1:
print(date,'th',month,year,'was/is/will be Monday.')
if day==2:
print(date,'th',month,year,'was/is/will be Tuesday.')
if day==3:
print(date,'th',month,year,'was/is/will be Wednesday.')
if day==4:
print(date,'th',month,year,'was/is/will be Thursday.')
if day==5:
print(date,'th',month,year,'was/is/will be Friday.')
if day==6:
print(date,'th',month,year,'was/is/will be Saturday.')
if day==0:
print(date,'th',month,year,'was/is/will be Sunday.')
else:
print('Incorrect month')
else:
print('Incorrect date')
Download CODES here.
Comments