Spaces:
Runtime error
Runtime error
Update app.py
Browse files206 unmodified lines2072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412423 unmodified lines246247248249250251252253254255256257258206 unmodified lines# Python parts and their corresponding emojis, with expanded detailspython_parts = {"Data Types": "π","Control Structures": "π","Functions": "π§","Classes": "ποΈ","Modules": "π¦","File Handling": "π","Exceptions": "β οΈ","Libraries": "π"}python_parts_extended = {"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)"}# Placeholder for chat responsesresponse_placeholders = {}# Function to display Python concepts with expanders and chat buttonsdef 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):prompt = f"Learn about {python_parts_extended[part]}"if st.button(f"Explore {part}", key=part):response = chat_with_model(prompt, part)3 unmodified linesif part in response_placeholders:st.markdown(f"**Response:** {response_placeholders[part]}")# Define function to add paper buttons and linksdef add_paper_buttons_and_links():# Python Pair Programmerpage = st.sidebar.radio("Choose a page:", ["Python Pair Programmer"])if page == "Python Pair Programmer":display_python_parts()206 unmodified lines2072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562573 unmodified lines261262263264265266267268269270271272273274275276277278279280281282206 unmodified lines# Python parts and their corresponding emojis, with expanded detailspython_parts = {"Syntax": "βοΈ","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)","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 and interactive examplesresponse_placeholders = {}example_placeholders = {}# Function to display Python concepts with expanders, examples, and quizzesdef display_python_parts():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 examplesif st.button(f"Show Example for {part}", key=f"example_{part}"):example = generate_example(part)example_placeholders[part] = examplest.code(example_placeholders[part], language="python")# Quizzesif st.button(f"Take Quiz on {part}", key=f"quiz_{part}"):quiz = generate_quiz(part)st.write(quiz)# Chat responsesprompt = f"Learn about {python_parts_extended[part]}"if st.button(f"Explore {part}", key=part):response = chat_with_model(prompt, part)3 unmodified linesif 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 generatedreturn "Python example for " + partdef 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 Programmerpage = st.sidebar.radio("Choose a page:", ["Python Pair Programmer"])if page == "Python Pair Programmer":# Display Python concepts and interactive sectionsdisplay_python_parts()
app.py+45-21