Skip to content

Commit e81e92e

Browse files
committed
quiz extension
Signed-off-by: Adam McNicol <[email protected]>
1 parent 6f2ec36 commit e81e92e

File tree

1 file changed

+10
-2
lines changed

1 file changed

+10
-2
lines changed

Files/Exercise Solutions/quiz.py

+10-2
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import csv
1+
import csv, random
22

33
def get_questions():
44
questions = []
@@ -25,8 +25,16 @@ def ask_question(question,score):
2525
def main():
2626
questions = get_questions()
2727
score = 0
28-
for question in questions:
28+
print("Welcome to the farming quiz!")
29+
print("============================")
30+
print()
31+
print()
32+
number = int(input("There are {0} questions - how many do you want in your quiz: ".format(len(questions))))
33+
while number > 0:
34+
question = random.choice(questions)
2935
score = ask_question(question, score)
36+
questions.remove(question)
37+
number -= 1
3038
print("Your final score was {0} out of {1}".format(score,len(questions)))
3139

3240
if __name__ == "__main__":

0 commit comments

Comments
 (0)