Guest User

Untitled

a guest
Oct 13th, 2017
37
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 3.44 KB | None | 0 0
  1. #---credits---#
  2. #
  3. # Made by JackCDK
  4. #
  5. # Find more of my work at jackcdk.cf
  6. #
  7.  
  8. #---libs---#
  9.  
  10. import csv #for storing student data
  11.  
  12. #---variables---#
  13.  
  14. username = "jfinney" #username
  15. password = "password" #password
  16.  
  17.  
  18. welcomeScreen = '''
  19. ==========================
  20. Welcome back {}!
  21.  
  22. Commands:
  23. add (adds new student details)
  24. find (finds studend details)
  25. leave (exits client)
  26.  
  27. '''.format(username) #Welcome back @username
  28.  
  29. findStud = '''
  30. ==========================
  31.  
  32. Commands:
  33. list (lists all students)
  34. back (go back to main menu)
  35. '''
  36.  
  37.  
  38. #---functions---#
  39.  
  40. def addStudent(): #function to add student detail
  41. print("==========================")
  42. while True:
  43. code = input("[>] Please enter student's special number: ") #surname
  44. surname = input("[>] Please enter student's surname: ") #surname
  45. forename = input("[>] Please enter student's forename: ") #firstname
  46. dob = input("[>] Please enter student's date of birth: ") #date of birth
  47. street = input("[>] Please enter student's home address: ") #street address
  48. phone = input("[>] Please enter student's home phone number: ") #home phone
  49.  
  50. with open('STUDENT_DETAILS.csv','a') as csv_file: #set open to csv_file
  51. csv_app = csv.writer(csv_file) #csv_app is the file
  52. csv_app.writerow([code,surname,forename,dob,street,phone]) #write the given info into the file
  53.  
  54. ae = input("[?] Do you want to add another student[Y/N]: ") # aks for input
  55. if ae == "Y":
  56. addStudent() # if Y then go to addStudent()
  57. elif ae == "N":
  58. mainSys() # if N then go to mainSys()
  59. else:
  60. print("[!] I do not understand that response...") # obv
  61.  
  62. def findStudent():
  63. print(findStud)
  64. while True: #Starts loop
  65. coms = input("[>] Please choose an option: ") # obv
  66.  
  67. if coms == "list":
  68. with open('STUDENT_DETAILS.csv') as csv_file: # assigns the file as csv_file
  69. CSV_read = csv.reader(csv_file) # makes csv_read read the csv file
  70. print("\n===")
  71. for row in CSV_read: # print rows in the csv file
  72. print(row)
  73. print("===")
  74. elif coms == "back":
  75. mainSys() #if user enters 'back' will call
  76. else:
  77. print("[!] Sorry, I don't understand that.")
  78.  
  79.  
  80.  
  81. def loginSys(): #login function
  82. print("==========================")
  83. while True: #Starts loop (just so that it will loop if the password is wrong)
  84. un = input("[>] Please enter username: ") #asks for username
  85. pw = input("[>] Please enter password: ") #asks for password
  86. if un == username and pw == password: #if the input = the variables, you get logged in
  87. mainSys()
  88. print("logged in")
  89. break #break the loop since you got the right details
  90. else: #if not, you get to try again
  91. print("[!] Error, Username or password incorrect")
  92. print("[!] Please try again")
  93.  
  94.  
  95.  
  96. def mainSys(): #Main screen
  97. print(welcomeScreen) #Prints welcome message
  98. coms = input("[>] Enter command: ")
  99. if coms == "add": # obv
  100. addStudent() # obv
  101. elif coms == "find": # obv
  102. findStudent() # obv
  103. elif coms == "leave": # obv
  104. exit()
  105.  
  106. #---Start of program---#
  107.  
  108. loginSys() #calls login function, starts of the whole program
Add Comment
Please, Sign In to add comment