Skip to Content
View all events

Write Python Code with ChatGPT and Claude

Published by O'Reilly Media, Inc.

Intermediate content levelIntermediate

Generating code and troubleshooting with LLMs

Getting set up (5 minutes)

  • Presentation: Running Python locally or in the cloud, and downloading the exercise files

Building programs with an LLM (30 minutes)

  • Presentation: Describing a program to an LLM and iterating on what it gives us
  • Exercise: Pick one of the program ideas and build it with an LLM
  • Q&A

Troubleshooting with an LLM (25 minutes)

  • Presentation: Asking an LLM to find the cause of an exception, or of a bug that doesn't raise an exception
  • Exercise: Pick a broken program and troubleshoot it with an LLM
  • Q&A

Break (5 minutes)

Writing tests with an LLM (35 minutes)

  • Presentation: Making code testable and asking an LLM to write automated tests for it
  • Exercise: Pick a program and use an LLM to write tests for it
  • Q&A

Closing tips (20 minutes)

  • Presentation: Modifying, refactoring, and extending existing code with an LLM
  • (optional) Demo: Using an agentic coding tool that reads and runs your code itself
  • (optional) Discussion: What kind of code could you see yourself writing with an LLM?
  • Q&A

What you’ll learn and how you can apply it

  • Use LLMs to explore coding solutions and generate code
  • Troubleshoot exceptions and bugs with an LLM's help
  • Use LLMs to write automated tests that verify generated code

This live event is for you because...

  • You are a fairly new Python programmer
  • You lack the Python skills needed to solve your problems
  • You are taking your first steps with AI code generation

Prerequisites

  • Have written a few small Python programs
  • Can run a Python file from the command line
  • No experience using LLMs for coding required
  • Only minimal Python knowledge/experience required
  • A computer with Python installed
  • A code editor on your machine (Visual Studio Code, PyCharm, Sublime Text, etc.)
  • A free or paid Claude, ChatGPT, or Gemini account (optional, to complete the exercises)
  • Download the exercise files from https://github.com/treyhunner/llm-coding-class (clone it or download the ZIP)

Course Follow-Up:

Schedule

The time frames are only estimates and may vary according to how the class is progressing.

Python environment setup (10 minutes)

  • Hands-on exercises: Open a command prompt/terminal; open a code editor; make a virtual environment
  • Q&A

Starting from nothing (50 minutes)

  • Presentation: Feeding the LLM a short description of a simple app and iterating; feeding the LLM a detailed description of a more complex app and iterating
  • Hands-on exercise: Choose from five ideas to try to create with an LLM
  • Group discussion: What kind of code can you see yourself writing from scratch with an LLM?
  • Break

Troubleshooting exceptions (25 minutes)

  • Presentation: Guessing the cause of an exception/traceback
  • Hands-on exercise: Take one of the bits of broken code and try to get help troubleshooting

Troubleshooting logical errors (25 minutes)

  • Presentation: Guessing the cause of a non-traceback error/bug
  • Hands-on exercise: Take one of the bits of broken code and try to get help troubleshooting
  • Break

Writing tests (40 minutes)

  • Presentation: Using LLMs to help write automated tests
  • Hands-on exercise: Choose a code example and try writing a test

Closing tips (30 minutes)

  • Presentation: Rubber duck debugging with a talking duck; modifying existing code to add or update functionality; refactoring existing code but maintaining the existing functionality; creating new code based on or similar to existing code
  • Group discussion: What can you see yourself refactoring with an LLM?; What kind of code can you see yourself writing from scratch with an LLM?
  • Q&A

Your Instructor

Trey Hunner

Trey Hunner helps Python programmers level up their skills through corporate training and through Python Morsels, a Python skill-building service for individuals and small teams. Trey also sends out a new Python tip every week through his email newsletter at pym.dev/newsletter.

linkedinXlinksearch

Skills covered

  • Claude
  • Python