Teaching Python

We're two middle school teachers learning and teaching Python

Using AI as an Ally in the Computer Science Classroom

ai-ally

Artificial Intelligence (AI) is reshaping how we teach and learn to code. The challenge is to leverage AI not as a crutch but as a catalyst for deeper understanding and motivation in our classrooms. It is even more challenging trying to convince students of this. However, by aligning your teaching goals with the open use of AI in the classroom, teachers can guide students into using AI to empower their learning, not replace it. Integrating AI into the collaborative learning process can shift the student mindset from merely using AI for quick answers to leveraging it as a powerful ally for continuous improvement and skill development.

Here is how we can use AI to empower, not replace, the learning process in computer science education.


Decoding Documentation

Many students and newbie coders find documentation dense and intimidating. Use AI to help students navigate and understand technical documentation. AI can break down these documents into more straightforward explanations, making them more accessible and less daunting for learners. You can also use ChatGPT4 or ChatPDF to upload documentation, ask AI questions, and provide coding assistance.

Example Assignment:
Assign each student a Python library to investigate. Have the students upload the package documentation and "interview" the AI to learn about the library. Have students generate an example script and then prepare a presentation to teach other students about the library.


Exploring AI-Generated Code

Engage students with AI-generated code samples. Encourage them to analyze and improve upon these samples. This activity not only demystifies AI's capabilities but also stimulates critical thinking as students discern the strengths and weaknesses of AI-generated code.

Example Lesson
Use ChatGPT4 or another code generator to create Python Scripts for fun activities. Have students identify the Coding concepts, describe what the code is doing, or look for any errors or issues with the code.


Ethical Discussions on AI Use

Facilitate discussions on the ethical use of AI in coding. Have students reflect on the importance of understanding the code they write, even when AI assists them, and the ethical implications of relying too heavily on AI. Encourage students to consider the responsibilities that come with this powerful tool.

Example Discussion
Provide students with a safe space to use Generative AI and give students parameters to guide their use. Ensure that students cite or provide credit to code scripts that they have gotten from Generative AI and or online. Discuss the importance of ethical use in code.


AI as a Research Tool

Teach students to use AI to gather information on coding concepts or languages they are unfamiliar with. This encourages them to take initiative in their learning and share their findings with peers, promoting a culture of shared learning.

Example Assignment
Assign students with a task that requires using another language or an advanced topic. Have the students develop a plan to create or execute the activity. Students can use AI to research other examples, code snippets, Python Libraries, and other coding languages to build a "mood board" or in-depth plan for the task.


Debating AI Suggestions

Encourage debates or discussions around AI-generated solutions. Students can analyze different solutions proposed by AI, debate their merits, and decide on the best approach. This enhances their understanding of coding practices and fosters critical thinking and decision-making skills.

Example Lesson
Use a personal script or a student's code and generate a code snippet for the same app using Generative AI. Place the two scripts side by side and discuss the differences between the two codes. Discuss readability, functionality, and efficiency with the code. (Make sure to remove the comments in the Generative AI before the discussion.)


Peer Review Sessions with AI Assistance

Organize peer review sessions where students use AI to analyze each other's code. The AI tool can point out inefficiencies, bugs, or areas for optimization, which students can then discuss and work on together. This improves their coding skills and teaches them to give and receive constructive feedback.

Example Activity
Complete peer reviews with students. First, have the students review each other's code without the help of AI. Have students look for bugs and give feedback on the code. Then, have students upload their partner's code into ChatGPT4. Have them ask GPT for feedback and improvements for the code, then have them share their findings. Having students work on other students' code allows them to evaluate and learn new concepts from their peers and AI. The discussion and resharing after the AI reviews are an excellent opportunity for the students to discuss if the improvements or feedback are worthy and relevant.


Celebrating Creativity and Innovation

Highlight and celebrate when students creatively use AI in their projects. Acknowledging innovative approaches motivates students and emphasizes the importance of creativity in coding and AI applications. Help develop opportunities or "forced" creativity to demonstrate the benefits of using Generative AI for creative ideas.

Example Activity
Python Mashups powered by AI: Develop a "Wheel of Python Libraries" or two wheels! Create two separate wheels, each featuring a diverse range of Python libraries. Ensure the libraries are varied enough to spark interesting combinations, yet compatible for integration into a single project.Have students spin the wheel to select two different Python Libraries. Students use Generative AI to develop an app that uses the two chosen libraries. See if the AI can help generate the start of an app and have students add their flare.

Once completed, students present their projects to the class, explaining their thought process, the challenges they faced, and how they integrated the two libraries. This fosters a learning environment where students can share insights and learn from each other's experiences.


Real-World Problem Solving

Challenge students to use AI as a tool to solve real-world problems. They could use AI to optimize code for efficiency, solve complex algorithms, or even predict outcomes. Such projects show the practical application of AI in coding, making learning more relevant and exciting.

Example Assignment
Have students design an app to solve a real-world problem or issue they could automate with Python. Call it an @Al Sweigart-inspired "Automate the Boring Stuff" Hackathon. Let students generate code using AI as necessary. Ensure that the students have developed a complete plan prior and have the students draft their final product before using the AI. This will help mitigate total plagiarism and ensure students think through the solution first.


AI as a Personalized Tutor

Introduce AI tools that can serve as personalized tutors for students. These tools can explain complex code lines or concepts in a way that is tailored to each student's understanding level. This individualized approach can clarify doubts and strengthen comprehension, encouraging students to explore coding concepts more confidently.

Example Lesson
Give students code or have them generate a script. Have the students ask ChatGPT4 to explain every line of code to them. Have students present this code, run it, and explain to students what each line does. Students can teach other students "like a 1st grader."


Shared Learning Logs

Create a shared digital log where students document their learning experiences with AI, including challenges faced and insights gained. Peers can comment on each other's logs, providing additional perspectives and learning from each other's experiences.

Example Project
Reflection and Metacognition are great ways to encourage students to think about their learning. Have students create portfolios of their use with AI. Have students reflect on what they learned if AI was helpful, and provide other perspectives on their learning.


It's important to set realistic expectations about AI's role in coding. AI can be a powerful ally when used wisely. It can demystify complex concepts, provide personalized learning experiences, and open doors to innovative problem-solving approaches. It's not just about finding quick solutions but understanding, improving, and innovating. By integrating AI thoughtfully, we prepare students to be coders, thinkers, and problem-solvers equipped for the future.