Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #---credits---#
- #
- # Made by JackCDK
- #
- # Find more of my work at jackcdk.cf
- #
- #---libs---#
- import csv #for storing student data
- #---variables---#
- username = "jfinney" #username
- password = "password" #password
- welcomeScreen = '''
- ==========================
- Welcome back {}!
- Commands:
- add (adds new student details)
- find (finds studend details)
- leave (exits client)
- '''.format(username) #Welcome back @username
- findStud = '''
- ==========================
- Commands:
- list (lists all students)
- back (go back to main menu)
- '''
- #---functions---#
- def addStudent(): #function to add student detail
- print("==========================")
- while True:
- code = input("[>] Please enter student's special number: ") #surname
- surname = input("[>] Please enter student's surname: ") #surname
- forename = input("[>] Please enter student's forename: ") #firstname
- dob = input("[>] Please enter student's date of birth: ") #date of birth
- street = input("[>] Please enter student's home address: ") #street address
- phone = input("[>] Please enter student's home phone number: ") #home phone
- with open('STUDENT_DETAILS.csv','a') as csv_file: #set open to csv_file
- csv_app = csv.writer(csv_file) #csv_app is the file
- csv_app.writerow([code,surname,forename,dob,street,phone]) #write the given info into the file
- ae = input("[?] Do you want to add another student[Y/N]: ") # aks for input
- if ae == "Y":
- addStudent() # if Y then go to addStudent()
- elif ae == "N":
- mainSys() # if N then go to mainSys()
- else:
- print("[!] I do not understand that response...") # obv
- def findStudent():
- print(findStud)
- while True: #Starts loop
- coms = input("[>] Please choose an option: ") # obv
- if coms == "list":
- with open('STUDENT_DETAILS.csv') as csv_file: # assigns the file as csv_file
- CSV_read = csv.reader(csv_file) # makes csv_read read the csv file
- print("\n===")
- for row in CSV_read: # print rows in the csv file
- print(row)
- print("===")
- elif coms == "back":
- mainSys() #if user enters 'back' will call
- else:
- print("[!] Sorry, I don't understand that.")
- def loginSys(): #login function
- print("==========================")
- while True: #Starts loop (just so that it will loop if the password is wrong)
- un = input("[>] Please enter username: ") #asks for username
- pw = input("[>] Please enter password: ") #asks for password
- if un == username and pw == password: #if the input = the variables, you get logged in
- mainSys()
- print("logged in")
- break #break the loop since you got the right details
- else: #if not, you get to try again
- print("[!] Error, Username or password incorrect")
- print("[!] Please try again")
- def mainSys(): #Main screen
- print(welcomeScreen) #Prints welcome message
- coms = input("[>] Enter command: ")
- if coms == "add": # obv
- addStudent() # obv
- elif coms == "find": # obv
- findStudent() # obv
- elif coms == "leave": # obv
- exit()
- #---Start of program---#
- loginSys() #calls login function, starts of the whole program
Add Comment
Please, Sign In to add comment