Mouse in the Cabinet (Exercise)
00:00
Here comes the first exercise: Mouse in the Cabinet. In the program on the left, you can find these variables and functions. address
, cabinet_items
, basement_items
, and print()
. From the perspective of the mouse in the cabinet, order them into the four scopes: Local, Enclosing, Global, and Built-in.
00:24 You can find the function that you see on the slide in the supporting materials and also in the slides that you can download.
00:32
You may be wondering what “from the perspective of the mouse” means, because that’s not a proper Python term, right? So let’s have a quick look at the code on the left. There is a function named explore_basement()
that contains another function named explore_cabinet()
.
00:47 And this function contains a docstring with a mouse emoji. You need to look at the scopes from the perspective of the mouse, meaning where this docstring is, and then look out from this part of the code into the code that’s around it, and then order the scopes for the names that I just mentioned before.
01:07 Again, you can find the code in the supporting materials to look at it, but keep in mind that you don’t need to write code on your own in this exercise.
01:18 So pause this course, look at the code, think about your own solution, and once you’re ready, hop over to the next lesson where I’ll give you my solution.
Become a Member to join the conversation.