📌 Project Overview
In this project, you will create a Python quiz containing multiple questions. The program will check each answer and display the final score.
What you will learn:
- Using lists
- Taking user input
- Using loops
- Using if-else
- Counting scores
🎯 How the Quiz Works
1
Show question
2
Get answer
3
Check answer
4
Calculate score
Step 1: Create Questions
Store questions and answers in Python lists.
Python
questions = [
"What is the capital of India?",
"Which language are we learning?",
"What is 5 + 5?"
]
answers = [
"delhi",
"python",
"10"
]
Step 2: Create the Score
Python
score = 0
Step 3: Ask Questions
Use a loop to go through every question.
Python
for i in range(len(questions)):
print(questions[i])
user_answer = input("Your answer: ")
Step 4: Check the Answer
Python
if user_answer.lower() == answers[i]:
print("Correct!")
score += 1
else:
print("Wrong!")
🚀 Complete Python Code
quiz.py
questions = [
"What is the capital of India?",
"Which language are we learning?",
"What is 5 + 5?",
"Which keyword is used to define a function?",
"Which symbol is used for comments?"
]
answers = [
"delhi",
"python",
"10",
"def",
"#"
]
score = 0
print("===== PYTHON QUIZ =====")
for i in range(len(questions)):
print()
print("Question", i + 1)
print(questions[i])
user_answer = input("Your answer: ")
if user_answer.lower() == answers[i]:
print("Correct! 🎉")
score += 1
else:
print("Wrong!")
print()
print("===== QUIZ COMPLETE =====")
print("Your Score:",
score,
"/",
len(questions))
💻 Example Output
===== PYTHON QUIZ ===== Question 1 What is the capital of India? Your answer: Delhi Correct! 🎉 Question 2 Which language are we learning? Your answer: Python Correct! 🎉 Question 3 What is 5 + 5? Your answer: 8 Wrong! ===== QUIZ COMPLETE ===== Your Score: 2 / 5
🧠 Mini Challenge
Improve your quiz by adding:
- Multiple-choice questions
- 10 or more questions
- Different difficulty levels
- Percentage score
- Correct answer display
- Play again option
🎉 First Project Collection Complete!
You have now learned how to build four beginner Python projects using the concepts from PyStep.
Completed Projects:
- 🧮 Calculator
- 🎯 Number Guessing Game
- 📝 To-Do List
- ❓ Quiz App
🧠 Try the Python Quiz
Answer the questions and test your Python knowledge.
Question 1 of 5
Score: 0