Spaces:
Runtime error
Runtime error
Update app.py
Browse files206 unmodified lines2072082092102102112122132142152162112122132142152162172182192202212222212222232242252262272282232242252262272282292302312322312332342352362342372382362372382392392402412422432442452462472482492502512522532542552562573 unmodified lines261262263264265266267268269270271272273274275276277278279280281282206 unmodified lines # Python parts and their corresponding emojis, with expanded detailspython_parts = { "Syntax": "βοΈ", "Data Types": "π", "Control Structures": "π", "Functions": "π§", "Classes": "ποΈ", "Modules": "π¦", "File Handling": "π", "Exceptions": "β οΈ", "Data Types": "π", "Control Structures": "π", "Functions": "π§", "Classes": "ποΈ", "API Interaction": "π", "Data Visualization": "π", "Error Handling": "β οΈ", "Libraries": "π"}
python_parts_extended = { "Syntax": "βοΈ (Variables, Comments, Printing)", "Data Types": "π (Numbers, Strings, Lists, Tuples, Sets, Dictionaries)", "Control Structures": "π (If, Elif, Else, Loops, Break, Continue)", "Functions": "π§ (Defining, Calling, Parameters, Return Values)", "Classes": "ποΈ (Creating, Inheritance, Methods, Properties)", "Modules": "π¦ (Importing, Creating, Exploring)", "File Handling": "π (Open, Read, Write, Close)", "Exceptions": "β οΈ (Try, Except, Finally, Raising)", "Libraries": "π (Numpy, Pandas, Matplotlib, TensorFlow, Requests)" "Data Types": "π (Numbers, Strings, Lists, Tuples, Sets, Dictionaries)", "Control Structures": "π (If, Elif, Else, Loops, Break, Continue)", "Functions": "π§ (Defining, Calling, Parameters, Return Values)", "Classes": "ποΈ (Creating, Inheritance, Methods, Properties)", "API Interaction": "π (Requests, JSON Parsing, HTTP Methods)", "Data Visualization": "π (Matplotlib, Seaborn, Plotly)", "Error Handling": "β οΈ (Try, Except, Finally, Raising)", "Libraries": "π (Numpy, Pandas, Scikit-Learn, TensorFlow)"}
# Placeholder for chat responses# Placeholder for chat responses and interactive examplesresponse_placeholders = {}example_placeholders = {}
# Function to display Python concepts with expanders and chat buttons# Function to display Python concepts with expanders, examples, and quizzesdef display_python_parts(): st.title("Python Pair Programmer")
for part in python_parts.keys(): with st.expander(f"{part} ({python_parts_extended[part]})", expanded=False): st.title("Python Interactive Learning Platform")
for part, emoji in python_parts.items(): with st.expander(f"{emoji} {part} - {python_parts_extended[part]}", expanded=False): # Interactive examples if st.button(f"Show Example for {part}", key=f"example_{part}"): example = generate_example(part) example_placeholders[part] = example st.code(example_placeholders[part], language="python")
# Quizzes if st.button(f"Take Quiz on {part}", key=f"quiz_{part}"): quiz = generate_quiz(part) st.write(quiz)
# Chat responses prompt = f"Learn about {python_parts_extended[part]}" if st.button(f"Explore {part}", key=part): response = chat_with_model(prompt, part)3 unmodified lines if part in response_placeholders: st.markdown(f"**Response:** {response_placeholders[part]}")
def generate_example(part): # This function will return a relevant Python example based on the selected part # Examples could be pre-defined or dynamically generated return "Python example for " + part
def generate_quiz(part): # This function will create a simple quiz related to the Python part # Quizzes could be multiple-choice questions, true/false, etc. return "Quiz for " + part # Define function to add paper buttons and linksdef add_paper_buttons_and_links(): # Python Pair Programmer page = st.sidebar.radio("Choose a page:", ["Python Pair Programmer"]) if page == "Python Pair Programmer": # Display Python concepts and interactive sections display_python_parts()
app.py+45-21