🏠 Home 📚 Chapters 💻 Projects ℹ️ About
HomeProjects › Day 24
DAY 24 — 60 DAY PYTHON CHALLENGE

💻 Quiz Game

Python में Quiz Game — General Knowledge Quiz

Advertisement

Project kya hai?

Day 24 ka project hai Quiz Game! Neeche complete code hai — copy karo aur chalao!

Complete Python Code

python — quiz.py
questions = [
    {
        "q":    "Python mein list banana ka sahi tarika kya hai?",
        "opts": ["list = ()", "list = []", "list = {}", "list = <>"],
        "ans":  1,
        "exp":  "Square brackets [] se list banti hai!"
    },
    {
        "q":    "print() function kya karta hai?",
        "opts": ["Input leta hai", "Screen par dikhata hai", "Calculate karta hai", "File save karta hai"],
        "ans":  1,
        "exp":  "print() screen par output dikhata hai."
    },
    {
        "q":    "Python mein comment kaise likhte hain?",
        "opts": ["// comment", "/* comment */", "# comment", "-- comment"],
        "ans":  2,
        "exp":  "# se single line comment hota hai."
    },
    {
        "q":    "for i in range(3) loop kitni baar chalta hai?",
        "opts": ["2 baar", "3 baar", "4 baar", "1 baar"],
        "ans":  1,
        "exp":  "range(3) = 0,1,2 - teen values!"
    },
    {
        "q":    "len('Python') ki value kya hai?",
        "opts": ["5", "6", "7", "8"],
        "ans":  1,
        "exp":  "Python mein 6 characters hain: P-y-t-h-o-n"
    },
]

import random
random.shuffle(questions)

print("=== Python Quiz Game ===")
print(f"Total: {len(questions)} questions
")

score = 0
for i, q in enumerate(questions, 1):
    print(f"Q{i}: {q['q']}")
    for j, opt in enumerate(q['opts']):
        print(f"   {j}. {opt}")
    try:
        ans = int(input("Answer (0-3): "))
        if ans == q['ans']:
            print("  SAHI HAI!")
            score += 1
        else:
            print(f"  Galat! Sahi jawab: {q['opts'][q['ans']]}")
        print(f"  Explanation: {q['exp']}
")
    except:
        print("  Invalid input!
")

print(f"
=== Result ===")
print(f"Score: {score}/{len(questions)}")
pct = score/len(questions)*100
if pct == 100:   print("Perfect! Aap Python expert hain!")
elif pct >= 60:  print("Accha kiya! Aur practice karo.")
else:            print("Mehnat karo! Aap kar sakte hain!")
OUTPUT
=== Python Quiz Game ===
Total: 5 questions

Q1: Python mein list banana ka sahi tarika?
   0. list = ()
   1. list = []
Answer: 1
  SAHI HAI!

=== Result ===
Score: 4/5
Accha kiya!

Code kaise kaam karta hai?

List of dicts se questions store hote hain. random.shuffle() se har baar alag order milta hai. Explanation se concept clear hota hai.
Advertisement

📋 Project ka Introduction

Quiz Game Python ka Day 24 ka project hai. Is project mein aap Python ke important concepts practice karenge jo real-world applications mein bahut use hote hain.

Yeh project beginners ke liye design kiya gaya hai lekin kaafi concepts cover karta hai. Step by step samjho, code chalao, aur khud modify karke practice karo.

Is tarah ke projects banane se aapka Python confidence badh jaata hai aur aap asli problems solve karna seekh jaate hain. Chaliye code samjhte hain!

🧠 Is Project mein kya seekhoge?

Yeh project banate waqt aap ye Python concepts use karoge:
ConceptKya karta hai
VariablesData store karna
FunctionsReusable code blocks
LoopsRepeat karna
ConditionsDecisions lena
Input/OutputUser se interact karna

📝 Code kaise kaam karta hai — Step by Step

Neeche code ki poori logic step-by-step samjhayi gayi hai:
  1. Problem samjho: Quiz Game mein kya karna hai
  2. Required variables aur data structures decide karo
  3. Logic step-by-step likhó
  4. Code mein implement karo
  5. Test karo aur bugs fix karo

⚠️ Common Mistakes — Bhool mat jaana!

Beginners yeh galtiyan aksar karte hain — dhyan rakho:
  • ⚠️ Indentation sahi rakho — Python mein spaces matter karti hain
  • ⚠️ Variables ko use se pehle define karo
  • ⚠️ Input ko int()/float() mein convert karo agar number chahiye
  • ⚠️ Edge cases handle karo — kya hoga agar user galat input de?

🏋️ Practice Exercises — Aage badho!

Yeh project complete karne ke baad in exercises se practice karo:
  • 💡 Quiz Game mein naya feature add karo
  • 💡 Code ko functions mein refactor karo
  • 💡 Error handling improve karo
  • 💡 File mein data save karo

❓ Aksar Pooche Jane Wale Sawal (FAQ)

Q: Quiz Game project kyon banana chahiye?

A: Har project ek naya concept sikhata hai. Practice se hi Python fluent aati hai.
Q: Code run nahi ho raha?

A: Indentation check karo, syntax errors dekho, variables define hain ya nahi check karo.
Q: Kaise improve karein?

A: Pehle basic version complete karo, phir ek ek feature add karte jao.
🏠 📋 Projects Day 25 →