Third question, and yeah these get really hard,

keeping track of all the moving pieces and logic in here,

it's a very big challenge for students,

and it's also one of the way a skill that's really helpful in

developing a close reading skills that they can use a lots of other classes.

I've had students tell me, "Oh now,

I do better my math classes because I've learned I have to pay

attention at a really detailed level." All right.

So, this is a great question that you can reuse in lots of different ways as a teacher,

both for discussions and then also for assessment purposes.

We're saying for what values that I'm going to give you of A and B,

is instruction B executed.

So really, this just gets students,

well, tracing in detail.

Okay? If we're going to teach this in a learning context,

what I really want them to do as I say,

"I don't want you to like, game it by using your test-taking skills.

I want you to trace out each of the four pairs of A and B values for A, B, C,

and D, because that's that skill essentially that we're trying to develop."

Now, if you were then talking to students

about doing this as a test-taking maybe in a timed environment,

you might be like, "Hey,

then we could apply some strategy skills."

"Hey, do you know that the value of A,

is the same for A and B,

and the value A,

is same for C and D. So we can look at that.

But we're talking about learning right now.

So, let's focus on that.

So, what we want people to do?

Is we want them to trace,

but just keeping track of the variable values is still

going to require us to apply a lot of brain power when we're actually doing the tracing,

which can be really really hard with these nested if else statements.

So instead, I recommend tracing the conditions.

So, let's look over on the left.

We've got three conditions.

Right? A greater than 10,

B less than five and B greater than 10.

So, we have three different conditions not two.

That's different than we've seen before.

So, we're going to want to set up a table like this,

we've got A greater than 10,

B less than five and B less than 10.

Now, depending on whether A greater than 10 is true or false,

we may only be looking at one of those other columns.

But I recommend that you say to students put all the conditions that you see

down here to the right of your values and then go through. Don't look at the code.

Just use the table and put in the values for A greater than 10,

B less than five bigger than negative 10.

So, I would say A is the value four is that greater than 10?

False. No. B is the value 11 is that less than five?

False. B is value of 11 is that greater than negative 10?

True. Okay. Now, I filled out the table,

I don't have to pay attention to the A and B columns the white columns,

I can just look at the orange columns.

Now, I can use those,

and I'll just go through and identify

which condition I have so the very first one A is greater than 10.

So, I'll look at A greater than 10 columns that's false.

So, I'll skip over the top, go down to the else,

and then I'll say, "Well,

here I think I've got that, yeah,

script on the top go down the else.

Oh I skipped ahead."

Now, I'm actually not looking at the B less than five,

I'm looking at B greater than negative 10, that is true.

Now I can identify that I've got instruction E that's executed.

But don't forget instruction D are got executed as well,

so we might as well indicate that because that was

it executed just because A greater than 10 was false,

no matter what B was.

So, now we're going to figure out if this is the right answer to the question,

for all values of A and B is instruction B executed.

Now again, you and hopefully even your students maybe once they're on to test-taking,

could maybe use this one round through to be like,

"Oh, I can see where it's going to be,

I got to have a greater than 10 be true and B or something"

That is really executing or using your prior knowledge about nested if statements.

We want students to go through the process of tracing these,

so that they can really deepen and reinforce their understanding.

So, let's do the next one. All right.

So we got, a is four,

b is nine. a greater than 10?

False. Is b less than five?

Minus not less than five. That's false.

Always b greater than negative 10?

Minus going, " Oh!

Man that's exacting one as a one before.

Cool. "I don't have to rethink about it.

That wasn't true before?

So, it isn't true now and I just left the instructions highlighted for you. All right.

Next row, fill in against,

don't pay attention to the code,

just look at the table.

Is 15 greater than 10?

True. Is five less than five?

False. Is five greater than negative 10?

True. Okay. Now, I've got those values,

now I can go into the table.

The code, sorry, a greater than 10, that's true.

All right. We got that big one.

Is b less than five?

That's false, and that's b less than five is the one I was supposed to look at there.

So, I do instruction B, and then,

oh by the way also do instruction C. So,

we've got the right answer now.

Its' C. Okay.

For what values of a and b is instruction B executed?

But, and sometimes I do this,

and I recommend you do it too,

sometimes I intentionally make two answers correct for classwide discussion,

because one kid will like come up with C,

and one kid would come with D, let's say,

I don't know maybe D is going to be correct to,

and they'll argue about it, and they'll be like ha ha ha.

They were two, and I won't say two of the above,

