Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- # MAIN VARIABLES
- import time
- tutor = "Mr.Leeman"
- username = "Leeman"
- password = "Donut123"
- file = open('details.txt','r')
- details = file.readlines()
- loop = True
- ID = len(details)
- append = open('details.txt','a')
- # FUNCTIONS
- # LOGIN
- def login():
- print("Welcome to the Tutor Group Manager\nHit q to quit the program.")
- while loop == True:
- userinput = input("\nUSERNAME:")
- if userinput == "q":
- file.close()
- quit()
- passinput = input("PASSWORD:")
- if userinput == username and passinput == password:
- mainmenu()
- elif passinput == "q":
- file.close()
- append.close()
- quit()
- else:
- print("Wrong details given!")
- # MAIN MENU
- def mainmenu():
- print("\n Main Menu")
- print("\n(1)Enter new student details")
- print("(2)Access student details")
- print("(3)Special reports")
- print("(4)Log out")
- menu = input(" O>")
- if menu == "1":
- newdata(ID,append)
- elif menu == "2":
- accessdata(details)
- elif menu == "3":
- print("Special reports")
- elif menu == "4":
- print("")
- login()
- else:
- print("Wrong input given!")
- time.sleep(2)
- print("")
- mainmenu()
- # 1ST OPTION
- def newdata(ID,append):
- print("Enter new student details below:")
- surname = input("SURNAME:")
- forename = input("FORENAME:")
- dob = input("DATE OF BIRTH(day/month/year format):")
- address = input("ADDRESS:")
- phone = input("PHONE NUMBER:")
- if len(phone) < 9:
- print("The phone number is too short, has to be at least 9 digits")
- newdata(ID,append)
- gender = input("GENDER(M/F):")
- if gender == "M":
- gender = "Male"
- elif gender == "F":
- gender = "Female"
- else:
- print("Wrong Gender given! Has to be M(Male) or F(Female)")
- newdata(ID,append)
- email = input("EMAIL ADDRESS(name.surname@treeroad.co.uk):")
- if "@treeroad.co.uk" not in email:
- print("Wrong email address given!")
- newdata(ID,append)
- print("ID = ",ID)
- print("SURNAME = ",surname)
- print("FORENAME = ",forename)
- print("DATE OF BIRTH = ",dob)
- print("ADDRESS = ",address)
- print("PHONE NUMBER = ",phone)
- print("GENDER = ",gender)
- print("Tutor Group = ",tutor)
- print("EMAIL ADDRESS = ",email)
- approval = input("Are you satisfied with the data given?(Y/N)")
- if approval == "Y" or approval == "y":
- ID = str(ID)
- append.write("\n")
- append.write(ID)
- append.write(",")
- append.write(surname)
- append.write(",")
- append.write(forename)
- append.write(",")
- append.write(dob)
- append.write(",")
- append.write(address)
- append.write(",")
- append.write(phone)
- append.write(",")
- append.write(gender)
- append.write(",")
- append.write(tutor)
- append.write(",")
- append.write(email)
- ID = int(ID)
- ID = ID + 1
- print ("New ID = ",ID)
- print("Data saved!")
- time.sleep(1)
- mainmenu()
- elif approval == "N" or approval == "n":
- ID = int(ID)
- ID = ID - 1
- ID = str(ID)
- newdata(ID,append)
- else:
- print("Wrong input!")
- ID = int(ID)
- ID = ID - 1
- ID = str(ID)
- newdata(ID,append)
- def accessdata(details):
- ran = len(details)
- idinput = input("Enter the personalized ID:")
- print("Accessed")
- for x in range(ran):
- print("Accessed")
- split = details[x].split(",")
- print(split[0])
- if split[0] == idinput:
- print("ID = ",split[0])
- print("SURNAME = ",split[0])
- print("FORENAME = ",split[0])
- print("DATE OF BIRTH = ",split[0])
- print("ADDRESS = ",)
- print("PHONE NUMBER = ",phone)
- print("GENDER = ",gender)
- print("Tutor Group = ",tutor)
- print("EMAIL ADDRESS = ",email)
- print("\n(1)Search for another student")
- print("(2)Go back to main menu")
- accessinput = input("O>")
- if accessinput == "1":
- accessdata(details)
- elif accessinput == "2":
- mainmenu()
- else:
- print("Wrong input given!")
- time.sleep(1)
- accessdata(details)
- else:
- print("Not found")
- # MAIN PROGRAM
- login()
- # END OF CODE :)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement