Use the Cloud9 Debugger

This lab will get you acquainted with the Python debugger in Cloud9. The debugger is an essential tool for understanding how your program works. It lets you run your code step-by-step while examining the contents of variables. Before you begin you should complete the steps in the lab Write Your First Python Program.

Step 1: Add More Code

You need to have more code if you want to use the debugger. Copy and paste the following lines into your program.

print("Hello Python World!")
print("This program will help you debug.")
name = input('What is your name? ')
print(f"Hello {name}!")

The code asks for input run it once using the run button to see what the program does. When you run the program it will stop and prompt you for an answer. Here’s what the prompt looks like:

Input your name

Step 2: Enable Debugging

There’s an icon of a bug in the window shown above. Clicking it turns the bug to green.

Enable debugging with the bug

Step 3: Set a Breakpoint

A breakpoint is a place in your program where you want the deubgger to stop so you can step through the code line by line. To enable a breakpoint simply click just to the left of a line number in your program. After you click you should see a red circle next to the line number like the picture below:

Set breakpoint

Step 4: Restart Your Program

Press the restart button Restart button in Cloud9 to restart your program and the debugger window will appear. Your desktop should show the debugger open and your program stopped at your breakpoint.

Debugger active

Step 5: Step Through Your Program

The step over Step over button button advances your program by one line. Press it three times to advance your program to the place where it asks for input. You should see the prompt printed. Enter your name and press enter. The program should advance to the last line as shown.

Input to the debugger

Look carefully at the debugger panel and you’ll see that there is a variable listed called name. You can see that it contains the value you typed.


Explore the debugger by:

  • Changing the breakpoint and rerun your program.

  • Find out what happens when you press the other step buttons.

Turn In

Turn in a screenshot of Cloud9 with the debugger running.