I am totally lost on Unit 5 - Lesson 16 #6-8. Can anyone help me out. I see the solution, but don’t understand enough to explain it to the kids.
I always draw out the variables so I can keep track of them as I trace the code.
Here’s (the first part of) the function code:
Here’s the input:
You’ll see just from the first “if” condition, it evaluates to “true”, thus it immediately returns ‘input’ - 25. That’s not what we want.
#7 now assumes your ‘constrain’ functions works and you must figure out where in the code to implement it.
#8 is asking you to write a new function with a different purpose.
Did you have more specific questions?
These are actually possibly difficult problems that take a lot of deep thinking - as in not procedural/rote stuff. That makes it hard to understand and hard to explain, but in my opinion I’m not sure if I’d try to explain this into someone’s head. Something that just takes time and patience in trying to follow things slowly step by step and problem solve, and if that’s not working, look at the answer and slowly trace that for understanding. These are skills that aren’t built overnight and if you and your students made it this far, you’re all doing awesome.