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larkana"
|
| 6 |
+
|
| 7 |
+
# Questions Data
|
| 8 |
+
questions = [
|
| 9 |
+
{
|
| 10 |
+
"question": "1. Who is the last Prophet of Islam?",
|
| 11 |
+
"options": ["Hazrat Musa (A.S)", "Hazrat Isa (A.S)", "Hazrat Muhammad (S.A.W)", "Hazrat Ibrahim (A.S)"],
|
| 12 |
+
"answer": "Hazrat Muhammad (S.A.W)"
|
| 13 |
+
},
|
| 14 |
+
{
|
| 15 |
+
"question": "2. What is the Holy Book of Islam?",
|
| 16 |
+
"options": ["Bible", "Torah", "Quran", "Zabur"],
|
| 17 |
+
"answer": "Quran"
|
| 18 |
+
},
|
| 19 |
+
{
|
| 20 |
+
"question": "3. How many pillars of Islam are there?",
|
| 21 |
+
"options": ["3", "4", "5", "6"],
|
| 22 |
+
"answer": "5"
|
| 23 |
+
},
|
| 24 |
+
{
|
| 25 |
+
"question": "4. How many times do Muslims pray in a day?",
|
| 26 |
+
"options": ["3", "4", "5", "6"],
|
| 27 |
+
"answer": "5"
|
| 28 |
+
},
|
| 29 |
+
{
|
| 30 |
+
"question": "5. What is the first month of Islamic calendar?",
|
| 31 |
+
"options": ["Ramzan", "Muharram", "Shaban", "Rajab"],
|
| 32 |
+
"answer": "Muharram"
|
| 33 |
+
},
|
| 34 |
+
{
|
| 35 |
+
"question": "6. In which city was Prophet Muhammad (S.A.W) born?",
|
| 36 |
+
"options": ["Madina", "Makkah", "Taif", "Jerusalem"],
|
| 37 |
+
"answer": "Makkah"
|
| 38 |
+
},
|
| 39 |
+
{
|
| 40 |
+
"question": "7. What is the name of Prophet Muhammad’s (S.A.W) mother?",
|
| 41 |
+
"options": ["Amina", "Khadija", "Fatima", "Ayesha"],
|
| 42 |
+
"answer": "Amina"
|
| 43 |
+
},
|
| 44 |
+
{
|
| 45 |
+
"question": "8. What is Zakat?",
|
| 46 |
+
"options": ["Prayer", "Charity", "Fasting", "Pilgrimage"],
|
| 47 |
+
"answer": "Charity"
|
| 48 |
+
},
|
| 49 |
+
{
|
| 50 |
+
"question": "9. Which angel brought revelations to Prophet Muhammad (S.A.W)?",
|
| 51 |
+
"options": ["Jibrael (A.S)", "Mikail (A.S)", "Israfeel (A.S)", "Izrael (A.S)"],
|
| 52 |
+
"answer": "Jibrael (A.S)"
|
| 53 |
+
},
|
| 54 |
+
{
|
| 55 |
+
"question": "10. What is the name of the mosque in Makkah?",
|
| 56 |
+
"options": ["Masjid e Nabvi", "Masjid e Aqsa", "Masjid al Haram", "Quba Mosque"],
|
| 57 |
+
"answer": "Masjid al Haram"
|
| 58 |
+
},
|
| 59 |
+
{
|
| 60 |
+
"question": "11. What is fasting called in Islam?",
|
| 61 |
+
"options": ["Hajj", "Sawm", "Zakat", "Shahada"],
|
| 62 |
+
"answer": "Sawm"
|
| 63 |
+
},
|
| 64 |
+
{
|
| 65 |
+
"question": "12. Which month do Muslims fast?",
|
| 66 |
+
"options": ["Muharram", "Ramzan", "Rajab", "Shaban"],
|
| 67 |
+
"answer": "Ramzan"
|
| 68 |
+
},
|
| 69 |
+
{
|
| 70 |
+
"question": "13. What is the declaration of faith called?",
|
| 71 |
+
"options": ["Salah", "Shahada", "Zakat", "Hajj"],
|
| 72 |
+
"answer": "Shahada"
|
| 73 |
+
},
|
| 74 |
+
{
|
| 75 |
+
"question": "14. How many Rakats are in Fajr prayer?",
|
| 76 |
+
"options": ["2", "3", "4", "5"],
|
| 77 |
+
"answer": "2"
|
| 78 |
+
},
|
| 79 |
+
{
|
| 80 |
+
"question": "15. Who was the first Caliph of Islam?",
|
| 81 |
+
"options": ["Hazrat Umar (R.A)", "Hazrat Usman (R.A)", "Hazrat Ali (R.A)", "Hazrat Abu Bakr (R.A)"],
|
| 82 |
+
"answer": "Hazrat Abu Bakr (R.A)"
|
| 83 |
+
},
|
| 84 |
+
{
|
| 85 |
+
"question": "16. What is Hajj?",
|
| 86 |
+
"options": ["Prayer", "Charity", "Pilgrimage", "Fasting"],
|
| 87 |
+
"answer": "Pilgrimage"
|
| 88 |
+
},
|
| 89 |
+
{
|
| 90 |
+
"question": "17. What is the night of power called?",
|
| 91 |
+
"options": ["Shab e Barat", "Laylatul Qadr", "Shab e Miraj", "Eid Night"],
|
| 92 |
+
"answer": "Laylatul Qadr"
|
| 93 |
+
},
|
| 94 |
+
{
|
| 95 |
+
"question": "18. How many Surahs are in the Quran?",
|
| 96 |
+
"options": ["110", "112", "114", "116"],
|
| 97 |
+
"answer": "114"
|
| 98 |
+
},
|
| 99 |
+
{
|
| 100 |
+
"question": "19. What is the migration of Prophet (S.A.W) called?",
|
| 101 |
+
"options": ["Hijrah", "Jihad", "Fatah", "Dawah"],
|
| 102 |
+
"answer": "Hijrah"
|
| 103 |
+
},
|
| 104 |
+
{
|
| 105 |
+
"question": "20. What is the second pillar of Islam?",
|
| 106 |
+
"options": ["Salah", "Zakat", "Hajj", "Sawm"],
|
| 107 |
+
"answer": "Salah"
|
| 108 |
+
}
|
| 109 |
+
]
|
| 110 |
+
|
| 111 |
+
def evaluate(*answers):
|
| 112 |
+
score = 0
|
| 113 |
+
for i, answer in enumerate(answers):
|
| 114 |
+
if answer == questions[i]["answer"]:
|
| 115 |
+
score += 1
|
| 116 |
+
|
| 117 |
+
result = f"""
|
| 118 |
+
📘 Islamiat Test Result
|
| 119 |
+
|
| 120 |
+
👨💻 Developer: {DEVELOPER_NAME}
|
| 121 |
+
🏫 School: {SCHOOL_NAME}
|
| 122 |
+
|
| 123 |
+
✅ Your Score: {score} / 20
|
| 124 |
+
|
| 125 |
+
"""
|
| 126 |
+
return result
|
| 127 |
+
|
| 128 |
+
# Creating Gradio Interface
|
| 129 |
+
inputs = []
|
| 130 |
+
for q in questions:
|
| 131 |
+
inputs.append(gr.Radio(q["options"], label=q["question"]))
|
| 132 |
+
|
| 133 |
+
interface = gr.Interface(
|
| 134 |
+
fn=evaluate,
|
| 135 |
+
inputs=inputs,
|
| 136 |
+
outputs="text",
|
| 137 |
+
title="Class 5 Islamiat Test",
|
| 138 |
+
description=f"Developed by {DEVELOPER_NAME} | {SCHOOL_NAME}"
|
| 139 |
+
)
|
| 140 |
+
|
| 141 |
+
if __name__ == "__main__":
|
| 142 |
+
interface.launch()
|