0% found this document useful (0 votes)
25 views4 pages

It 269 Project Team Survey

Uploaded by

api-641993512
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
25 views4 pages

It 269 Project Team Survey

Uploaded by

api-641993512
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 4

import random

Running = True

def Encourageing_message():
# Function to display an encouraging message based on the total score
if totScore == int(3):
print("Your score is " + str(totScore) + ". Amazing, you are so smart\
n")
elif totScore == int(2):
print("Your score is " + str(totScore) + ". Good job\n")
elif totScore == int(1):
print("Your score is " + str(totScore) + ". Nice try\n")
elif totScore == int(0):
print("Your score is " + str(totScore) + ". Maybe next time\n")

# Open a file for reading


open_file = open("File2.dat", "r")

Ques0 = []
Ans0 = []
Rule0 = []
TotalScore = []
totalScore = []

# Read questions, answers, and rules from the file


while True:
line1 = open_file.readline().strip()
line2 = open_file.readline().strip()
line3 = open_file.readline().strip()
if (line1 == ""):
break
Ques0.append(line1)
Ans0.append(line2)
Rule0.append(line3)

while Running == True:


# Initialize variables for each round of the quiz
rules = "TRIVIA QUIZ" + "\nThis quiz will have 3 questions.\n"
score1 = 0
score2 = 0
score3 = 0
Ques1 = []
Ques2 = []
Ques3 = []
Ans1 = []
Ans2 = []
Ans3 = []
Rule1 = []
Rule2 = []
Rule3 = []
Ques1 = Ques0
Ans1 = Ans0
Rule1 = Rule0

print(rules)

ques1 = random.choice(Ques1)
index1 = Ques1.index(ques1)
rules1 = str(Rule1[index1])
print(str(rules1) + "\n")
ans1 = str(input(ques1 + " "))

answer1 = str(Ans1[index1])

if ans1 == answer1:
print("\nCorrect\n\n")
score1 = score1 + 1
else:
print("\nIncorrect")
score1 = score1 + 0

correctAns = input("\nDo you want to see the correct answer (y/n): ")
while True:
if correctAns == "n" or correctAns == "N":
print("\nNext Question.\n")
print("\n")
break
elif correctAns == "y" or correctAns == "Y":
print("\nCorrect is " + str(answer1) + ".\n")
print("\n")
break
else:
correctAns = input("\nDo you want to see the correct answer
(y/n): ")

Ques1.pop(index1)
Ans1.pop(index1)
Rule1.pop(index1)

Ques2 = Ques1
Ans2 = Ans1
Rule2 = Rule1
ques2 = random.choice(Ques2)
index2 = Ques2.index(ques2)
rules2 = str(Rule2[index2])
print(str(rules2) + "\n")
ans2 = str(input(ques2 + " "))
answer2 = str(Ans2[index2])

if ans2 == answer2:
print("\nCorrect\n")
score2 = score2 + 1
else:
print("\nIncorrect")
score2 = score2 + 0
correctAns = input("\nDo you want to see the correct answer (y/n): ")
while True:
if correctAns == "n" or correctAns == "N":
print("\nNext Question.\n")
break
elif correctAns == "y" or correctAns == "Y":
print("\nCorrect is " + str(answer2) + ".\n")
break
else:
correctAns = input("\nDo you want to see the correct answer
(y/n): ")

Ques2.pop(index2)
Ans2.pop(index2)
Rule2.pop(index2)

Ques3 = Ques2
Ans3 = Ans2
Rule3 = Rule2
ques3 = random.choice(Ques3)
index3 = Ques3.index(ques3)
rules3 = str(Rule3[index3])
print(str(rules1) + "\n")
ans3 = str(input(ques3 + " "))

answer3 = str(Ans3[index3])

if ans3 == answer3:
print("\nCorrect\n")
score3 = score3 + 1
else:
print("\nIncorrect")
score3 = score3 + 0
correctAns = input("\nDo you want to see the correct answer (y/n): ")
while True:
if correctAns == "n" or correctAns == "N":
print("\nNext Question.\n")
break
elif correctAns == "y" or correctAns == "Y":
print("\nCorrect is " + str(answer3) + ".\n")
break
else:
correctAns = input("\nDo you want to see the correct answer
(y/n): ")

totScore = score1 + score2 + score3

Encourageing_message()

TotalScore.append(totScore)
totScore = 3
totalScore.append(totScore)

plAg = input("Play again? (y/n): ")


while True:
if plAg == "n" or plAg == "N":
Running = False
break
elif plAg == "y" or plAg == "Y":
Running = True
print("")
break
elif plAg != "n" or plAg != "N" or plAg != "y" or plAg != "Y":
plAg = input("Play again? (y/n): ")
open_file.close()

# Calculate and print the total score


Total = sum(TotalScore)
total = sum(totalScore)
print("\nYour total score is " + str(Total) + " of " + str(total))
exit()

You might also like