Get ready to be the Quizmaster! You are going to design your own Python game show in the style of a quiz.

Think of a genre (science, music, math, sports, video games, etc.) and create at least 10 questions. You can decide whether you want to make the questions multiple choice or not. Then go to OnlineGDB to get programming.

Your quiz program must have the following items:

It must start by asking the user what their name is and welcoming them to your quiz. It pays to be polite!
Set up a variable to keep score. It is up to you how to design the points system. Will you give them 10 points for a correct answer and 0 for an incorrect answer? Or perhaps you will be tough and take away points for an incorrect answer!
Ask your 10 quiz questions. If they get a question wrong, be sure to tell the user what the correct answer was. Then adjust the score appropriately, depending on whether their answer was right or wrong.
At the end of the program, tell the user their score.

import random

# Welcome message
print("Welcome to the Python Quiz Show!")
name = input("Please enter your name: ")
print("Hello,", name, "! Let's get started.")

# Set up variables
score = 0
total_questions = 10

# List of questions and answers
questions = [
{
"question": "What is the capital of France?",
"options": ["Paris", "London", "Rome", "Berlin"],
"answer": "Paris"
},
{
"question": "What is the chemical symbol for Gold?",
"options": ["Au", "Ag", "Hg", "Pb"],
"answer": "Au"
},
{
"question": "Who is the author of the Harry Potter series?",
"options": ["Stephen King", "J.R.R. Tolkien", "J.K. Rowling", "George R.R. Martin"],
"answer": "J.K. Rowling"
},
{
"question": "What is the square root of 169?",
"options": ["10", "11", "12", "13"],
"answer": "13"
},
{
"question": "Who won the FIFA World Cup in 2018?",
"options": ["Germany", "Argentina", "France", "Brazil"],
"answer": "France"
},
{
"question": "Which planet is known as the Red Planet?",
"options": ["Mars", "Venus", "Jupiter", "Saturn"],
"answer": "Mars"
},
{
"question": "Who is the lead singer of the band Coldplay?",
"options": ["Chris Martin", "Bono", "Thom Yorke", "Adam Levine"],
"answer": "Chris Martin"
},
{
"question": "What is the largest country in the world by land area?",
"options": ["Russia", "Canada", "China", "United States"],
"answer": "Russia"
},
{
"question": "Which video game franchise features a character named Mario?",
"options": ["Call of Duty", "Grand Theft Auto", "Super Mario", "Assassin's Creed"],
"answer": "Super Mario"
},
{
"question": "What is the chemical formula for water?",
"options": ["H2O2", "CO2", "H2", "H2O"],
"answer": "H2O"
}
]

random.shuffle(questions) # Shuffle the questions every time the quiz is played

# Quiz loop
for i in range(total_questions):
print("\nQuestion", i+1, ":")
print(questions[i]["question"])
for j, option in enumerate(questions[i]["options"]):
print(j+1, ")", option)

answer = input("Enter your answer (1-4): ")
if answer == questions[i]["answer"]:
score += 10
print("Correct!")
else:
print("Incorrect! The correct answer is", questions[i]["answer"])

# Print final score
print("\nQuiz completed!")
print("Your final score is:", score, "out of", total_questions*10)

can you write code for At the end of the program, tell the user their score.

Certainly! Here's the updated code to display the user's score at the end of the program:

```python
# Print final score
print("\nQuiz completed!")
print("Your final score is:", score, "out of", total_questions*10)
```

This code will display the user's score out of the total possible score (which is 10 points per question).

its giving me an error code

I apologize for the error. Could you please provide me with the specific error message you are receiving? This will help me identify the issue and provide a solution.

Traceback (most recent call last):

File "/home/main.py", line 55, in <module>
print("Your final score is:", score, "1", total_questions*10)
NameError: name 'total_questions' is not defined

I apologize for the oversight. It looks like I missed defining the `total_questions` variable in the earlier code. Here's the corrected code:

```python
# Set up variables
score = 0
total_questions = len(questions) # Update to use the length of the questions list

# ...

# Print final score
print("\nQuiz completed!")
print("Your final score is:", score, "out of", total_questions*10)
```

By using `len(questions)`, we can dynamically determine the total number of questions in the list and calculate the maximum score accordingly.

Traceback (most recent call last):

File "/home/main.py", line 55, in <module>
total_questions = len(questions) # Update to use the length of the questions list
NameError: name 'questions' is not defined it says

Apologies for the confusion. It seems that the `questions` list variable is not accessible in the final part of the code.

To resolve this issue, let's move the declaration of the `total_questions` variable before the `questions` list so that it can be accessed later. Here's the updated code:

```python
# Set up variables
total_questions = 10 # Update with the total number of questions
score = 0

# List of questions and answers
questions = [
# Quiz questions here...
]

# ...

# Print final score
print("\nQuiz completed!")
print("Your final score is:", score, "out of", total_questions*10)
```

Please replace `# Quiz questions here...` with the actual list of questions and answers.

Make sure to replace `10` in `total_questions = 10` with the actual total number of questions in your quiz.