Sabir55 commited on
Commit
4d57e77
ยท
verified ยท
1 Parent(s): f95c35e

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +38 -58
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
- "options": ["Earth", "Mars", "Venus", "Jupiter"],
11
- "answer": "Mars"},
12
- {"question": "Which gas do plants absorb from the atmosphere?",
13
- "options": ["Oxygen", "Carbon Dioxide", "Nitrogen", "Hydrogen"],
14
- "answer": "Carbon Dioxide"},
15
- {"question": "What is H2O commonly known as?",
16
- "options": ["Salt", "Water", "Oxygen", "Hydrogen"],
17
- "answer": "Water"},
18
- {"question": "What part of the plant conducts photosynthesis?",
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
- "Mathematics": [
26
- {"question": "What is 12 ร— 8?",
27
- "options": ["96", "108", "88", "104"],
28
- "answer": "96"},
29
- {"question": "What is the square root of 64?",
30
- "options": ["6", "7", "8", "9"],
31
- "answer": "8"},
32
- {"question": "What comes after a billion?",
33
- "options": ["Trillion", "Million", "Quadrillion", "Thousand"],
34
- "answer": "Trillion"},
35
- {"question": "What is the value of ฯ€ (Pi) to 2 decimal places?",
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
- "Technology": [
43
- {"question": "Which company created the iPhone?",
44
- "options": ["Google", "Microsoft", "Apple", "Samsung"],
45
- "answer": "Apple"},
46
- {"question": "What does CPU stand for?",
47
- "options": ["Central Process Unit", "Central Processing Unit", "Computer Processing Unit", "Control Panel Unit"],
48
- "answer": "Central Processing Unit"},
49
- {"question": "HTML is used to create what?",
50
- "options": ["Websites", "Apps", "Games", "Databases"],
51
- "answer": "Websites"},
52
- {"question": "Which social media platform owns Instagram?",
53
- "options": ["Apple", "Google", "Meta", "Twitter"],
54
- "answer": "Meta"},
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
- # UI Setup
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 # Reset answers
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"):