Create app.py
Browse files
app.py
ADDED
@@ -0,0 +1,36 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
# Required libraries
|
2 |
+
import streamlit as st
|
3 |
+
import pandas as pd
|
4 |
+
|
5 |
+
# Reading the CSV file
|
6 |
+
@st.cache_data
|
7 |
+
def load_data():
|
8 |
+
data = pd.read_csv('questions_working.csv')
|
9 |
+
return data
|
10 |
+
|
11 |
+
data = load_data()
|
12 |
+
|
13 |
+
# Filter questions by levels
|
14 |
+
easy_questions = data[data['Level'] == 'Easy']
|
15 |
+
very_easy_questions = data[data['Level'] == 'Very Easy']
|
16 |
+
moderate_questions = data[data['Level'] == 'Moderate']
|
17 |
+
|
18 |
+
# Create columns for the selection boxes
|
19 |
+
col1, col2, col3, col4 = st.columns(4)
|
20 |
+
|
21 |
+
# Display selection boxes in columns
|
22 |
+
easy_selection_1 = col1.selectbox('Choose an Easy Question (1):', easy_questions['ID'].tolist())
|
23 |
+
easy_selection_2 = col2.selectbox('Choose an Easy Question (2):', easy_questions['ID'].tolist())
|
24 |
+
very_easy_selection = col3.selectbox('Choose a Very Easy Question:', very_easy_questions['ID'].tolist())
|
25 |
+
moderate_selection = col4.selectbox('Choose a Moderate Question:', moderate_questions['ID'].tolist())
|
26 |
+
|
27 |
+
|
28 |
+
# If button is pressed, display the answers
|
29 |
+
if st.button('Show Answers'):
|
30 |
+
selections = [easy_selection_1, easy_selection_2, very_easy_selection, moderate_selection]
|
31 |
+
for selected_id in selections:
|
32 |
+
question_row = data[data['ID'] == selected_id].iloc[0]
|
33 |
+
st.markdown('---') # Draw a horizontal line
|
34 |
+
st.write(f"**Question (ID: {question_row['ID']}):** {question_row['Question']}")
|
35 |
+
st.write(f"**Answer:** {question_row['Answer']}")
|
36 |
+
|