Advertisement
Guest User

Untitled

a guest
Mar 16th, 2018
100
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.58 KB | None | 0 0
  1. import csv
  2. def validatelogin(username, password):
  3. with open("Users.csv", "r") as file:
  4. read=csv.DictReader(file)
  5. for row in read:
  6. if username in row["Username"]:
  7. #UserName works
  8. if password in row["Password"]:
  9. return True
  10. else:
  11. return False
  12. else:
  13. return False
  14.  
  15. def login():
  16. x=False
  17. while x==False:
  18. username = input("What is your username? ")
  19. password = input("What is your password? ")
  20. x = validatelogin(username, password)
  21. if x == False:
  22. print("Nope, Try again! ")
  23. print("Logged in!")
  24.  
  25.  
  26. def register():
  27. firstname=input("What is your first name? ")
  28. lastname=input("What is your last name? ")
  29. age=input("What is your age? ")
  30. year=input("What is your school year? ")
  31. username=firstname[0:3]+age
  32. print("Your username is "+ username)
  33. password=input("What do you want your password to be? ")
  34.  
  35. with open("Users.csv","a") as file:
  36. write=csv.writer(file)
  37. write.writerow([username,password,firstname,lastname,age,year])
  38.  
  39. def writequestions(sub,question,ansA,ansB,ansC,ansD,correct):
  40. with open("Questions.csv","a") as file:
  41. write=csv.writer(file)
  42. write.writerow([sub,question,ansA,ansB,ansC,ansD,correct])
  43.  
  44. def questionmaker():
  45. sub=input("What is the subject? ")
  46. question=input("What is the question? ")
  47. ansA=input("What is answer A")
  48. ansB=input("What is answer B")
  49. ansC=input("What is answer C")
  50. ansD=input("What is answer D")
  51. correct=input("Which answer is correct? A B C or D")
  52. writequestions(sub,question,ansA,ansB,ansC,ansD,correct)
  53.  
  54. def gettopics():
  55. topics=[]
  56. with open("Questions.csv","r") as file:
  57. read=csv.DictReader(file)
  58. for row in read:
  59. topics.append(row["Questions"])
  60. return topics
  61.  
  62. def removedupes(lst):
  63. return list(set(lst))
  64.  
  65. def questions():
  66. questions=[]
  67. print("Choose a topic out of the list below.")
  68. topics=removedupes(gettopics())
  69. for i in topics:
  70. print(i)
  71. UI=input("Option: ")
  72. while UI not in topics:
  73. print("That was not an option. Look at the list again and try to select one of them")
  74. UI=input("Option: ")
  75. alltopics=gettopics()
  76. with open("Questions.csv","r") as file:
  77. read=csv.DictReader(file)
  78. for row in read:
  79. if UI in row["Questions"]
  80. questions.append()
  81. #need to randomly select for test function
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement