Advertisement
Guest User

Untitled

a guest
Oct 15th, 2017
99
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 3.33 KB | None | 0 0
  1. import csv
  2. def csv_read():
  3. db = []
  4. file = "FakeNames3.csv"
  5. with open(file, "r") as a:
  6. reader = csv.reader(a)
  7. for row in reader:
  8. db.append(row)
  9. return db
  10. def findStudent():
  11. while True:
  12. try:
  13. IDChoice = str(input("Enter Pupil ID: "))
  14. break
  15. except ValueError:
  16. print("Invalid Input, ID must be an integer")
  17. found = False
  18. for row in pupils:
  19. print(row[0], "and", IDChoice)
  20. if row[0] == IDChoice:
  21. print("Pupil Found:")
  22. found = True
  23. for a in range(0,13):
  24. print(row)
  25. if found == False:
  26. print("Invalid pupil ID, pupil not found")
  27. print("Returning to main menu...")
  28. menu()
  29.  
  30. def reports():
  31. print("Filler")
  32.  
  33. def LogOut():
  34. print("Sucessfully logged out, please log in again")
  35. LogOn()
  36.  
  37. def menu():
  38. print("~~~~~~~~~~Menu~~~~~~~~~~ \n 1) Find Student \n 2) Produce Reports \n 3) Log Out")
  39. while True:
  40. try:
  41. choice = int(input("Enter the corresponding number for your choice: "))
  42. if choice > 0 and choice < 4:
  43. break
  44. else:
  45. print("Please enter a number between 1 and 3")
  46. except ValueError:
  47. print("Invalid Input")
  48. if choice == 1:
  49. findStudent()
  50. if choice == 2:
  51. reports()
  52. if choice == 3:
  53. LogOut()
  54.  
  55. def LogOn():
  56. print("~~~~~~~~~~WElCOME~~~~~~~~~~")
  57. logged = False
  58. while logged == False:
  59. while True:
  60. try:
  61. user = input("Enter username: ")
  62. passw = input("Enter password: ")
  63. break
  64. except ValueError:
  65. print("Invalid entries, please try again")
  66.  
  67. if user == realUser and passw == realPass:
  68. print("Welcome, Mr Leeman!")
  69. logged = True
  70. else:
  71. print("Incorrect username and/or password")
  72. menu()
  73.  
  74. def LogOn():
  75. print("~~~~~~~~~~WElCOME~~~~~~~~~~")
  76. logged = False
  77. while logged == False:
  78. while True:
  79. try:
  80. user = input("Enter username: ")
  81. passw = input("Enter password: ")
  82. break
  83. except ValueError:
  84. print("Invalid entries, please try again")
  85.  
  86. if user == realUser and passw == realPass:
  87. print("Welcome, Mr Leeman!")
  88. logged = True
  89. else:
  90. print("Incorrect username and/or password")
  91. menu()
  92.  
  93. def LogOn(db):
  94. found = False
  95. username = input("entre,username")
  96. password = input("entre, password")
  97. strAT = "@"
  98. if len(username)> 0 and len(password)> 0:
  99. print("your password and username is above 0")
  100. if username.find(strAT) != -1:
  101. print("@ found")
  102. for each_record in db:
  103. if each_record[11] == username and each_record[12]==password:
  104. found = True
  105. print("username and pass found")
  106. else:
  107. print("username and pass not found")
  108. else:
  109. print("no @")
  110. else:
  111. print("username or pass length below 0")
  112. return found
  113. menu()
  114.  
  115. pupils = []
  116. pupils = csv_read()
  117. realUser = "LeeMr"
  118. realPass = "Pass421"
  119. LogOn()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement