Advertisement
OsamaKurdi200

Age calculator by OsamaKurdi

May 17th, 2018
258
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 8.59 KB | None | 0 0
  1. import re
  2. def main():
  3.     print('''# This is Age Calculator Program.
  4.    # This program is written by Osama Kurdi.
  5.    --------------------------------------------------------------------''')
  6.     while True:
  7.         YON = input("Have You Registered Name Before? (Yes or No)")
  8.         if YON == 'No':
  9.             UserName = str(input("Enter Your UserName:"))
  10.             if UserName == 'Osama':
  11.                 print("This UserName Is Taken.")
  12.                 continue
  13.             PassWord = int(input("Enter Your Password:"))
  14.             if (PassWord > 99999999):
  15.                 print("Password Should Not Be More Than 8 Numbers.\n", "Please Enter A New One With Our Conditions.")
  16.                 continue
  17.             print("Your Account Detalies is UserName: {} PassWord: {}".format(UserName, PassWord))
  18.             print("Account Registered!")
  19.  
  20.             DOB = input("Enter Your Birthday Like That dd/mm/yy:")
  21.             DON = input("Enter Date Now Like That dd/mm/yy:")
  22.  
  23.             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}',
  24.                                                                                      DOB) is None:
  25.                 print('You have entered a wrong format! ')
  26.                 print('--------------------------------------------------------------------')
  27.                 continue
  28.         if YON == 'Yes':
  29.             name=input("Enter Your Name (Name or I Dont Have):")
  30.             if name == 'I Dont Have':
  31.                 continue
  32.             if name == 'Osama':
  33.                 password=input("Enter The Password")
  34.                 if(int(password)==32363236):
  35.                     print("Loged In Succsefully")
  36.                     DD=19
  37.                     MM=8
  38.                     YY=2004
  39.                     NN=input("Enter Date Now (dd/mm/yy):")
  40.                     if re.search(r'\d{1,2}/\d{1,2}/\d{4}', NN) is None:
  41.                         print('You have entered a wrong format! ')
  42.                         print('--------------------------------------------------------------------')
  43.                         continue
  44.                     NN=NN.split('/')
  45.                     DDD, MMM, YYY=int(NN[0]), int(NN[1]), int(NN[2])
  46.  
  47.                     GY = str(YYY - YY) + ' Years And '
  48.                     GM = str(MMM - MM) + ' Monthes And '
  49.                     GD = str(DDD - DD) + ' Days .'
  50.                     GMM = str(12 - int(MM) + int(MMM) - 1)
  51.                     # 19/8/2017
  52.                     # 19/12/2004
  53.                     GYY = str(YYY - YY) + ' Years '
  54.  
  55.                     if (int(MMM) >= int(MM) and int(DDD) >= int(DD)):
  56.                         if YYY - YY < 2:
  57.                             GY = GY.replace(' Years And ', ' Year And ')
  58.                         if MMM - MM < 2:
  59.                             GM = GM.replace('  Monthes And ', 'Monthe And')
  60.                         if DDD - DD < 2:
  61.                             GD = GD.replace(' Days .', ' Day ')
  62.                         print("Your Age is " + GY + GM + GD)
  63.                     # If Monthes Now Is Smaller Than Monthes Born And Days Now Is Smaller Than Days Born::
  64.                     # 3
  65.                     if (int(MMM) < int(MM) and int(DDD) < int(DD)):
  66.                         if YYY - YY < 2:
  67.                             GY = GY.replace(' Years And ', ' Year And ')
  68.                         if MMM - MM < 2:
  69.                             GM = GM.replace('  Monthes And ', 'Monthe And')
  70.                         if DDD - DD < 2:
  71.                             GD = GD.replace(' Days .', ' Day ')
  72.                         print("Your Age is " + GY, GMM, "Monthes And", 30 - int(DD) + int(DDD), "Days.")
  73.                     # B  19/8/2004
  74.                     # N  17/5/2017
  75.                     # If Monthes Now Is Smaller Than Monthes Born And Days NOw Is Bigger Than Days Born::
  76.                     # 4
  77.                     if (int(MMM) < int(MM) and int(DDD) >= int(DD)):
  78.                         if YYY - YY < 2:
  79.                             GY = GY.replace(' Years And ', ' Year And ')
  80.                         if MMM - MM < 2:
  81.                             GM = GM.replace('  Monthes And ', 'Monthe And')
  82.                         if DDD - DD < 2:
  83.                             GD = GD.replace(' Days .', ' Day ')
  84.                         print("Your Age is " + GY, GMM, "Monthes And", int(DDD - DD), "Days.")
  85.                     # If Monthes Now Is Bigger Than Monthes Born And Days Now Is Smaller Than Days Born.
  86.                     # 2
  87.                     if (int(MMM) >= int(MM) and int(DDD) < int(DD)):
  88.                         if YYY - YY < 2:
  89.                             GY = GY.replace(' Years And ', ' Year And ')
  90.                         if MMM - MM < 2:
  91.                             GM = GM.replace('  Monthes And ', 'Monthe And')
  92.                         if DDD - DD < 2:
  93.                             GD = GD.replace(' Days .', ' Day ')
  94.                         print("Your Age is " + GY,GMM, "Monthes And", 30 - int(DD) + int(DDD), "Days.")
  95.                     break
  96.                 else:
  97.                     print("You Have Entered Wrong Password.")
  98.                     continue
  99.             else:
  100.                 print("You Have Entered Wrong Name.")
  101.                 continue
  102.  
  103.  
  104.  
  105.  
  106.     #This will convert the user's input into lists to use them in assigning values.
  107.         DON= DON.split('/')
  108.         DOB= DOB.split('/')
  109.  
  110.         # This line assigns spefic year's, month's and day's values.
  111.         YearsB, MonthesB, DaysB=int(DOB[2]), int(DOB[1]), int(DOB[0])
  112.         YearsN, MonthesN, DaysN = int(DON[2]), int(DON[1]), int(DON[0])
  113.         # These lines calculate years, months and days.
  114.         AgeY=str(YearsN-YearsB) + ' Years And '
  115.         AgeM=str(MonthesN-MonthesB) + ' Monthes And '
  116.         AgeD=str(DaysN-DaysB) + ' Days .'
  117.         AgeMM=str(12-int(MonthesB)+int(MonthesN)-1)
  118.         #19/8/2017
  119.         #19/12/2004
  120.         AgeYY=str(YearsN-YearsB) + ' Years '
  121.         #If Monthes Now And Days Now Are Bigger Than Monthes And Days Now :::
  122.         #1
  123.         if(int(YearsN)<int(YearsB)):
  124.             print("You Did Not Born Yet :)")
  125.             continue
  126.  
  127.         if(int(MonthesN) >= int(MonthesB) and int(DaysN) >= int(DaysB)):
  128.             if YearsN - YearsB < 2:
  129.                 AgeY = AgeY.replace(' Years And ', ' Year And ')
  130.             if MonthesN - MonthesB < 2:
  131.                 AgeM = AgeM.replace('  Monthes And ', 'Monthe And')
  132.             if DaysN - DaysB < 2:
  133.                 AgeD = AgeD.replace(' Days .', ' Day ')
  134.             print("Your Age is " + AgeY + AgeM + AgeD)
  135.         #If Monthes Now Is Smaller Than Monthes Born And Days Now Is Smaller Than Days Born::
  136.         #3
  137.         if(int(MonthesN)<int(MonthesB) and int(DaysN)<int(DaysB)):
  138.             if YearsN - YearsB < 2:
  139.                 AgeY = AgeY.replace(' Years And ', ' Year And ')
  140.             if MonthesN - MonthesB < 2:
  141.                 AgeM = AgeM.replace('  Monthes And ', 'Monthe And')
  142.             if DaysN - DaysB < 2:
  143.                 AgeD = AgeD.replace(' Days .', ' Day ')
  144.             print("Your Age is " + AgeY ,AgeMM,"Monthes And" ,30 - int(DaysB) + int(DaysN),"Days.")
  145.         # B  19/8/2004
  146.         # N  17/5/2017
  147.         #If Monthes Now Is Smaller Than Monthes Born And Days NOw Is Bigger Than Days Born::
  148.         #4
  149.         if(int(MonthesN) < int(MonthesB) and int(DaysN) >= int(DaysB)):
  150.             if YearsN - YearsB < 2:
  151.                 AgeY = AgeY.replace(' Years And ', ' Year And ')
  152.             if MonthesN - MonthesB < 2:
  153.                 AgeM = AgeM.replace('  Monthes And ', 'Monthe And')
  154.             if DaysN - DaysB < 2:
  155.                 AgeD = AgeD.replace(' Days .', ' Day ')
  156.             print("Your Age is " + AgeY ,AgeMM,"Monthes And", int(DaysN-DaysB),"Days.")
  157.         #If Monthes Now Is Bigger Than Monthes Born And Days Now Is Smaller Than Days Born.
  158.         #2
  159.         if(int(MonthesN) >= int(MonthesB) and int(DaysN) < int(DaysB)):
  160.             if YearsN - YearsB < 2:
  161.                 AgeY = AgeY.replace(' Years And ', ' Year And ')
  162.             if MonthesN - MonthesB < 2:
  163.                 AgeM = AgeM.replace('  Monthes And ', 'Monthe And')
  164.             if DaysN - DaysB < 2:
  165.                 AgeD = AgeD.replace(' Days .', ' Day ')
  166.             print("Your Age is " + AgeY , AgeMM ,"Monthes And", 30 - int(DaysB) + int(DaysN),"Days.")
  167.  
  168.  
  169.         #Will Tell Your Age in Minuites!
  170.         MIN=(YearsN-YearsB)*525600
  171.         print("Minuites In {}:".format(AgeYY) , MIN)
  172.         # Will Tell Your Age in Seconds!
  173.         SEC=(YearsN-YearsB)*31556926
  174.         print("Seconds In {}:".format(AgeYY) , SEC)
  175.         break
  176.  
  177.  
  178.  
  179.  
  180.  
  181.  
  182. if __name__ == '__main__':main()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement