awacke1 commited on
Commit
5330d13
Β·
1 Parent(s): d3482a8

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +16 -54
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
- for part, emoji in python_parts.items():
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 = generate_example(part)
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 = generate_quiz(part)
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: