Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #This creates the variable for the login system, and takes a Y ( Yes ) or a N ( No ). This will be used soon.
- versystem = input("Have you signed up for an account? y/n: ")
- #makes the next lines of code occur, and is called when versystem is equal to no
- if versystem == "n":
- #This creates a while loop, so we can put in our variables
- while True:
- #Here we create new variables so we can enter a new account
- username = input("Enter your username: ")
- #This creates a password variable
- password = input("Enter your password: ")
- #This creates a verification variable
- password1 = input("Confirm password: ")
- #This creates an if statement, and sees if the verification password matches the actual password
- if password == password1:
- #This writes a new file, so we can add the variables to it
- file = open(username+".txt", "w")
- #Here we write in the variables to the file
- file.write(username+":"+password)
- #This line closes the file, since we are finished with it
- file.close()
- #This changes the versystem variable to yes, and runs a new set of code
- versystem = "y"
- #This stops the loop, so it doesn't happen again
- break
- #If the passwords do not match, then this message is shown
- print("Passwords do not match, please try again!")
- #We create a new function, so we can write our later code into a file.
- def origDate(day, month, year):
- #This opens a new file, and edits to it or writes a new file.
- fil = open("MonthGen.txt", "a+")
- #This writes a liine called:
- fil.write("Orginal Date: \n")
- #This writes in our dates, but are changed to strings, since integers cannot be used
- fil.write(str(day)+'/'+str(month)+'/'+str(year)+'\n')
- #This closes the file
- fil.close()
- #Makes the function for one outcome, calls a few variables that will be made later
- def month1L(day, month1, ny):
- #Appends or creates a file to print info
- fileMon1 = open("MonthGen.txt", "a+")
- #Writes infomation for the user that would be printed
- fileMon1.write("3 Months Later: \n"+str(day)+'/'+str(month1)+'/'+str(ny)+'\n')
- #Closes the file
- fileMon1.close()
- #Makes the function for one outcome, calls a few variables that will be made later
- def month1NL(day, month, year):
- #Appends or creates a file to print info
- fileMon1N = open("MonthGen.txt", "a+")
- #Writes infomation for the user that would be printed
- fileMon1N.write("3 Months Later: \n"+str(day)+'/'+str(month+3)+'/'+str(year)+'\n')
- #Closes the file
- fileMon1N.close()
- #Makes the function for one outcome, calls a few variables that will be made later
- def month2L(day, month2, ny):
- #Appends or creates a file to print info
- fileMon2 = open("MonthGen.txt", "a+")
- #Writes infomation for the user that would be printed
- fileMon2.write("6 Months Later: \n"+str(day)+'/'+str(month2)+'/'+str(ny)+'\n')
- #Closes the file
- fileMon2.close()
- #Makes the function for one outcome, calls a few variables that will be made later
- def month2NL(day, month, year):
- #Appends or creates a file to print info
- fileMon2N = open("MonthGen.txt", "a+")
- #Writes infomation for the user that would be printed
- fileMon2N.write("6 Months Later: \n"+str(day)+'/'+str(month+6)+'/'+str(year)+'\n')
- #Closes the file
- fileMon2N.close()
- #Makes the function for one outcome, calls a few variables that will be made later
- def month3L(day, month3, ny):
- #Appends or creates a file to print info
- fileMon3 = open("MonthGen.txt", "a+")
- #Writes infomation for the user that would be printed
- fileMon3.write("9 Months Later: \n"+str(day)+'/'+str(month3)+'/'+str(ny)+'\n')
- #Closes the file
- fileMon3.close()
- #Makes the function for one outcome, calls a few variables that will be made later
- def month3NL(day, month, year):
- #Appends or creates a file to print info
- fileMon3N = open("MonthGen.txt", "a+")
- #Writes infomation for the user that would be printed
- fileMon3N.write("9 Months Later: \n"+str(day)+'/'+str(month+9)+'/'+str(year)+'\n')
- #Closes the file
- fileMon3N.close()
- #This creates a logout function, so we can logout of the program.
- def logOut():
- #This creates a new variable and asks if you want to logout.
- logout = input("Would you like to logout? y/n: ")
- #If you do not want to logout, then it calls on the month generator
- if logout == "n":
- #This calls the month generator
- monthS()
- #If you want to logout, then exit() is run, and exits the program
- if logout == "y":
- #This exits the program
- exit()
- #This is the month generator, and is the main part of the program
- def monthS():
- #Here we are creating three new variables
- day = int(input("Please input the day: "))
- #This creates a month variable
- month = int(input("Please input the month: "))
- #This creates the year variable
- year = int(input("Please input the year: "))
- #This calls the function we made earlier, and copies the original dates to a file
- origDate(day, month, year)
- #This makes the months if the year needs to loop
- month1 = (month+3)-12
- #This creates the 2nd month that needs to be printed after 6 months
- month2 = (month+6)-12
- #This creates the 3rd month that needs to be printed after 9 months
- month3 = (month+9)-12
- #This creates a new year, and just adds one
- ny = year+1
- #This creates an if statement, and is called if the months go over 12
- if month+3 > 12:
- #This now prints to the user the following:
- #This prints this line to the user
- print("After 3 Months: ")
- #Prints the month1 variable to the user
- print(day,"/",month1,"/",ny)
- #Calls the function to write this to the text file
- month1L(day, month1, ny)
- #If the top is not true, then this happens
- else:
- #This tells the user it is 3 months after
- print("After 3 Months: ")
- #This prints the month variable plus 3
- print(day,"/",month+3,"/",year)
- #This copies this information to the text file
- month1NL(day, month, year)
- #If month +6 is more than 12, then this happens
- if month+6 > 12:
- #Tells the user it is 6 months after
- print("After 6 Months:")
- #Prints the month2 variable to the user
- print(day,"/",month2,"/",ny)
- #Calls the function to copy this info to the text file
- month2L(day, month2, ny)
- #If the top is not true, then this happens
- else:
- #Tells the user it is after 6 months
- print("After 6 Months:")
- #Simply prints the month variable plus 6
- print(day,"/",month+6,"/",year)
- #Calls this function to copy this info to the file
- month2NL(day, month, year)
- #If the original month +9 is more than 12, then this happens
- if month+9 > 12:
- #Tells the user it is after 9 months
- print("After 9 Months:")
- #Prints the month3 variable
- print(day,"/",month3,"/",ny)
- #Calls the function to copy this info to a file
- month3L(day, month3, ny)
- #If the top is not true, then this happens
- else:
- #Tells the user it is 9 months after
- print("After 9 Months:")
- #Prints the month variable plus 6
- print(day,"/",month+9,"/",year)
- #Calls this function to copy this info to the file
- month3NL(day, month, ny)
- #Asks the user if they want to logout, and takes a yes or no answer
- logOut()
- #If the user answers yes immediately, then this occurs
- if versystem == "y":
- #Here we create a while loop
- while True:
- #We are creating new variables, so we can login
- login1 = input("Login: ")
- #This creates a password variable
- login2 = input("Password: ")
- #We now open a file and read it, and it should have the name of a username we made earlier
- file = open(login1+".txt", "r")
- #Here we create a variable that reads the line in the file
- data = file.readline()
- #This creates an if statement, seeing if what we enters exists already
- if data == login1+":"+login2:
- #Here we acknowledge that the user has logged in
- print("Welcome!")
- #Here we run the month generator
- monthS()
- #We stop the loop so it doesn't continue
- break
- #If the username and password do not work, then this is printed
- else:
- #This tells the user it is incorrect
- print("Incorrect")
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement