Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import csv
- def validatelogin(username, password):
- with open("Users.csv", "r") as file:
- read=csv.DictReader(file)
- for row in read:
- if username in row["Username"]:
- #UserName works
- if password in row["Password"]:
- return True
- else:
- return False
- else:
- return False
- def login():
- x=False
- while x==False:
- username = input("What is your username? ")
- password = input("What is your password? ")
- x = validatelogin(username, password)
- if x == False:
- print("Nope, Try again! ")
- print("Logged in!")
- def register():
- firstname=input("What is your first name? ")
- lastname=input("What is your last name? ")
- age=input("What is your age? ")
- year=input("What is your school year? ")
- username=firstname[0:3]+age
- print("Your username is "+ username)
- password=input("What do you want your password to be? ")
- with open("Users.csv","a") as file:
- write=csv.writer(file)
- write.writerow([username,password,firstname,lastname,age,year])
- def writequestions(sub,question,ansA,ansB,ansC,ansD,correct):
- with open("Questions.csv","a") as file:
- write=csv.writer(file)
- write.writerow([sub,question,ansA,ansB,ansC,ansD,correct])
- def questionmaker():
- sub=input("What is the subject? ")
- question=input("What is the question? ")
- ansA=input("What is answer A")
- ansB=input("What is answer B")
- ansC=input("What is answer C")
- ansD=input("What is answer D")
- correct=input("Which answer is correct? A B C or D")
- writequestions(sub,question,ansA,ansB,ansC,ansD,correct)
- def gettopics():
- topics=[]
- with open("Questions.csv","r") as file:
- read=csv.DictReader(file)
- for row in read:
- topics.append(row["Questions"])
- return topics
- def removedupes(lst):
- return list(set(lst))
- def questions():
- questions=[]
- print("Choose a topic out of the list below.")
- topics=removedupes(gettopics())
- for i in topics:
- print(i)
- UI=input("Option: ")
- while UI not in topics:
- print("That was not an option. Look at the list again and try to select one of them")
- UI=input("Option: ")
- alltopics=gettopics()
- with open("Questions.csv","r") as file:
- read=csv.DictReader(file)
- for row in read:
- if UI in row["Questions"]
- questions.append()
- #need to randomly select for test function
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement