All right. Let's figure out how you would want to discuss these questions in the classroom with your students. Because they really get at some of the core concepts of the logic pined nested if elses, and start to push us a little bit on some of the difficult complexities that we've maintained in our head. So, here's the first instruction, is asking about Instruction B and E. Just this alone, we've completely left out some material in the if statement. We don't have any of the actual expressions to evaluate. That's challenging for students. This is what we call a level of abstraction saying, "Look, it doesn't really matter. We're not telling you exactly what the conditions are. We want to know from your core understanding of how if else work. Could B and E be executed at the same time?" So, I've got to indicate the right answer here. The answer is B and E. I'm pretty sure it's no. Right? Okay. So what's a key thing that we can actually have talked to students about here? You didn't actually need to know about nested if else's for this to work. Actually, it's just a question about the regular if else on the outside. Can something that's in the true part of the if, the dark gold one, also be done in the same time as something in the false portion of the else portion of that external if? So, in this case, it looks really complicated and some students are like, "I don't want to think about it, my brain hurts." But it's like, this is a really important skill that computer scientists need to have, even though you're looking at a complex thing. Can you just look at the smallest amount of complexity that you need to be able to get the answer that you needed. So, ignore complexity until you're required to engage with it. So again, answer, no. So, if I were reviewing it with kids I'd be like, "Hey let's remember. All this stuff up here, that's in our outer if statement and all of that could be done, not necessarily every instruction, but all of those could be done whether it's true, and then oh yeah, this is the whole else part that goes in the outer if. So really, sort of chunking those into blocks. So, the students can focus on the higher level like ignore all these details together, put all those together. It's a really good thing to explicitly teach them, not just hope they figure out on their own. All right. Different question, it says, "Is it possible for both instruction D and F to execute in a single run of this code?" I was so bad I didn't give you the answers. Take a look. Guess. Right. Probably, you say yes. But that may only be true if you have a lot of prior experience in programming. So really, definitely important to keep in mind especially as we start getting these complex logic parts. One of the things that people with experience programming is they really get good at sort of again, simplifying the logic and knowing what to pay attention too, when there's a whole lot of stuff on the screen. So, really good thing to help students manage complexity when they are struggling to do so, is to use a graphic representation. That's why we taught you guys flow charts as we were doing this particular topic. So again, we're upping the level of abstraction required from the student brain saying, "We're not telling you what the conditionals are for the if's." So, we'll just use these open diagonals to indicate the if statements. So we have just on a few here. So, this will be the first outer if statement be the top one, and then true is usually to the left. Sorry. I should probably written true on there, and that would be the second if statement and then, there's instruction A, if that second value is true. Then we could go on to add well if that second boolean expression is not true if it's false, then we go instruction B to the right. So, instruction C, could be one of those things that students really struggle with. Because it's not, it's in the true portion of the if, in the outer if, but it's not in control of that inner if inside the true portion. It's going to happen no matter what as long as that first boolean expression is true. More so in particular, it's going to happen after either instruction A, or instruction B, happen but not both of them just one of them will happen. But afterwards, instruction C will always happen if the first expression is true, regardless of what is true about second expression. Let's go down the other path because we've covered A, B, and C. So, if the first Boolean expression is false, we go to the else. In this case, there's an instruction right away that's not under any other control that we always do. Then, we have another check to have our if statement there at the Boolean expression. If it's true, we go to instruction A. Also, we go to instruction F. So, the'res different graphical orientation or representation of these nested if else statements, can really help students do what you may do if you've had prior programming experience, which is tracing the execution of the code and realizing like, how do I keep track of what instructions or would have been done, what Boolean expressions I would have been checking et cetera. When anytime we execute this code, we're going to take exactly and only one path from the top to the bottom of this graph. 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.