no, just let them to do the argument.

Okay? It adds a lot of energy to the course. All right.

So, C is the correct answer.

Let's see if I was sneaky and also made D a correct answer.

All right. Filling my table,15 is greater than 10, is true.

Negative 15, less than five, that's also true.

Is negative 15 greater than negative 10?

That's false. Now, I fill in.

So, I'm in the top half,

I'm true, b less than five, that's true.

So, now I'm doing instruction A and instructions C. Didn't do it in this case.

So, only C is correct in the sense here.

That was a lot of work,

but this tracing of expressions rather than values,

et cetera and having students work on just the evaluation of the expressions,

and then go and execute code,

this is a really good thing.

So, teacher tip, when you have really complex problems,

and this is true actually in any discipline,

but it's really important to break up how we're going to approach

them into small steps and give them names.

Okay? I didn't do that in this case, I didn't tell you.

I'm going to ask you to do it in a minute.

So, in that one we were breaking up things into steps, right?

There was tables, there was code,

and really important for you as a teacher,

you will be tempted to, don't skip steps.

Okay? Just keep going through them because there will

be some students who are still internalizing those,

and they need to see them over and over again. All right.

So, here's the question: For that last tracing problem,

we actually had two steps.

If I asked you to put names to these steps that you would teach your students,

what would you name them? All right.

Last question. Oh my gosh,

this question is hard.

Let me tell you how hard it is.

I came up with the evil idea of what the basic that was going to be,

it was going to be two expressions,

A greater than 10, and B less than five,

and I was going to have one code where the B expression was in the outer if,

and the A was in the inner ifs and then one where, a was in the outer if,

and b was the inner if, and I was like,

"Wonder if I can make them do the same thing because they do the same thing?"

That's it. I kind of wrote the code like a drafted on paper,

like doing the diagrams,

and then I thought," I have to check this", and I did,

I had to code this up to really, really be sure.

To really be sure,

I really coded this up,

I put in the values for a and b,

and then where I have instruction I said," Say instruction A,

say instruction B" and I tested every case,

all eight cases four for the first one, four for the second one.

Yeah. Hard. So, this is really good for students to do, right?

It really makes their brain start working at

the level of the logic that a computer does. All right.

So, again, we're going to have a table,

all of our condition options,

luckily we only have two different conditions in here,

and then we're going to work on one code at a time,

and see for what condition options is instruction A and B done.

And if for all the condition options they do the same thing,

then these codes execute the exact same values.

No matter a and b.

So, a key thing here is we're not testing

all the values of that we can possibly have for a and b,

all we have to do is test the two conditions for b less than five,

and the two conditions for a greater than 10.

So, there's four total conditions.

All right. This is code one,

that was the one that was on the left side.

Again, I've got my inputs,

I can have b less than five,

and a greater than 10, is true,

and I chose to do them in this order because I've got b less than five at the top,

so I can read true, false, true, false.

So, if b less than five is true, a greater than 10 is true,

that's instruction A, if b less than five is true,

and a greater than 10 is false,

that's instruction E. Again,

I've got the same thing,

but in the bottom half in the else,

so if b less than five is false,

but a greater than 10 is true,

that's being an else instruction F. So, This one,

by picking the ordering in which I set up the true,

true, true, false, et cetera, I can make it easy.

But what about code two? That one is going to be different.

So, I gave you the answers here,

let's see if we can confirm they're correct.

So note, code two is different,

it starts off at, a greater than 10.

Is a greater than 10? True. So, now you're going to look at the second column.

Yes. Okay. If b is less than five, true.

Those are going to be the same,

yes, that makes sense. There is I mean instruction.

So, just flipping them. I am still, if it's the true,

true condition, I'm still going to end up at instruction A.

Okay. Now, let me now instead of walking through the code,

let's walk through the tables.

If A greater than the 10 is false,

this is the second row,

so that takes me down to the else.

If b, less than five is true, okay,

then that's instruction E. At least that looks like it's matching up.

Yes. Then, let's do if a greater than 10 is true,

so we're in the if, then if b less than five is false,

that's going to instruction B.

So now I've got third under code two execute,

third one down, that's D, and then finally,

if a greater than 10 is false,

now I jumped down to the else,

if B, less than five,

that's false, and then that would give me into instruction F. And guess what?

Because for all different options of these conditions,

b less than five, a greater than 10,

the two codes execute the same thing.

We can say then, no matter what values we put in for a or b,

these two codes will execute the exact same way.