1 Comment
User's avatar
Andy Au Lugo's avatar

#Build a Simple Quiz Game

def new_game():

correct_guesses = 0

numeric_options = 1

guesses = []

print("Welcome to a Harry Potter Quiz Game")

print(" ")

for key in questions:

print("------------------------------")

print(key)

for j in options[numeric_options - 1]:

print(j)

numeric_options += 1

awnser = input("Enter A, B, C, or D: ")

awnser = awnser.upper()

guesses.append(awnser)

correct_guesses += check_answer(questions.get(key), awnser)

show_score(correct_guesses,guesses)

print("-----------------------------")

print()

play_game()

def check_answer(awnsers,awnser):

if awnser == awnsers:

print("YOU GOT IT!")

return 1

else:

print("Wrong!")

return 0

def show_score(correct_guesses,guesses):

print()

print("RESULTS!")

print("AWNSERS: ", end=" ")

for i in questions:

print(questions.get(i), end=" ")

print()

print("GUESSES: ", end=" ")

for i in guesses:

print(i, end=" ")

print()

score = int((correct_guesses/len(questions))*100)

print(f"Your score is : {score}%")

def play_game():

while True:

response = input("Wanna play againg?: ")

if response == "yes" or response == "y":

new_game()

else:

break

print("Thanks for playing!")

questions = {

"Who is the actor who played Harry Potter?:": "A",

"Where is the movie 'Harry Potter' set?: ": "A",

"Who writes the 'Harry Potter' books?: ": "D",

"What is the name of Harry Potter's best friend?: ": "C",

"How many books are in the 'Harry Potter' series?: ": "B",

"How many movies are in the 'Harry Potter' series?: ": "D"

}

options = [["A.Daniel Radcliffe", "B.Emma Watson", "C.Rupert Grint", "D.Tom Felton"],

["A.Hogwarts", "B.London", "C.New York", "D.Paris"],

["A.J.R.R. Tolkien", "B.Stephen King", "C.George R.R. Martin", "D.J.K. Rowling"],

["A.Neville Longbottom", "B.Hermione Granger", "C.Ron Weasley", "D.Draco Malfoy"],

["A.6", "B.7", "C.8", "D.9"],

["A.5", "B.7", "C.6", "D.8"]]

new_game()

Expand full comment