Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import re
- def main():
- print('''# This is Age Calculator Program.
- # This program is written by Osama Kurdi.
- --------------------------------------------------------------------''')
- while True:
- YON = input("Have You Registered Name Before? (Yes or No)")
- if YON == 'No':
- UserName = str(input("Enter Your UserName:"))
- if UserName == 'Osama':
- print("This UserName Is Taken.")
- continue
- PassWord = int(input("Enter Your Password:"))
- if (PassWord > 99999999):
- print("Password Should Not Be More Than 8 Numbers.\n", "Please Enter A New One With Our Conditions.")
- continue
- print("Your Account Detalies is UserName: {} PassWord: {}".format(UserName, PassWord))
- print("Account Registered!")
- DOB = input("Enter Your Birthday Like That dd/mm/yy:")
- DON = input("Enter Date Now Like That dd/mm/yy:")
- if re.search(r'\d{1,2}/\d{1,2}/\d{4}', DON) is None or re.search(r'\d{1,2}/\d{1,2}/\d{4}',
- DOB) is None:
- print('You have entered a wrong format! ')
- print('--------------------------------------------------------------------')
- continue
- if YON == 'Yes':
- name=input("Enter Your Name (Name or I Dont Have):")
- if name == 'I Dont Have':
- continue
- if name == 'Osama':
- password=input("Enter The Password")
- if(int(password)==32363236):
- print("Loged In Succsefully")
- DD=19
- MM=8
- YY=2004
- NN=input("Enter Date Now (dd/mm/yy):")
- if re.search(r'\d{1,2}/\d{1,2}/\d{4}', NN) is None:
- print('You have entered a wrong format! ')
- print('--------------------------------------------------------------------')
- continue
- NN=NN.split('/')
- DDD, MMM, YYY=int(NN[0]), int(NN[1]), int(NN[2])
- GY = str(YYY - YY) + ' Years And '
- GM = str(MMM - MM) + ' Monthes And '
- GD = str(DDD - DD) + ' Days .'
- GMM = str(12 - int(MM) + int(MMM) - 1)
- # 19/8/2017
- # 19/12/2004
- GYY = str(YYY - YY) + ' Years '
- if (int(MMM) >= int(MM) and int(DDD) >= int(DD)):
- if YYY - YY < 2:
- GY = GY.replace(' Years And ', ' Year And ')
- if MMM - MM < 2:
- GM = GM.replace(' Monthes And ', 'Monthe And')
- if DDD - DD < 2:
- GD = GD.replace(' Days .', ' Day ')
- print("Your Age is " + GY + GM + GD)
- # If Monthes Now Is Smaller Than Monthes Born And Days Now Is Smaller Than Days Born::
- # 3
- if (int(MMM) < int(MM) and int(DDD) < int(DD)):
- if YYY - YY < 2:
- GY = GY.replace(' Years And ', ' Year And ')
- if MMM - MM < 2:
- GM = GM.replace(' Monthes And ', 'Monthe And')
- if DDD - DD < 2:
- GD = GD.replace(' Days .', ' Day ')
- print("Your Age is " + GY, GMM, "Monthes And", 30 - int(DD) + int(DDD), "Days.")
- # B 19/8/2004
- # N 17/5/2017
- # If Monthes Now Is Smaller Than Monthes Born And Days NOw Is Bigger Than Days Born::
- # 4
- if (int(MMM) < int(MM) and int(DDD) >= int(DD)):
- if YYY - YY < 2:
- GY = GY.replace(' Years And ', ' Year And ')
- if MMM - MM < 2:
- GM = GM.replace(' Monthes And ', 'Monthe And')
- if DDD - DD < 2:
- GD = GD.replace(' Days .', ' Day ')
- print("Your Age is " + GY, GMM, "Monthes And", int(DDD - DD), "Days.")
- # If Monthes Now Is Bigger Than Monthes Born And Days Now Is Smaller Than Days Born.
- # 2
- if (int(MMM) >= int(MM) and int(DDD) < int(DD)):
- if YYY - YY < 2:
- GY = GY.replace(' Years And ', ' Year And ')
- if MMM - MM < 2:
- GM = GM.replace(' Monthes And ', 'Monthe And')
- if DDD - DD < 2:
- GD = GD.replace(' Days .', ' Day ')
- print("Your Age is " + GY,GMM, "Monthes And", 30 - int(DD) + int(DDD), "Days.")
- break
- else:
- print("You Have Entered Wrong Password.")
- continue
- else:
- print("You Have Entered Wrong Name.")
- continue
- #This will convert the user's input into lists to use them in assigning values.
- DON= DON.split('/')
- DOB= DOB.split('/')
- # This line assigns spefic year's, month's and day's values.
- YearsB, MonthesB, DaysB=int(DOB[2]), int(DOB[1]), int(DOB[0])
- YearsN, MonthesN, DaysN = int(DON[2]), int(DON[1]), int(DON[0])
- # These lines calculate years, months and days.
- AgeY=str(YearsN-YearsB) + ' Years And '
- AgeM=str(MonthesN-MonthesB) + ' Monthes And '
- AgeD=str(DaysN-DaysB) + ' Days .'
- AgeMM=str(12-int(MonthesB)+int(MonthesN)-1)
- #19/8/2017
- #19/12/2004
- AgeYY=str(YearsN-YearsB) + ' Years '
- #If Monthes Now And Days Now Are Bigger Than Monthes And Days Now :::
- #1
- if(int(YearsN)<int(YearsB)):
- print("You Did Not Born Yet :)")
- continue
- if(int(MonthesN) >= int(MonthesB) and int(DaysN) >= int(DaysB)):
- if YearsN - YearsB < 2:
- AgeY = AgeY.replace(' Years And ', ' Year And ')
- if MonthesN - MonthesB < 2:
- AgeM = AgeM.replace(' Monthes And ', 'Monthe And')
- if DaysN - DaysB < 2:
- AgeD = AgeD.replace(' Days .', ' Day ')
- print("Your Age is " + AgeY + AgeM + AgeD)
- #If Monthes Now Is Smaller Than Monthes Born And Days Now Is Smaller Than Days Born::
- #3
- if(int(MonthesN)<int(MonthesB) and int(DaysN)<int(DaysB)):
- if YearsN - YearsB < 2:
- AgeY = AgeY.replace(' Years And ', ' Year And ')
- if MonthesN - MonthesB < 2:
- AgeM = AgeM.replace(' Monthes And ', 'Monthe And')
- if DaysN - DaysB < 2:
- AgeD = AgeD.replace(' Days .', ' Day ')
- print("Your Age is " + AgeY ,AgeMM,"Monthes And" ,30 - int(DaysB) + int(DaysN),"Days.")
- # B 19/8/2004
- # N 17/5/2017
- #If Monthes Now Is Smaller Than Monthes Born And Days NOw Is Bigger Than Days Born::
- #4
- if(int(MonthesN) < int(MonthesB) and int(DaysN) >= int(DaysB)):
- if YearsN - YearsB < 2:
- AgeY = AgeY.replace(' Years And ', ' Year And ')
- if MonthesN - MonthesB < 2:
- AgeM = AgeM.replace(' Monthes And ', 'Monthe And')
- if DaysN - DaysB < 2:
- AgeD = AgeD.replace(' Days .', ' Day ')
- print("Your Age is " + AgeY ,AgeMM,"Monthes And", int(DaysN-DaysB),"Days.")
- #If Monthes Now Is Bigger Than Monthes Born And Days Now Is Smaller Than Days Born.
- #2
- if(int(MonthesN) >= int(MonthesB) and int(DaysN) < int(DaysB)):
- if YearsN - YearsB < 2:
- AgeY = AgeY.replace(' Years And ', ' Year And ')
- if MonthesN - MonthesB < 2:
- AgeM = AgeM.replace(' Monthes And ', 'Monthe And')
- if DaysN - DaysB < 2:
- AgeD = AgeD.replace(' Days .', ' Day ')
- print("Your Age is " + AgeY , AgeMM ,"Monthes And", 30 - int(DaysB) + int(DaysN),"Days.")
- #Will Tell Your Age in Minuites!
- MIN=(YearsN-YearsB)*525600
- print("Minuites In {}:".format(AgeYY) , MIN)
- # Will Tell Your Age in Seconds!
- SEC=(YearsN-YearsB)*31556926
- print("Seconds In {}:".format(AgeYY) , SEC)
- break
- if __name__ == '__main__':main()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement