How to use the
Learning Portal

Learning Portal

Our hands-on, comprehensive lesson plans span a range of levels. Browse our free STEM and coding learning resources.

Marty Image

2.4 – Debugging in Python

45 Minutes

Lesson Overview

Finding problems and errors in Python is a lot different in comparison to Scratch. In this lesson, we cover some easy ways to find the problem with our programs and put them to the test briefly. Students will be using the IDLE editor in this lesson to create and modify Python programs.

Key vocabulary:
    Python , Debugging , Logic Error , Syntax,

Content Sections

  • Learning Objectives
  • Extensions & Challenges
    • Additional Reading
    • 2.4 – Debugging in Python

      45 Minutes

      Lesson Overview

      Finding problems and errors in Python is a lot different in comparison to Scratch. In this lesson, we cover some easy ways to find the problem with our programs and put them to the test briefly. Students will be using the IDLE editor in this lesson to create and modify Python programs.

      Key vocabulary:
        Python , Debugging , Logic Error , Syntax,
      • Lessons 2.1-2.3
      • Laptop or PC
        • Marty the Robot
        • Marty Workbooks (Lesson 4)
        • Python treasure hunt scripts and instructions
        • Laptop or PC with Python, MartyPy and IDLE installed

      Learning Objectives

      • Describe the different techniques that we can use to debug programs in Python
      • Given a short Python script, analyse and debug so that it runs as expected

      1. Warm up activity, go through a few different short scripts from the PowerPoint slides and get students to decide if they think the program will work as expected

      2. Discussion with students around why they think we need debugging and why things don’t always work like we expect when programming

      3. Students should go into small groups of around 2-3 where each group has access to a Marty

      4. Students in the group should work together to work their way through the Python treasure hunt where they will have to debug some short scripts to get enough clues to work out a fact about Marty!

      Extensions & Support

      • Students could try creating their own treasure hunt activities
      • Students could create short Python scripts and place some errors in them for other student groups to try and find then fix

      Additional Reading

      • Educator’s Guide
      • Getting Started with Python: Schools

      Learner Resources —