Advertisement
FFFatal

Untitled

Oct 6th, 2017
123
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 5.48 KB | None | 0 0
  1. import time #Allows us to use the time.sleep command
  2. import sys #Allows us to use sys commands (For us it is killing the program on line 50)
  3. import random
  4.  
  5.  
  6.  
  7. def startup():
  8.  
  9. print('\n'*200)
  10.  
  11. username = input('Enter your username: ')
  12. password = input('Enter your password: ')
  13.  
  14. if username == 'leeman' and password == 'password': #Checking the username and password match
  15.  
  16. main_menu() #Finding Main Menu
  17.  
  18.  
  19. else:
  20.  
  21. print('You have entered an incorrect username and password')
  22. time.sleep(2) #Wating 2 seconds
  23. startup()
  24.  
  25.  
  26.  
  27. #--------------------------------------------------------------------------------------------------------------------------------------------------------------
  28.  
  29.  
  30.  
  31.  
  32. def main_menu():
  33.  
  34. print('\n'*200) #Printing enough lines so that the startup menu can't be seen
  35.  
  36.  
  37. print('----- MAIN MENU -----') #
  38. print('Create New Student (C)') #
  39. print('Delete a Student (D)') # MAIN MENU GUI
  40. print('View Students (V)') #
  41. print('Exit Program (E)') #
  42. print('')
  43.  
  44. decision = input('What is your decision: ')
  45.  
  46. if decision == 'C':
  47. createstudent()
  48.  
  49. elif decision == 'D':
  50. deletestudent()
  51.  
  52. elif decision == 'V':
  53. viewstudent()
  54.  
  55. elif decision == 'E':
  56. sys.exit()
  57.  
  58.  
  59. else:
  60. print('You have entered an invalid decision')
  61. time.sleep(2)
  62. print('Returning to main menu ')
  63. time.sleep(2)
  64. main_menu()
  65.  
  66.  
  67. #--------------------------------------------------------------------------------------------------------------------------------------------------------------
  68.  
  69. def createstudent():
  70. print('\n'*200)
  71.  
  72. fname=input("What is the student's forename: ")
  73.  
  74. sname=input("What is the student's surname: ")
  75.  
  76. dob=input("What is the student's birthday in the format 00/00/00: ")
  77.  
  78. iid=random.randint(1,999)
  79.  
  80. sid=str(iid)
  81.  
  82. gender1=input("What is the student's gender out of Male(M),Female(F) and other(O)" )
  83.  
  84. if gender1 == 'M':
  85. gender2 = ('male')
  86.  
  87. elif gender1 == 'F':
  88. gender2 == female
  89.  
  90. elif gender1 == 'O':
  91. gender2 = input('What gender would the student like to be refered as: ')
  92.  
  93. else:
  94. print('You have entered an invalid gender')
  95. createstudent()
  96.  
  97. shome=input("What is the student's home phone number: ")
  98.  
  99. saddress=input("What is the student's home address: ")
  100.  
  101. sform=input("What is the student's form group: ")
  102.  
  103.  
  104.  
  105. with open('students.txt','a') as student:
  106. student.write('\nID'+sid) #
  107. student.write('\n'+fname) #
  108. student.write('\n'+sname) #
  109. student.write('\n'+dob) #
  110. student.write('\n'+gender2) # Writing new students to file
  111. student.write('\n'+shome) #
  112. student.write('\n'+saddress) #
  113. student.write('\n'+sform) #
  114. student.write('\n'*2) #
  115.  
  116. crdecision=input('Do you want to add another student: ')
  117. if crdecision == 'Yes':
  118. createstudent()
  119. else:
  120. print('Returning to main menu ')
  121. time.sleep(2)
  122. main_menu()
  123.  
  124.  
  125.  
  126.  
  127.  
  128.  
  129.  
  130.  
  131.  
  132. #----------------------------------------------------------------------------------------------------------------------------------------------------------------
  133.  
  134. def deletestudent():
  135. pass
  136.  
  137.  
  138.  
  139.  
  140.  
  141. #----------------------------------------------------------------------------------------------------------------------------------------------------------------
  142. def viewstudent():
  143.  
  144. print('\n'*200)
  145.  
  146. IDinput=input("Please enter in the student's ID you want to display ")
  147.  
  148.  
  149.  
  150. with open('students.txt','r') as student:
  151. data = student.read().splitlines() #Making is so it doesn't make new line between each line of information
  152. for i in range(len(data)):
  153. if data[i][:2]=='ID':
  154. ID = data[i][2:]
  155. if IDinput == ID:
  156. print('\n'*2)
  157. print("ID: "+ID)
  158. fname=data[i+1]
  159. sname=data[i+2]
  160. dob=data[i+3]
  161. gender=data[i+4]
  162. shome=data[i+5]
  163. saddress=data[i+6]
  164. sform=data[i+7]
  165.  
  166. print("Forename: "+fname)
  167. print("Surname: "+sname)
  168. print("Date of Birth: "+dob)
  169. print("Gender: "+gender)
  170. print("Phone Number: "+shome)
  171. print("Home Address: "+saddress)
  172. print("Form Group: "+sform)
  173. print('\n'*2)
  174.  
  175. vstudent=input('Do you want to display another student when you are done ')
  176.  
  177. if vstudent == 'Yes':
  178. viewstudent()
  179.  
  180. elif vstudent == 'yes':
  181. viewstudent()
  182.  
  183. else:
  184. time.sleep(1)
  185. print('Returning to main menu')
  186. print('\n'*2)
  187.  
  188. time.sleep(3)
  189. main_menu()
  190.  
  191. else:
  192. print('You have entered an invalid ID ')
  193. time.sleep(1)
  194. print('Returning to view student menu ')
  195. time.sleep(2)
  196. viewstudent()
  197.  
  198.  
  199.  
  200.  
  201.  
  202.  
  203.  
  204.  
  205.  
  206.  
  207.  
  208.  
  209.  
  210.  
  211. startup()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement