So let's try a little more complicated example.
So I'm going to click on these other tabs that are open, and
switch over to our second program.
It's a sequence of print statements,
that we can use to kind of show off some of the features of Thonny's debugger.
So the controls for the debugger can be accessed up here with these buttons.
So what I am going to do is,
instead of clicking run, I'm going to click debug current script.
And what Thonny does is it highlights the next piece of your Python program,
that we're getting ready to evaluate.
So we're going to evaluate this docstring,
we can hit basically step over, go to the next thing.
And so now we're ready to evaluate this print step.
So what the operation step over is going to do,
it's going to evaluate everything in this yellow box in one step.
So when I step over, what you're going to see is,
that I evaluated what's in here and printed out, Hello Thonny.
I can also step over this and
now I'm ready to evaluate the last print statement.
So what we're going to do now is we're going to use a second option,
which is step into.
Step into was going to now walk through evaluating the pieces of this
print function.
So let's do that.
So it says we need to evaluate the entire expression.
Then we need to evaluate secret number, which is just what the secret number is.
Do we now devaluate this arithmetic expression?
And Thonny's going to show us basically how the pieces of this arithmetic
expression are evaluated, and the order in which this evaluation takes place.
So we're going to evaluate one, you get back one.
Then, we're going to evaluate two times three.
So we have to evaluate two, that's two.
We have to evaluate three, that's three.
Then we're going to evaluate two times three, that's six.
Then we're going to evaluate one plus six, that's seven.
And then when we're done, we're going to print both those out.
And we're going to get the secret number of seven.
So notice here that when we step into a piece of code,
we're evaluating the components one step at a time.
If you're tired of kind of evaluating all of the little pieces,
you can use the final button which is step out.
And that basically exits a thing that you're currently evaluating, and
jumps back out to the next higher level Okay,
let's try Thonny's debugger out on a more interesting program,
one that uses concepts that you've been working on this week.
In particular, I've written a little code here that takes a list of numbers and
computes the smallest number in the list.
Now, notice in Python we can do this with a single function min, but
we've just done this as an example,
so you can see how evaluating something with loops and lists, would work.
So I'm going to start off by just running the code, and
you'll notice that it basically says that the minimal of this example list is 1.1.
So I have a list of numbers here, and sure enough the smallest number is 1.1.
So now I'm going to run the debugger,
we're going to see how this program is actually evaluated inside python.
So I'm going to click the debug script.
And I'm going to use Step over here, till we get to something interesting.
So we're going to define both our functions, then we're going to call and
run example.
So now we want to step into that.
And the thing that's interesting that happen here when we're actually evaluating
run_example, notice that Thonny popped up a new window that corresponds to
the evaluation of run_example.
So now we're going to evaluate run example.
And I'm going to step over this.
And you can see here,
we've actually bound the local variable example list to the list we provided.
And we're going to print out that example list, we're going to print a blank line.
And now the next nice thing that happens,
is we're going to actually evaluate list_num.
So I'm going to step into that.
And we notice that what happens is,
example_list gets replaced by the actual list.
And now we're going to dive into the evaluation of list_minimum, so
again we popped up a new window.
The thing to notice here, the parameter numbers,
is actually bound to the particular list we're interested in.
So now, I'm going to step over and get to the for loop.