awacke1 commited on
Commit
ea5547d
Β·
1 Parent(s): 571dbcf

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +45 -21
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
- "Data Types": "πŸ“Š",
211
- "Control Structures": "πŸ”",
212
- "Functions": "πŸ”§",
213
- "Classes": "πŸ—οΈ",
214
- "Modules": "πŸ“¦",
215
- "File Handling": "πŸ“‚",
216
- "Exceptions": "⚠️",
 
217
  "Libraries": "πŸ“š"
218
  }
219
 
220
  python_parts_extended = {
221
- "Data Types": "πŸ“Š (Numbers, Strings, Lists, Tuples, Sets, Dictionaries)",
222
- "Control Structures": "πŸ” (If, Elif, Else, Loops, Break, Continue)",
223
- "Functions": "πŸ”§ (Defining, Calling, Parameters, Return Values)",
224
- "Classes": "πŸ—οΈ (Creating, Inheritance, Methods, Properties)",
225
- "Modules": "πŸ“¦ (Importing, Creating, Exploring)",
226
- "File Handling": "πŸ“‚ (Open, Read, Write, Close)",
227
- "Exceptions": "⚠️ (Try, Except, Finally, Raising)",
228
- "Libraries": "πŸ“š (Numpy, Pandas, Matplotlib, TensorFlow, Requests)"
 
229
  }
230
 
231
- # Placeholder for chat responses
232
  response_placeholders = {}
 
233
 
234
- # Function to display Python concepts with expanders and chat buttons
235
  def display_python_parts():
236
- st.title("Python Pair Programmer")
237
-
238
- for part in python_parts.keys():
239
- with st.expander(f"{part} ({python_parts_extended[part]})", expanded=False):
 
 
 
 
 
 
 
 
 
 
 
 
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