Advertisement
Guest User

Month Gen - Alfie C

a guest
Feb 3rd, 2019
350
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 8.33 KB | None | 0 0
  1. #This creates the variable for the login system, and takes a Y ( Yes ) or a N ( No ). This will be used soon.
  2. versystem = input("Have you signed up for an account? y/n: ")
  3.  
  4. #makes the next lines of code occur, and is called when versystem is equal to no
  5. if versystem == "n":
  6.     #This creates a while loop, so we can put in our variables
  7.     while True:
  8.         #Here we create new variables so we can enter a new account
  9.         username  = input("Enter your username: ")
  10.         #This creates a password variable
  11.         password  = input("Enter your password: ")
  12.         #This creates a verification variable
  13.         password1 = input("Confirm password: ")
  14.         #This creates an if statement, and sees if the verification password matches the actual password
  15.         if password == password1:
  16.             #This writes a new file, so we can add the variables to it
  17.             file = open(username+".txt", "w")
  18.             #Here we write in the variables to the file
  19.             file.write(username+":"+password)
  20.             #This line closes the file, since we are finished with it
  21.             file.close()
  22.             #This changes the versystem variable to yes, and runs a new set of code
  23.             versystem = "y"
  24.             #This stops the loop, so it doesn't happen again
  25.             break
  26.         #If the passwords do not match, then this message is shown
  27.         print("Passwords do not match, please try again!")
  28.  
  29. #We create a new function, so we can write our later code into a file.
  30. def origDate(day, month, year):
  31.   #This opens a new file, and edits to it or writes a new file.
  32.   fil = open("MonthGen.txt", "a+")
  33.   #This writes a liine called:
  34.   fil.write("Orginal Date: \n")
  35.   #This writes in our dates, but are changed to strings, since integers cannot be used
  36.   fil.write(str(day)+'/'+str(month)+'/'+str(year)+'\n')
  37.   #This closes the file
  38.   fil.close()
  39.  
  40. #Makes the function for one outcome, calls a few variables that will be made later
  41. def month1L(day, month1, ny):
  42.   #Appends or creates a file to print info
  43.   fileMon1 = open("MonthGen.txt", "a+")
  44.   #Writes infomation for the user that would be printed
  45.   fileMon1.write("3 Months Later: \n"+str(day)+'/'+str(month1)+'/'+str(ny)+'\n')
  46.   #Closes the file
  47.   fileMon1.close()
  48.  
  49. #Makes the function for one outcome, calls a few variables that will be made later
  50. def month1NL(day, month, year):
  51.   #Appends or creates a file to print info
  52.   fileMon1N = open("MonthGen.txt", "a+")
  53.   #Writes infomation for the user that would be printed
  54.   fileMon1N.write("3 Months Later: \n"+str(day)+'/'+str(month+3)+'/'+str(year)+'\n')
  55.   #Closes the file
  56.   fileMon1N.close()
  57.  
  58. #Makes the function for one outcome, calls a few variables that will be made later
  59. def month2L(day, month2, ny):
  60.   #Appends or creates a file to print info
  61.   fileMon2 = open("MonthGen.txt", "a+")
  62.   #Writes infomation for the user that would be printed
  63.   fileMon2.write("6 Months Later: \n"+str(day)+'/'+str(month2)+'/'+str(ny)+'\n')
  64.   #Closes the file
  65.   fileMon2.close()
  66.  
  67. #Makes the function for one outcome, calls a few variables that will be made later
  68. def month2NL(day, month, year):
  69.   #Appends or creates a file to print info
  70.   fileMon2N = open("MonthGen.txt", "a+")
  71.   #Writes infomation for the user that would be printed
  72.   fileMon2N.write("6 Months Later: \n"+str(day)+'/'+str(month+6)+'/'+str(year)+'\n')
  73.   #Closes the file
  74.   fileMon2N.close()
  75.  
  76. #Makes the function for one outcome, calls a few variables that will be made later
  77. def month3L(day, month3, ny):
  78.   #Appends or creates a file to print info
  79.   fileMon3 = open("MonthGen.txt", "a+")
  80.   #Writes infomation for the user that would be printed
  81.   fileMon3.write("9 Months Later: \n"+str(day)+'/'+str(month3)+'/'+str(ny)+'\n')
  82.   #Closes the file
  83.   fileMon3.close()
  84.  
  85. #Makes the function for one outcome, calls a few variables that will be made later
  86. def month3NL(day, month, year):
  87.   #Appends or creates a file to print info
  88.   fileMon3N = open("MonthGen.txt", "a+")
  89.   #Writes infomation for the user that would be printed
  90.   fileMon3N.write("9 Months Later: \n"+str(day)+'/'+str(month+9)+'/'+str(year)+'\n')
  91.   #Closes the file
  92.   fileMon3N.close()
  93.  
  94.  
  95. #This creates a logout function, so we can logout of the program.
  96. def logOut():
  97.   #This creates a new variable and asks if you want to logout.
  98.   logout = input("Would you like to logout? y/n: ")
  99.   #If you do not want to logout, then it calls on the month generator
  100.   if logout == "n":
  101.     #This calls the month generator
  102.     monthS()
  103.   #If you want to logout, then exit() is run, and exits the program
  104.   if logout == "y":
  105.     #This exits the program
  106.     exit()
  107.  
  108. #This is the month generator, and is the main part of the program
  109. def monthS():  
  110.   #Here we are creating three new variables
  111.   day = int(input("Please input the day: "))
  112.   #This creates a month variable
  113.   month = int(input("Please input the month: "))
  114.   #This creates the year variable
  115.   year = int(input("Please input the year: "))
  116.   #This calls the function we made earlier, and copies the original dates to a file
  117.   origDate(day, month, year)
  118.   #This makes the months if the year needs to loop
  119.   month1 = (month+3)-12
  120.   #This creates the 2nd month that needs to be printed after 6 months
  121.   month2 = (month+6)-12
  122.   #This creates the 3rd month that needs to be printed after 9 months
  123.   month3 = (month+9)-12
  124.   #This creates a new year, and just adds one
  125.   ny = year+1
  126.   #This creates an if statement, and is called if the months go over 12
  127.   if month+3 > 12:
  128.     #This now prints to the user the following:
  129.     #This prints this line to the user
  130.     print("After 3 Months: ")
  131.     #Prints the month1 variable to the user
  132.     print(day,"/",month1,"/",ny)
  133.     #Calls the function to write this to the text file
  134.     month1L(day, month1, ny)
  135.   #If the top is not true, then this happens  
  136.   else:
  137.     #This tells the user it is 3 months after
  138.     print("After 3 Months: ")
  139.     #This prints the month variable plus 3
  140.     print(day,"/",month+3,"/",year)
  141.     #This copies this information to the text file
  142.     month1NL(day, month, year)
  143.   #If month +6 is more than 12, then this happens
  144.   if month+6 > 12:
  145.     #Tells the user it is 6 months after
  146.     print("After 6 Months:")
  147.     #Prints the month2 variable to the user
  148.     print(day,"/",month2,"/",ny)
  149.     #Calls the function to copy this info to the text file
  150.     month2L(day, month2, ny)
  151.   #If the top is not true, then this happens
  152.   else:
  153.     #Tells the user it is after 6 months
  154.     print("After 6 Months:")
  155.     #Simply prints the month variable plus 6
  156.     print(day,"/",month+6,"/",year)
  157.     #Calls this function to copy this info to the file
  158.     month2NL(day, month, year)
  159.   #If the original month +9 is more than 12, then this happens
  160.   if month+9 > 12:
  161.     #Tells the user it is after 9 months
  162.     print("After 9 Months:")
  163.     #Prints the month3 variable
  164.     print(day,"/",month3,"/",ny)
  165.     #Calls the function to copy this info to a file
  166.     month3L(day, month3, ny)
  167.   #If the top is not true, then this happens
  168.   else:
  169.     #Tells the user it is 9 months after
  170.     print("After 9 Months:")
  171.     #Prints the month variable plus 6
  172.     print(day,"/",month+9,"/",year)
  173.     #Calls this function to copy this info to the file
  174.     month3NL(day, month, ny)
  175.   #Asks the user if they want to logout, and takes a yes or no answer
  176.   logOut()
  177.  
  178.  
  179. #If the user answers yes immediately, then this occurs
  180. if versystem == "y":
  181.     #Here we create a while loop
  182.     while True:
  183.         #We are creating new variables, so we can login
  184.         login1 = input("Login: ")
  185.         #This creates a password variable
  186.         login2 = input("Password: ")
  187.         #We now open a file and read it, and it should have the name of a username we made earlier
  188.         file = open(login1+".txt", "r")
  189.         #Here we create a variable that reads the line in the file
  190.         data   = file.readline()
  191.         #This creates an if statement, seeing if what we enters exists already
  192.         if data == login1+":"+login2:
  193.             #Here we acknowledge that the user has logged in
  194.             print("Welcome!")
  195.             #Here we run the month generator  
  196.             monthS()    
  197.             #We stop the loop so it doesn't continue
  198.             break
  199.         #If the username and password do not work, then this is printed
  200.         else:
  201.           #This tells the user it is incorrect
  202.           print("Incorrect")
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement