Spaces:
Runtime error
Runtime error
Update app.py
Browse files
app.py
CHANGED
@@ -211,85 +211,47 @@ def link_button_with_emoji(url, title, emoji_summary):
|
|
211 |
random_emoji = random.choice(emojis)
|
212 |
st.markdown(f"[{random_emoji} {emoji_summary} - {title}]({url})")
|
213 |
|
214 |
-
|
215 |
-
# Python parts and their corresponding emojis, with expanded details
|
216 |
python_parts = {
|
217 |
-
"Syntax": "βοΈ",
|
218 |
-
"Data Types": "π",
|
219 |
-
"Control Structures": "π",
|
220 |
-
"Functions": "π§",
|
221 |
-
"Classes": "ποΈ",
|
222 |
-
"API Interaction": "π",
|
223 |
-
"Data Visualization": "π",
|
224 |
-
"Error Handling": "β οΈ",
|
225 |
-
"Libraries": "π"
|
226 |
-
}
|
227 |
-
|
228 |
-
python_parts_extended = {
|
229 |
-
"Syntax": "βοΈ (Variables, Comments, Printing)",
|
230 |
-
"Data Types": "π (Numbers, Strings, Lists, Tuples, Sets, Dictionaries)",
|
231 |
-
"Control Structures": "π (If, Elif, Else, Loops, Break, Continue)",
|
232 |
-
"Functions": "π§ (Defining, Calling, Parameters, Return Values)",
|
233 |
-
"Classes": "ποΈ (Creating, Inheritance, Methods, Properties)",
|
234 |
-
"API Interaction": "π (Requests, JSON Parsing, HTTP Methods)",
|
235 |
-
"Data Visualization": "π (Matplotlib, Seaborn, Plotly)",
|
236 |
-
"Error Handling": "β οΈ (Try, Except, Finally, Raising)",
|
237 |
-
"Libraries": "π (Numpy, Pandas, Scikit-Learn, TensorFlow)"
|
238 |
}
|
239 |
|
240 |
-
# Placeholder for chat responses and interactive examples
|
241 |
response_placeholders = {}
|
242 |
example_placeholders = {}
|
243 |
|
244 |
-
# Function to display Python concepts with expanders, examples, and quizzes
|
245 |
def display_python_parts():
|
246 |
st.title("Python Interactive Learning Platform")
|
247 |
-
|
248 |
-
|
249 |
-
with st.expander(f"{emoji} {part} - {python_parts_extended[part]}", expanded=False):
|
250 |
-
# Interactive examples
|
251 |
if st.button(f"Show Example for {part}", key=f"example_{part}"):
|
252 |
-
example =
|
253 |
example_placeholders[part] = example
|
254 |
st.code(example_placeholders[part], language="python")
|
255 |
response = chat_with_model('Create a STEM related 3 to 5 line python code example with output for:' + example_placeholders[part], part)
|
256 |
-
|
257 |
-
# Quizzes
|
258 |
if st.button(f"Take Quiz on {part}", key=f"quiz_{part}"):
|
259 |
-
quiz =
|
260 |
response = chat_with_model(quiz, part)
|
261 |
-
|
262 |
-
# Chat responses
|
263 |
-
prompt = f"Learn about {python_parts_extended[part]}"
|
264 |
if st.button(f"Explore {part}", key=part):
|
265 |
response = chat_with_model(prompt, part)
|
266 |
response_placeholders[part] = response
|
267 |
-
|
268 |
-
# Display the chat response if available
|
269 |
if part in response_placeholders:
|
270 |
st.markdown(f"**Response:** {response_placeholders[part]}")
|
271 |
|
272 |
-
def generate_example(part):
|
273 |
-
# This function will return a relevant Python example based on the selected part
|
274 |
-
# Examples could be pre-defined or dynamically generated
|
275 |
-
return "Python example for " + part
|
276 |
-
|
277 |
-
def generate_quiz(part):
|
278 |
-
# This function will create a simple quiz related to the Python part
|
279 |
-
# Quizzes could be multiple-choice questions, true/false, etc.
|
280 |
-
return "Python script quiz example for " + part
|
281 |
-
|
282 |
-
# Define function to add paper buttons and links
|
283 |
def add_paper_buttons_and_links():
|
284 |
-
# Python Pair Programmer
|
285 |
page = st.sidebar.radio("Choose a page:", ["Python Pair Programmer"])
|
286 |
if page == "Python Pair Programmer":
|
287 |
-
# Display Python concepts and interactive sections
|
288 |
display_python_parts()
|
289 |
|
290 |
-
|
291 |
-
|
292 |
-
|
293 |
col1, col2, col3, col4 = st.columns(4)
|
294 |
|
295 |
with col1:
|
|
|
211 |
random_emoji = random.choice(emojis)
|
212 |
st.markdown(f"[{random_emoji} {emoji_summary} - {title}]({url})")
|
213 |
|
|
|
|
|
214 |
python_parts = {
|
215 |
+
"Syntax": {"emoji": "βοΈ", "details": "Variables, Comments, Printing"},
|
216 |
+
"Data Types": {"emoji": "π", "details": "Numbers, Strings, Lists, Tuples, Sets, Dictionaries"},
|
217 |
+
"Control Structures": {"emoji": "π", "details": "If, Elif, Else, Loops, Break, Continue"},
|
218 |
+
"Functions": {"emoji": "π§", "details": "Defining, Calling, Parameters, Return Values"},
|
219 |
+
"Classes": {"emoji": "ποΈ", "details": "Creating, Inheritance, Methods, Properties"},
|
220 |
+
"API Interaction": {"emoji": "π", "details": "Requests, JSON Parsing, HTTP Methods"},
|
221 |
+
"Data Visualization": {"emoji": "π", "details": "Matplotlib, Seaborn, Plotly"},
|
222 |
+
"Error Handling": {"emoji": "β οΈ", "details": "Try, Except, Finally, Raising"},
|
223 |
+
"Libraries": {"emoji": "π", "details": "Numpy, Pandas, Scikit-Learn, TensorFlow"},
|
224 |
+
"Advanced Concepts": {"emoji": "π§ ", "details": "Decorators, Generators, Context Managers, Metaclasses, Asynchronous Programming"},
|
225 |
+
"Top PyPI Libraries": {"emoji": "π", "details": "Requests, Pillow, SQLAlchemy, Flask, Django, SciPy, Beautiful Soup, PyTest, PyGame, Twisted"}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
226 |
}
|
227 |
|
|
|
228 |
response_placeholders = {}
|
229 |
example_placeholders = {}
|
230 |
|
|
|
231 |
def display_python_parts():
|
232 |
st.title("Python Interactive Learning Platform")
|
233 |
+
for part, content in python_parts.items():
|
234 |
+
with st.expander(f"{content['emoji']} {part} - {content['details']}", expanded=False):
|
|
|
|
|
235 |
if st.button(f"Show Example for {part}", key=f"example_{part}"):
|
236 |
+
example = "Python script example with mock example inputs for " + part
|
237 |
example_placeholders[part] = example
|
238 |
st.code(example_placeholders[part], language="python")
|
239 |
response = chat_with_model('Create a STEM related 3 to 5 line python code example with output for:' + example_placeholders[part], part)
|
|
|
|
|
240 |
if st.button(f"Take Quiz on {part}", key=f"quiz_{part}"):
|
241 |
+
quiz = "Python script quiz example with mock example inputs for " + part
|
242 |
response = chat_with_model(quiz, part)
|
243 |
+
prompt = f"Learn about advanced coding examples using mock example inputs for {content['details']}"
|
|
|
|
|
244 |
if st.button(f"Explore {part}", key=part):
|
245 |
response = chat_with_model(prompt, part)
|
246 |
response_placeholders[part] = response
|
|
|
|
|
247 |
if part in response_placeholders:
|
248 |
st.markdown(f"**Response:** {response_placeholders[part]}")
|
249 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
250 |
def add_paper_buttons_and_links():
|
|
|
251 |
page = st.sidebar.radio("Choose a page:", ["Python Pair Programmer"])
|
252 |
if page == "Python Pair Programmer":
|
|
|
253 |
display_python_parts()
|
254 |
|
|
|
|
|
|
|
255 |
col1, col2, col3, col4 = st.columns(4)
|
256 |
|
257 |
with col1:
|