Download as txt, pdf, or txt
Download as txt, pdf, or txt
You are on page 1of 2

print("Welcome to the General Knowledge Trivia Game!

")
print("Answer the following questions to test your knowledge.")

# variable for the score and give it a starting value


score = 0

# input from the user for each question


# if the answer is correct and add to the score

# list of questions
questions = [
"What is the capital of France? ",
"Which animal is known for its black and white stripes? ",
"What is the chemical symbol for gold? ",
"Who wrote the play 'Romeo and Juliet'? ",
"What is the largest planet in our solar system? ",
"What is the tallest mammal in the world? ",
"What is the largest country in the world? ",
"What is the largest ocean in the world? ",
"What is the smallest continent in the world? ",
"What is the largest desert in the world? ",
"Who wrote the novel 'To Kill a Mockingbird'? ",
"Who is the author of the Harry Potter series? ",
"Where is the Great Barrier Reef located? ",]

#list of answers
answers = [
"Paris",
"Zebra",
"Au",
"William Shakespeare",
"Jupiter",
"Giraffe",
"Russia",
"Pacific",
"Australia",
"Sahara Desert",
"Harper Lee",
"J.K. Rowling",
"Australia",]

# how many players as a variable


num_players = int(input("How many players are there? "))

# the names of the players


names = []

# loop to get the names of each player and add them to the list
for player in range(num_players):
name = input("Enter the name of player {}: ".format(player+1))
names.append(name)

# all the scores to zero at the start


scores = [0] * num_players

#loop to repeat for the number of players


for player_number in range(num_players):
# loop to create a question number variable
for question_number in range(len(questions)):
# Give the name of each player before asking the question
print("Player {}: {}".format(player_number+1, names[player_number]))
ans = input(questions[question_number])
# Check if the answer matches the correct answer at that position
if ans.lower() == answers[question_number].lower():
scores[player_number] += 1

# name of each player and their score


print("Scores:")
for player_number in range(num_players):
print("{}: {}".format(names[player_number], scores[player_number]))

# Determine the winner by finding the player with the highest score
highest_score_so_far = scores[0]
player_with_highest_score = names[0]

for player_number in range(1, num_players):


if scores[player_number] > highest_score_so_far:
highest_score_so_far = scores[player_number]
player_with_highest_score = names[player_number]
print("The winner is: {}, well done, you are very
smart".format(player_with_highest_score))

You might also like