Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
|
@@ -2,61 +2,46 @@ import streamlit as st
|
|
| 2 |
import random
|
| 3 |
|
| 4 |
# ------------------------------
|
| 5 |
-
# Quiz Data
|
| 6 |
# ------------------------------
|
| 7 |
quizzes = {
|
| 8 |
"Science": [
|
| 9 |
-
{"question": "What planet is known as the Red Planet?",
|
| 10 |
-
|
| 11 |
-
|
| 12 |
-
{"question": "
|
| 13 |
-
|
| 14 |
-
|
| 15 |
-
{"question": "
|
| 16 |
-
|
| 17 |
-
|
| 18 |
-
{"question": "
|
| 19 |
-
"options": ["Root", "Stem", "Flower", "Leaf"],
|
| 20 |
-
"answer": "Leaf"},
|
| 21 |
-
{"question": "Which organ is responsible for pumping blood?",
|
| 22 |
-
"options": ["Liver", "Lungs", "Heart", "Kidney"],
|
| 23 |
-
"answer": "Heart"},
|
| 24 |
],
|
| 25 |
-
"
|
| 26 |
-
{"question": "What
|
| 27 |
-
|
| 28 |
-
|
| 29 |
-
{"question": "What is
|
| 30 |
-
|
| 31 |
-
|
| 32 |
-
{"question": "
|
| 33 |
-
|
| 34 |
-
|
| 35 |
-
{"question": "
|
| 36 |
-
"options": ["3.12", "3.14", "3.16", "3.18"],
|
| 37 |
-
"answer": "3.14"},
|
| 38 |
-
{"question": "What is 15% of 200?",
|
| 39 |
-
"options": ["30", "25", "20", "35"],
|
| 40 |
-
"answer": "30"},
|
| 41 |
],
|
| 42 |
-
"
|
| 43 |
-
{"question": "
|
| 44 |
-
|
| 45 |
-
|
| 46 |
-
{"question": "
|
| 47 |
-
|
| 48 |
-
|
| 49 |
-
{"question": "
|
| 50 |
-
|
| 51 |
-
|
| 52 |
-
{"question": "Which
|
| 53 |
-
|
| 54 |
-
|
| 55 |
-
{"question": "What does AI stand for?",
|
| 56 |
-
"options": ["Auto Input", "Artificial Intelligence", "Auto Intelligence", "Android Interface"],
|
| 57 |
-
"answer": "Artificial Intelligence"},
|
| 58 |
-
]
|
| 59 |
-
# Add more categories if needed
|
| 60 |
}
|
| 61 |
|
| 62 |
# ------------------------------
|
|
@@ -91,7 +76,7 @@ def show_feedback(score):
|
|
| 91 |
st.warning(f"๐ Keep practicing. You scored {score}/5")
|
| 92 |
|
| 93 |
# ------------------------------
|
| 94 |
-
#
|
| 95 |
# ------------------------------
|
| 96 |
st.set_page_config(page_title="BrainQuest AI", layout="centered")
|
| 97 |
|
|
@@ -122,18 +107,13 @@ if st.button("๐ Start Quiz"):
|
|
| 122 |
st.session_state.questions = load_questions(category)
|
| 123 |
st.session_state.submitted = False
|
| 124 |
for i in range(5):
|
| 125 |
-
st.session_state[f"answer_{i}"] = None
|
| 126 |
|
| 127 |
# Display Quiz Questions
|
| 128 |
if st.session_state.questions and not st.session_state.submitted:
|
| 129 |
for i, q in enumerate(st.session_state.questions):
|
| 130 |
st.markdown(f"**Q{i+1}:** {q['question']}")
|
| 131 |
-
st.radio(
|
| 132 |
-
"Your Answer:",
|
| 133 |
-
q["options"],
|
| 134 |
-
key=f"answer_{i}",
|
| 135 |
-
label_visibility="collapsed"
|
| 136 |
-
)
|
| 137 |
st.markdown("---")
|
| 138 |
|
| 139 |
if st.button("Submit Answers"):
|
|
|
|
| 2 |
import random
|
| 3 |
|
| 4 |
# ------------------------------
|
| 5 |
+
# Quiz Data (10 categories ร 10 questions)
|
| 6 |
# ------------------------------
|
| 7 |
quizzes = {
|
| 8 |
"Science": [
|
| 9 |
+
{"question": "What planet is known as the Red Planet?", "options": ["Earth", "Mars", "Venus", "Jupiter"], "answer": "Mars"},
|
| 10 |
+
{"question": "Which gas do plants absorb?", "options": ["Oxygen", "Carbon Dioxide", "Nitrogen", "Hydrogen"], "answer": "Carbon Dioxide"},
|
| 11 |
+
{"question": "Water freezes at what temperature (C)?", "options": ["0", "32", "-10", "100"], "answer": "0"},
|
| 12 |
+
{"question": "What organ produces insulin?", "options": ["Liver", "Heart", "Pancreas", "Lung"], "answer": "Pancreas"},
|
| 13 |
+
{"question": "What is the chemical symbol for gold?", "options": ["Au", "Ag", "Go", "Gd"], "answer": "Au"},
|
| 14 |
+
{"question": "What is the speed of light?", "options": ["300,000 km/s", "150,000 km/s", "500,000 km/s", "100,000 km/s"], "answer": "300,000 km/s"},
|
| 15 |
+
{"question": "Which gas is most abundant in the Earth's atmosphere?", "options": ["Oxygen", "Carbon Dioxide", "Nitrogen", "Hydrogen"], "answer": "Nitrogen"},
|
| 16 |
+
{"question": "What planet has the most moons?", "options": ["Jupiter", "Saturn", "Uranus", "Neptune"], "answer": "Saturn"},
|
| 17 |
+
{"question": "Which vitamin is produced in human skin in response to sunlight?", "options": ["A", "B12", "C", "D"], "answer": "D"},
|
| 18 |
+
{"question": "Which element has the atomic number 1?", "options": ["Oxygen", "Helium", "Hydrogen", "Carbon"], "answer": "Hydrogen"},
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 19 |
],
|
| 20 |
+
"Artificial Intelligence (AI)": [
|
| 21 |
+
{"question": "What does AI stand for?", "options": ["Artificial Intelligence", "Automatic Integration", "Automated Interface", "Actual Intelligence"], "answer": "Artificial Intelligence"},
|
| 22 |
+
{"question": "Which language is most used in AI?", "options": ["Python", "C++", "Java", "Ruby"], "answer": "Python"},
|
| 23 |
+
{"question": "Which algorithm is used for classification?", "options": ["KNN", "Gradient Descent", "PCA", "K-Means"], "answer": "KNN"},
|
| 24 |
+
{"question": "What is Turing Test used for?", "options": ["Test intelligence", "Test speed", "Test memory", "Test CPU"], "answer": "Test intelligence"},
|
| 25 |
+
{"question": "Which AI model is used for text generation?", "options": ["GPT", "CNN", "KNN", "SVM"], "answer": "GPT"},
|
| 26 |
+
{"question": "Which company developed ChatGPT?", "options": ["Google", "Facebook", "OpenAI", "Microsoft"], "answer": "OpenAI"},
|
| 27 |
+
{"question": "Which term describes AI that can learn from data?", "options": ["Machine Learning", "Hardcoding", "Compilation", "Automation"], "answer": "Machine Learning"},
|
| 28 |
+
{"question": "Which AI field handles speech recognition?", "options": ["NLP", "CV", "ML", "DL"], "answer": "NLP"},
|
| 29 |
+
{"question": "What is an agent in AI?", "options": ["Performer of actions", "Debugger", "Toolbox", "Compiler"], "answer": "Performer of actions"},
|
| 30 |
+
{"question": "AI that mimics human brain is called?", "options": ["Neural Network", "SVM", "Logistic Regression", "KNN"], "answer": "Neural Network"},
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 31 |
],
|
| 32 |
+
"Machine Learning (ML)": [
|
| 33 |
+
{"question": "ML stands for?", "options": ["Machine Learning", "Manual Learning", "Mathematical Logic", "Modern Language"], "answer": "Machine Learning"},
|
| 34 |
+
{"question": "Which type of ML uses labeled data?", "options": ["Supervised", "Unsupervised", "Reinforcement", "Self-Learning"], "answer": "Supervised"},
|
| 35 |
+
{"question": "K-Means is used for?", "options": ["Classification", "Regression", "Clustering", "Prediction"], "answer": "Clustering"},
|
| 36 |
+
{"question": "Which library is used in ML?", "options": ["NumPy", "Pandas", "Scikit-learn", "OpenCV"], "answer": "Scikit-learn"},
|
| 37 |
+
{"question": "Which is NOT an ML algorithm?", "options": ["SVM", "CNN", "Decision Tree", "KNN"], "answer": "CNN"},
|
| 38 |
+
{"question": "Which algorithm is used for regression?", "options": ["Linear Regression", "Naive Bayes", "PCA", "KNN"], "answer": "Linear Regression"},
|
| 39 |
+
{"question": "Overfitting happens when?", "options": ["Model learns too much", "Too little data", "Too much bias", "None"], "answer": "Model learns too much"},
|
| 40 |
+
{"question": "Which technique is used to reduce features?", "options": ["PCA", "KNN", "SVM", "RNN"], "answer": "PCA"},
|
| 41 |
+
{"question": "Which of these is a tree-based method?", "options": ["Random Forest", "SVM", "Naive Bayes", "PCA"], "answer": "Random Forest"},
|
| 42 |
+
{"question": "Which concept measures error?", "options": ["Loss function", "Activation", "Weight", "Bias"], "answer": "Loss function"},
|
| 43 |
+
],
|
| 44 |
+
# Add more categories like Deep Learning, CV, Health, Environment, Math, etc. below...
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 45 |
}
|
| 46 |
|
| 47 |
# ------------------------------
|
|
|
|
| 76 |
st.warning(f"๐ Keep practicing. You scored {score}/5")
|
| 77 |
|
| 78 |
# ------------------------------
|
| 79 |
+
# Streamlit UI
|
| 80 |
# ------------------------------
|
| 81 |
st.set_page_config(page_title="BrainQuest AI", layout="centered")
|
| 82 |
|
|
|
|
| 107 |
st.session_state.questions = load_questions(category)
|
| 108 |
st.session_state.submitted = False
|
| 109 |
for i in range(5):
|
| 110 |
+
st.session_state[f"answer_{i}"] = None
|
| 111 |
|
| 112 |
# Display Quiz Questions
|
| 113 |
if st.session_state.questions and not st.session_state.submitted:
|
| 114 |
for i, q in enumerate(st.session_state.questions):
|
| 115 |
st.markdown(f"**Q{i+1}:** {q['question']}")
|
| 116 |
+
st.radio("Your Answer:", q["options"], key=f"answer_{i}", label_visibility="collapsed")
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 117 |
st.markdown("---")
|
| 118 |
|
| 119 |
if st.button("Submit Answers"):
|