Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import csv
- que = 0 #So here I am setting 4 variables, the question-number, the answer-number, the hint-number and the score
- anw = 0
- hnt = 0
- score = 0
- print("Welcome, to the Data Challenge!")
- print("You will be asked a series of questions.")
- print("All correct answers will give you 2 points, while all incorrect answers will take off 1 point")
- print("The test is case sensitive, so add capital letters where appropriate (begginning of words)")
- print("If you need help, type 'Hint' as your answer, and a tip will come up")
- print("However, this will cost you 1 point")
- print()
- print("Remember, this test is Case Sensitive, so do not miss out on those captials.")
- print()
- begin = str(input("Are you ready to begin? (Y/N) "))
- print()
- if begin == "Y":
- print("Lets do this!")
- qes = True #the variable qes here is just used for a while loop
- while qes:
- qs = [] #so here I am creating a list for all of the questions
- with open("questions.txt", mode="r",encoding="utf-8") as question:
- reader = csv.reader(question)
- for row in reader:
- qs.append(row)
- uno = qs[que] #return of the 'que' variable. this bit of code makes it so that the variable uno is set to the 'que' position in the list
- print(uno) #for example, if que = 3, then it would read the 4th line of the list (lists start at 0)
- ans = [] #another list creation just here
- with open("answers.txt", mode="r",encoding="utf-8") as answer:
- reader = csv.reader(answer)
- for row in reader:
- ans.append(row)
- dos = ans[anw] #same basic logic as above here
- print(dos)
- ans1 = input()
- if ans1 == dos: #this is where everything goes wrong, it does not accept my 'ans1' input as being the same as the line from the list
- print("You are right!")
- score = score + 2
- print("Your score is ", score)
- que = que +1 #if you get the question right, then all of the variables go up 1
- anw = anw +1 #meaning that the position in the list rises by 1
- hnt = (hnt)+1 #and everything repeats, thanks to the while loop.
- qes = True #since all the variables have changed, now there will be different questions, answers and hints shown
- else:
- if (ans1) == "Hint":
- score = (score)-1
- hin = []
- with open("hints.txt", mode="r",encoding="utf-8") as hints:
- reader = csv.reader(hints)
- for row in reader:
- hin.append(row)
- print(hin[hnt])
- qes = True
- else:
- print("That is incorrect. Let's start from the beginning.")
- que = 0
- anw = 0
- hnt = 0
- score = (score)-1
- qes = True
- else:
- print("Alright then. See you next time.")
- exit()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement