Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
84 changes: 84 additions & 0 deletions Domains/CompetitiveProgramming/Programs/Python/quiz/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,84 @@
contributer Anushka2726
📋 Description

This is a Simple Quiz App built using Python.
It asks the user multiple-choice questions, takes their input (A/B/C/D), and calculates the final score at the end.
It’s a perfect beginner-friendly project to practice loops, conditionals, and lists/dictionaries in Python.

🚀 Features

✅ Multiple-choice questions
✅ Instant feedback (Correct/Wrong)
✅ Score counter
✅ Easy to modify or expand with new questions

🧩 How It Works

The quiz questions are stored in a list of dictionaries.

Each question dictionary includes:

"question" → the question text

"options" → list of answer choices

"answer" → correct option (A, B, C, or D)

The program displays one question at a time.

The user inputs their answer.

The app checks if the answer is correct and keeps track of the score.

At the end, it shows your total score.

🖥️ Example Output
1. What is the capital of France?
A. Berlin
B. Madrid
C. Paris
D. Rome
Enter your answer (A/B/C/D): c
✅ Correct!

2. Which language is used for web apps?
A. Python
B. JavaScript
C. HTML
D. All of the above
Enter your answer (A/B/C/D): d
✅ Correct!

🎯 You got 2 out of 2 correct!

🧰 Requirements

Python 3.x
(No external libraries required)

▶️ How to Run

Copy the code into a file named quiz_app.py

Open a terminal or command prompt.

Run the script:

python quiz_app.py


Answer each question by typing A, B, C, or D, and press Enter.

🧠 Future Improvements

Add more questions from a text or JSON file.

Randomize question order using random.shuffle().

Add timer functionality.

Create a GUI version using tkinter.

Save user scores to a file.


51 changes: 51 additions & 0 deletions Domains/CompetitiveProgramming/Programs/Python/quiz/quiz.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
# Simple Quiz App in Python

def run_quiz(questions):
score = 0
for q in questions:
print("\n" + q["question"])
for option in q["options"]:
print(option)
answer = input("Enter your answer (A/B/C/D): ").upper()
if answer == q["answer"]:
print("✅ Correct!")
score += 1
else:
print(f"❌ Wrong! Correct answer is {q['answer']}")
print("\n🎯 You got", score, "out of", len(questions), "correct!")


# List of questions
questions = [
{
"question": "1. What is the capital of France?",
"options": ["A. Berlin", "B. Madrid", "C. Paris", "D. Rome"],
"answer": "C"
},
{
"question": "2. Which language is used for web apps?",
"options": ["A. Python", "B. JavaScript", "C. HTML", "D. All of the above"],
"answer": "D"
},
{
"question": "3. What is 5 + 7?",
"options": ["A. 10", "B. 12", "C. 14", "D. 15"],
"answer": "B"
},
{
"question": "4. Who developed Python?",
"options": ["A. Guido van Rossum", "B. Elon Musk", "C. Bill Gates", "D. Mark Zuckerberg"],
"answer": "A"
},
{
"question": "5. What does HTML stand for?",
"options": ["A. Hyper Trainer Marking Language",
"B. Hyper Text Markup Language",
"C. Hyper Text Marketing Language",
"D. None of these"],
"answer": "B"
}
]

# Run the quiz
run_quiz(questions)
Loading