So now that you've been engaged with our challenge questions, let's talk about how you might review these with kids in the classroom, and I'm going to bring up the key points that you'll want to bring up with your kids as well. So these are the exact same questions you just did, but I'm going to show you the answer, I'm going to talk through why I choose that question and how to explain it. So this question was about testing integer division. Integer division is not generally too hard for kids but they get really stuck on rounding instead of what it actually does, which is truncating. So the correct answer here is B. When we do 43 divided by 4, that's going to be integer division, and it's going to actually truncate the result of that, which is actually meaning throwing away everything after the decimal point. Students might get this wrong by saying it's going to round. What does that actually look like? Well, if we just write our division on the board here, we've got 43 divided by 4, that's 10.75. We're just throwing away, crossing out anything that comes afterwards, so that's just 10. The other options for question A, that would ignore that second print line, they ignore the fact that that was actually 4.0, that's the big difference here, integer division versus non-integer division because when either of your operands are non-integer, then it's going to round up to the double type, which is more precise. The second one, also says you ignored 4.0 but also if the students were rounding instead of doing truncation, they would maybe get that one and then the last one is just the problem with rounding instead of doing truncate. Second question; about the modulo operator. Modulo, I think is really best just to get kids to memorize the algorithm or the process for doing it. We don't really need them to have like this conceptual understanding of modulo in general for the AP Exam. So the key thing for this is that, remembering that the operator, which is the percent sign, means modulo. I also said modulus and that what you actually do in that case is just do your integer division, and take the remainder. So let's walk through how we'd work through those kids. So the very first statement, we have 43 divided by 4, that's 10 remainder 3. So we got three. Next statement, is 43 divided by 5, which is 8 remainder 3. It's still the same remainder, that's interesting. Well, it works out that way and the last two, jumping ahead, 43 divided by 10 remainder 3, and then the last one, this one sometime kids just [inaudible] , why would you divide something by one, that's weird. It is weird but you can do it. Forty three divided by 1 is 43 of course, with a remainder of 0. So always anything divided by 1 you're always going to have a remainder zero. So the opposite option here would be, if students forgot what was modulo and what was division, they might pick this one, which is just the result of integer division. There are a number of modulo videos out on the web and I find most of them to be way over what we need in terms of our kid's head or even really even helpful in understanding them. I'll put this link, it'll pop up here in a Window for you so that you can click on it and not have to type this out yourself. This is a video I would recommend. I think is quite good. It's just the level of knowledge our kids need. It shows them, batching up groups of three apples. So we've got 10 apples here, modulo three. If we take out the whole batches of three, we can see we get 3 remainder 1. So we have three of them in our net and one leftover. Let's go into casting. This is a very silly piece of code, nobody would ever run anything like that, you can feel free to let your students know. We're just trying to exercise their ability to understand, how do we evaluate expressions from left to right, and to keep pointing out the point that once you lose specificity in your data, like the 0.9, it's gone. You can't ever get it back. So let's see how this goes. So your talk to students they will be like, the first thing we do is, we take the value of y and we cast that to an int, so that creates 91.9, truncates again to remind people, down to 91. Then, we'll cast that integer number 91, to a double, which means we put a 0.0 on the end of it before we print it out. Let's try something a little trickier. So imagine we didn't print it out. What if we said, int x equal y, what will we get? Well, y is a double, 91.9 and x is, we said just an int, won't it just truncate for us and do that? Actually, no. They won't let you put a more specific value into something smaller like an int, unless you make it explicit. So in fact in this case, you'd get a compiler error. The compiler before it even starts running problem. It's just trying to read our partial program to figure out what instructions you've given and make sure there are no mistakes. They will call this out as a mistake because it says, that you're trying to have incompatible types, and the explicit thing that prints out as possible lossy conversion from double to int. Well, if you've ever had your kid's in a different class where they learned about compression algorithm for integers or something, they might know the word lossy. Basically, it means you're losing data and they want to make sure that you know you're doing that and if so, the way you fix it, is you put a cast to an int right before that y in the second line. Compound operators: not honestly used for very much in a real world. So maybe for SQL, I don't really think students should have to learn this but it's on the APCSA exam, so we'll point it out for you. What's tricky here, is the y divided by equal 0. Wait, that's modulo equals zero. Well, that works too but what we've got here, is we've got it divide by 0 error even as modulo because you have to do an integer division to get your remainder. So what is that doing? It's saying, this is the equivalent of saying y equal y modulo zero. So that means take y divide by zero and get the remainder, I can't divide by 0. So this would be odd. You think students would never just do this but sometimes maybe they're calculating a value and then trying to do modulo equal and what not but the difference here is actually compared to the other error we just looked at, which was an error that came up at compile time, even though you'd like to think that the computer could forgot this as a problem, it won't give you this error until the computer is actually running the code. We can tell the difference here because instead of saying error over in C, it would say exception. So exception in thread main, so that's in your main procedure or method, and it tells you you're having an arithmetic exception divided by zero. The funny thing is here, kids will sometimes be like, but why didn't it try to do even print the x because the x part was fine. There was no problem with that line. Well, they need to understand that instructions are done one at a time, and as soon as you hit an error, it's not going to go any further. It just bails out and quits and gives you this error. Decrement operator. We had a lot of these. Also not terribly tricky, just this can get kids involved in some very careful tracing things. Actually there are some more tricky things about this that I'll give it to you in a separate video, but really here is, we've got x equals 10 then we subtract 1 off of that, now x is 9 on the second line. Well wait, I think we can teach kids to trace. Let's do that. We've got x and foo, and so this is one easy way to trace certainly on the board. So in the first line we've got 10, then on the next line we're going to decrement that by one for nine, then on the next line, we're putting nine into foo, then we're increasing x by one for 10 and we can see at that point when we're going to do the print, we look at the bottom number in each of our columns. There are some crazy wacky things. Like if you were to try to do x equal x plus plus, like it makes your head hurt to think about it. Nobody should feel like that. I'll tell you about it more. In fact I had to go and Google to make sure I had this answer right, and I ended up on StackOverflow. I'll you more about that shortly. Final one, this is a quintessential challenge problem, that will at least be done in class on a quiz or on an exam in university settings. So it's really, really good for kids to know this and actually come to recognize it. So the goal of this code, is actually going to be swapping the values in two variables. So I've got the variable yellow and the variable blue, each with a value: there's this 10th variable that you don't initialize anything, and then I immediately set yellow to 10. Let's walk through the tracing of this. This is a really, really good one for kids to trace. I did it all at once because I could do that in class and it'd be okay but at the end, it's somewhat kind of hard to read. Each line is supposed to be on there. Let me show you a way that I like to do it better on the board, and there's a reason I don't do it on slides much because it takes forever to create and only it took me like 20 minutes to make these slides. Just these next set of slides. Instead on the board I would write yellow, blue and temp and put a box, and the idea is there can only ever be one value in the box because there's only ever one value in a variable. We have a trick for teaching kids about that shortly. So what you do is first-line 10 and you can have the kids tell you, what do I put next? I put zero into blue. Then it says, okay. We skip a line because nth term doesn't change. I think you just makes sure that you have that temp variable. Now it's saying, put the value of these yellow int 10 so that number 10 is in yellow, we'll put that in temp. Then you get to the first time, you're going to cross something out because you're going to overwrite the value in that variable. You can't have two values in the same variable, no room for that. Only room for one. So we took what's in blue which is zero and we put that into yellow. So I cross out the 10 and put in the zero. Then I take whatever's in temp which is 10, I put it into blue, so I'm crossing out the zero in blue, it's no longer there. I'm now going to have 10, and then I can print. We're going to show you tools where you'll get kids to be able to use this tool to do the tracing for them which is a good first step but then you'll help them move onto learning to be able to trace it by hand themselves. Students hate to do it but that is the grand majority of all questions on the AP exam, and really, this is what we test on university exams as well. You have to trace code in your head without using a computer. So here's that hint I've recommended. In addition, to using these tools, I'm also going to show you some manual ways that you can use to have kids act out and understand that variables can only hold one value, and it looks like this. Every student is a variable. They've got one hand behind their back and their other hand out and that reflects that they can only hold one ball at a time and then you can have the two kids trying to swap them, and you say swap them without using that temp or that friend variable, and they can't do it. It's like you can't put under your chin, you can't do whatever and they realize, I have to pass the ball off to a friend and then it gets passed back, and it's a great fun little thing that you can do with kids. Then the thing to finalize with this, I would actually have students go and to replete or whatever you're using for your ID and have students try to swap variables without using temp. The only thing to do is, try to switch around these two statements, they won't be able to do it but it's good for them to experience that themselves.