Spaces:
Runtime error
Runtime error
Update app.py
Browse files
app.py
CHANGED
|
@@ -207,36 +207,51 @@ def link_button_with_emoji(url, title, emoji_summary):
|
|
| 207 |
|
| 208 |
# Python parts and their corresponding emojis, with expanded details
|
| 209 |
python_parts = {
|
| 210 |
-
"
|
| 211 |
-
"
|
| 212 |
-
"
|
| 213 |
-
"
|
| 214 |
-
"
|
| 215 |
-
"
|
| 216 |
-
"
|
|
|
|
| 217 |
"Libraries": "π"
|
| 218 |
}
|
| 219 |
|
| 220 |
python_parts_extended = {
|
| 221 |
-
"
|
| 222 |
-
"
|
| 223 |
-
"
|
| 224 |
-
"
|
| 225 |
-
"
|
| 226 |
-
"
|
| 227 |
-
"
|
| 228 |
-
"
|
|
|
|
| 229 |
}
|
| 230 |
|
| 231 |
-
# Placeholder for chat responses
|
| 232 |
response_placeholders = {}
|
|
|
|
| 233 |
|
| 234 |
-
# Function to display Python concepts with expanders and
|
| 235 |
def display_python_parts():
|
| 236 |
-
st.title("Python
|
| 237 |
-
|
| 238 |
-
for part in python_parts.
|
| 239 |
-
with st.expander(f"{part}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 240 |
prompt = f"Learn about {python_parts_extended[part]}"
|
| 241 |
if st.button(f"Explore {part}", key=part):
|
| 242 |
response = chat_with_model(prompt, part)
|
|
@@ -246,13 +261,22 @@ def display_python_parts():
|
|
| 246 |
if part in response_placeholders:
|
| 247 |
st.markdown(f"**Response:** {response_placeholders[part]}")
|
| 248 |
|
|
|
|
|
|
|
|
|
|
|
|
|
| 249 |
|
|
|
|
|
|
|
|
|
|
|
|
|
| 250 |
|
| 251 |
# Define function to add paper buttons and links
|
| 252 |
def add_paper_buttons_and_links():
|
| 253 |
# Python Pair Programmer
|
| 254 |
page = st.sidebar.radio("Choose a page:", ["Python Pair Programmer"])
|
| 255 |
if page == "Python Pair Programmer":
|
|
|
|
| 256 |
display_python_parts()
|
| 257 |
|
| 258 |
|
|
|
|
| 207 |
|
| 208 |
# Python parts and their corresponding emojis, with expanded details
|
| 209 |
python_parts = {
|
| 210 |
+
"Syntax": "βοΈ",
|
| 211 |
+
"Data Types": "π",
|
| 212 |
+
"Control Structures": "π",
|
| 213 |
+
"Functions": "π§",
|
| 214 |
+
"Classes": "ποΈ",
|
| 215 |
+
"API Interaction": "π",
|
| 216 |
+
"Data Visualization": "π",
|
| 217 |
+
"Error Handling": "β οΈ",
|
| 218 |
"Libraries": "π"
|
| 219 |
}
|
| 220 |
|
| 221 |
python_parts_extended = {
|
| 222 |
+
"Syntax": "βοΈ (Variables, Comments, Printing)",
|
| 223 |
+
"Data Types": "π (Numbers, Strings, Lists, Tuples, Sets, Dictionaries)",
|
| 224 |
+
"Control Structures": "π (If, Elif, Else, Loops, Break, Continue)",
|
| 225 |
+
"Functions": "π§ (Defining, Calling, Parameters, Return Values)",
|
| 226 |
+
"Classes": "ποΈ (Creating, Inheritance, Methods, Properties)",
|
| 227 |
+
"API Interaction": "π (Requests, JSON Parsing, HTTP Methods)",
|
| 228 |
+
"Data Visualization": "π (Matplotlib, Seaborn, Plotly)",
|
| 229 |
+
"Error Handling": "β οΈ (Try, Except, Finally, Raising)",
|
| 230 |
+
"Libraries": "π (Numpy, Pandas, Scikit-Learn, TensorFlow)"
|
| 231 |
}
|
| 232 |
|
| 233 |
+
# Placeholder for chat responses and interactive examples
|
| 234 |
response_placeholders = {}
|
| 235 |
+
example_placeholders = {}
|
| 236 |
|
| 237 |
+
# Function to display Python concepts with expanders, examples, and quizzes
|
| 238 |
def display_python_parts():
|
| 239 |
+
st.title("Python Interactive Learning Platform")
|
| 240 |
+
|
| 241 |
+
for part, emoji in python_parts.items():
|
| 242 |
+
with st.expander(f"{emoji} {part} - {python_parts_extended[part]}", expanded=False):
|
| 243 |
+
# Interactive examples
|
| 244 |
+
if st.button(f"Show Example for {part}", key=f"example_{part}"):
|
| 245 |
+
example = generate_example(part)
|
| 246 |
+
example_placeholders[part] = example
|
| 247 |
+
st.code(example_placeholders[part], language="python")
|
| 248 |
+
|
| 249 |
+
# Quizzes
|
| 250 |
+
if st.button(f"Take Quiz on {part}", key=f"quiz_{part}"):
|
| 251 |
+
quiz = generate_quiz(part)
|
| 252 |
+
st.write(quiz)
|
| 253 |
+
|
| 254 |
+
# Chat responses
|
| 255 |
prompt = f"Learn about {python_parts_extended[part]}"
|
| 256 |
if st.button(f"Explore {part}", key=part):
|
| 257 |
response = chat_with_model(prompt, part)
|
|
|
|
| 261 |
if part in response_placeholders:
|
| 262 |
st.markdown(f"**Response:** {response_placeholders[part]}")
|
| 263 |
|
| 264 |
+
def generate_example(part):
|
| 265 |
+
# This function will return a relevant Python example based on the selected part
|
| 266 |
+
# Examples could be pre-defined or dynamically generated
|
| 267 |
+
return "Python example for " + part
|
| 268 |
|
| 269 |
+
def generate_quiz(part):
|
| 270 |
+
# This function will create a simple quiz related to the Python part
|
| 271 |
+
# Quizzes could be multiple-choice questions, true/false, etc.
|
| 272 |
+
return "Quiz for " + part
|
| 273 |
|
| 274 |
# Define function to add paper buttons and links
|
| 275 |
def add_paper_buttons_and_links():
|
| 276 |
# Python Pair Programmer
|
| 277 |
page = st.sidebar.radio("Choose a page:", ["Python Pair Programmer"])
|
| 278 |
if page == "Python Pair Programmer":
|
| 279 |
+
# Display Python concepts and interactive sections
|
| 280 |
display_python_parts()
|
| 281 |
|
| 282 |
|