Support our Blind Hand Charity by donating at 9818291723. Your contribution has the potential to bring about significant positive change for humanity.

Search This Blog

MY PROGRAMMES

Sunday, April 16, 2023

CHECK FOR VALIDITY OF A DATE

print("Write date in dd/mm/yyyy format")
d=int(input("Enter the date = "))
print("If month from 1 to 9 write without zero else write normally")
m=int(input("Enter the month = "))
y=int(input("Enter the year = "))
print("The date entered =",d,"/",m,"/",y)
if y%4==0:
    if m==2:
        if (d>0 and d<=29): print(end="")
        else: print("The date is invalid")
    if (m==1 or m==3 or m==5 or m==7 or m==9 or m==11):
        if(d>0 or d<=30): print("The date is valid")
        else: print("The date is invalid")
    elif (m==4 or m==6 or m==8 or m==10 or m==12):
        if(d>0 or d<=31):print("The date is valid")
        else: print("The date is invalid")
    else:print("The date is invalid")
else:
    if m==(2):
        if (d>0 and d<=28): print(end="The date is valid")
        else: print("The date is invalid")
    if (m==1 or m==3 or m==5 or m==7 or m==9 or m==11):
        if(d>0 or d<=30): print("The date is valid")
        else: print("The date is invalid")
    elif (m==4 or m==6 or m==8 or m==10 or m==12):
        if(d>0 or d<=31):print(end="The date is valid")
        else: print("The date is invalid")
    else:print("The date is invalid")