import gradio as gr # Developer and School Info DEVELOPER_NAME = "Muhammad Hasaan" SCHOOL_NAME = "Smart School Larkana" # Questions Data questions = [ { "question": "1. Who is the last Prophet of Islam?", "options": ["Hazrat Musa (A.S)", "Hazrat Isa (A.S)", "Hazrat Muhammad (S.A.W)", "Hazrat Ibrahim (A.S)"], "answer": "Hazrat Muhammad (S.A.W)" }, { "question": "2. What is the Holy Book of Islam?", "options": ["Bible", "Torah", "Quran", "Zabur"], "answer": "Quran" }, { "question": "3. How many pillars of Islam are there?", "options": ["3", "4", "5", "6"], "answer": "5" }, { "question": "4. How many times do Muslims pray in a day?", "options": ["3", "4", "5", "6"], "answer": "5" }, { "question": "5. What is the first month of Islamic calendar?", "options": ["Ramzan", "Muharram", "Shaban", "Rajab"], "answer": "Muharram" }, { "question": "6. In which city was Prophet Muhammad (S.A.W) born?", "options": ["Madina", "Makkah", "Taif", "Jerusalem"], "answer": "Makkah" }, { "question": "7. What is the name of Prophet Muhammad’s (S.A.W) mother?", "options": ["Amina", "Khadija", "Fatima", "Ayesha"], "answer": "Amina" }, { "question": "8. What is Zakat?", "options": ["Prayer", "Charity", "Fasting", "Pilgrimage"], "answer": "Charity" }, { "question": "9. Which angel brought revelations to Prophet Muhammad (S.A.W)?", "options": ["Jibrael (A.S)", "Mikail (A.S)", "Israfeel (A.S)", "Izrael (A.S)"], "answer": "Jibrael (A.S)" }, { "question": "10. What is the name of the mosque in Makkah?", "options": ["Masjid e Nabvi", "Masjid e Aqsa", "Masjid al Haram", "Quba Mosque"], "answer": "Masjid al Haram" }, { "question": "11. What is fasting called in Islam?", "options": ["Hajj", "Sawm", "Zakat", "Shahada"], "answer": "Sawm" }, { "question": "12. Which month do Muslims fast?", "options": ["Muharram", "Ramzan", "Rajab", "Shaban"], "answer": "Ramzan" }, { "question": "13. What is the declaration of faith called?", "options": ["Salah", "Shahada", "Zakat", "Hajj"], "answer": "Shahada" }, { "question": "14. How many Rakats are in Fajr prayer?", "options": ["2", "3", "4", "5"], "answer": "2" }, { "question": "15. Who was the first Caliph of Islam?", "options": ["Hazrat Umar (R.A)", "Hazrat Usman (R.A)", "Hazrat Ali (R.A)", "Hazrat Abu Bakr (R.A)"], "answer": "Hazrat Abu Bakr (R.A)" }, { "question": "16. What is Hajj?", "options": ["Prayer", "Charity", "Pilgrimage", "Fasting"], "answer": "Pilgrimage" }, { "question": "17. What is the night of power called?", "options": ["Shab e Barat", "Laylatul Qadr", "Shab e Miraj", "Eid Night"], "answer": "Laylatul Qadr" }, { "question": "18. How many Surahs are in the Quran?", "options": ["110", "112", "114", "116"], "answer": "114" }, { "question": "19. What is the migration of Prophet (S.A.W) called?", "options": ["Hijrah", "Jihad", "Fatah", "Dawah"], "answer": "Hijrah" }, { "question": "20. What is the second pillar of Islam?", "options": ["Salah", "Zakat", "Hajj", "Sawm"], "answer": "Salah" } ] def evaluate(*answers): score = 0 for i, answer in enumerate(answers): if answer == questions[i]["answer"]: score += 1 result = f""" 📘 Islamiat Test Result 👨‍💻 Developer: {DEVELOPER_NAME} 🏫 School: {SCHOOL_NAME} ✅ Your Score: {score} / 20 """ return result # Creating Gradio Interface inputs = [] for q in questions: inputs.append(gr.Radio(q["options"], label=q["question"])) interface = gr.Interface( fn=evaluate, inputs=inputs, outputs="text", title="Class 5 Islamiat Test", description=f"Developed by {DEVELOPER_NAME} | {SCHOOL_NAME}" ) if __name__ == "__main__": interface.launch()