Skip to content

Commit 3d4e7aa

Browse files
Updated Code
1 parent d03dc08 commit 3d4e7aa

File tree

1 file changed

+10
-9
lines changed

1 file changed

+10
-9
lines changed

Quiz Project/Quiz game.py

Lines changed: 10 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -6,27 +6,28 @@ def __init__(self, question, correctAnswer, otherAnswers):
66
self.corrAnsw = correctAnswer
77
self.otherAnsw = otherAnswers
88

9-
qaList = [QA("Where is Minsk?", "in Belarus", ["in Russia", "such a city doesn't exist"]),
10-
QA("What is the capital of Australia?", "Canberra", ["Sydney", "New York", "Australia doesn't exist"]),
11-
QA("Which of the following is not on Earth?", "Sea of Tranquility", ["Mediterranean Sea", "Baltic Sea", "North Sea"]),
12-
QA("Which of the following is not a continent?", "Arctica", ["Antarctica", "America"]),
13-
QA("Which of the following is not an African country?", "Malaysia", ["Madagascar", "Djibouti", "South Africa", "Zimbabwe"])]
9+
qaList = [QA("What is (void*)0?", "Representation of NULL pointer", ["Representation of void pointer", "Error"]),
10+
QA("In which header file is the NULL macro defined?", "stdio.h and stddef.h", ["stdio.h", "stddef.h", "math.h"]),
11+
QA("A pointer is?", "A variable that stores address of other variable", ["A keyword used to create variables", "A variable that stores address of an instruction", "All of the above"]),
12+
QA("The operator used to get value at address stored in a pointer variable is?", "*", ["&", "&&"]),
13+
QA("The keyword used to transfer control from a function back to the calling function is?", "return", ["goto", "switch", "getch"])]
1414

1515
corrCount = 0
1616
random.shuffle(qaList)
1717
for qaItem in qaList:
1818
print(qaItem.question)
19-
print("Possible answers are:")
19+
print("---------------------------")
2020
possible = qaItem.otherAnsw + [qaItem.corrAnsw] # square brackets turn correct answer into list for concatenating with other list
2121
random.shuffle(possible)
2222
count = 0 # list indexes start at 0 in python
2323
while count < len(possible):
2424
print(str(count+1) + ": " + possible[count])
2525
count += 1
26+
print("---------------------------")
2627
print("Please enter the number of your answer:")
2728
userAnsw = input()
2829
while not userAnsw.isdigit():
29-
print("That was not a number. Please enter the number of your answer:")
30+
print("That is not a number. Please enter the number of your answer:")
3031
userAnsw = input()
3132
userAnsw = int(userAnsw)
3233
while (userAnsw >= int(len(possible))):
@@ -36,8 +37,8 @@ def __init__(self, question, correctAnswer, otherAnswers):
3637
print("Your answer was correct.")
3738
corrCount += 1
3839
else:
39-
print("Your answer was wrong.")
40-
print("Correct answer was: " + qaItem.corrAnsw)
40+
print("Your answer is wrong.")
41+
print("Correct answer : " + qaItem.corrAnsw)
4142
print("")
4243

4344
print("You answered " + str(corrCount) + " of " + str(len(qaList)) + " questions correctly.")

0 commit comments

Comments
 (0)