CS 111: Introduction to Computer Science
Debuggers and recursion
Meeting WingIDE and its debugger
Today will be sort of half lecture and half lab. We'll be using the
WingIDE 101
"integrated development environment" (IDE). To get started:
- Open a Finder window, go to Applications/CarletonApps, and find
WingIDE. Drag it to your dock if you want to be able to get to it easily, but in
any case, launch it.
- Save a copy of spongebob.py in your account,
and open it using WingIDE.
- Run the program by clicking on the Debug button.
Did you see output? If not, you should go up to the Tools menu and select
Python Shell and try running the program again.
- Now arrange your screen so that you have tabs for Python Shell, Call Stack, and Stack Data
visible (see the Tools menu if they're not already visible).
By right-clicking and selecting appropriate choices, you can position these tabs wherever
you want them. I like to have Call Stack and Stack Data on the right side of my screen, and PythonShell
on the bottom, but it's up to you.
- If you right-click in the left side of the source code window, you can create little
stop signs, known as "breakpoints." Put a breakpoint to the left of the "return result" line inside
the patrick function.
- Run the program with the Debug button. What happens? Take a look at the Call Stack and Stack
data tabs. Can you make sense of what you see there?
- Click on the Step Over button once, twice, three times, and pay attention to what changes (if anything)
on screen for each click.
- Click on Debug again to continue the program, which will, again stop at the breakpoint
inside the patrick function. What do the Call Stack and Stack Data tabs look like now?
- Click on Debug one more time. The program should run to completion. Feel free to fool
around with the program some more, to figure out what's going on with the breakpoint, the call stack,
the stack data, etc.
Next: recursion
Open recursivefunctions.py in WingIDE, and
try some of the same things as above, experimenting with factorial(n).