Creating and Running a Code Snippet
00:16 So if you don’t have Jupyter Notebooks yet, then go ahead and check this one out and then come back to here. And if you have it running, what you do is simply you type your code—like, you click into one of those cells, make sure that it’s a code cell—but that’s what it’s going to be by default—
Syntax highlighting makes it much easier to read. And then we print out our
x again. Okay. So here’s our
for loop. If I want to run this, I can press the Run button up here, or use a keyboard shortcut that is Shift + Enter.
01:26 I’m going to press Run here now. And our output appears right under here. The structure of this is a little bit different than other things we’ve seen so far. Usually we have this one window that’s a code window, and then we have a different window that’s our terminal. In Jupyter Notebooks, the structure is different, and it’s kind of integrated.
01:44 You can think of it like a mix of a script editor and a REPL. It’s as if you would be writing little scripts in each cell, and then you get your output right underneath there. However, it’s not that the output is lost as it would be in a real REPL, but instead, we have access to things down here.
02:21 So, you can see that this is a very dynamic way of working with code. I think it’s actually a nice way to start coding in general because you have this immediate feedback on the code that you’re typing.
but Jupyter doesn’t keep track of the order of execution. So it does, in this—you can see it in here on the side which cell got executed when—but when I now go back up here, then we can see that
x is now
03:04 So there’s this big pool of variables that sits somewhere behind the screen and that keeps track of what the variable currently refers to. So, this might get a bit confusing but just for exploration and for getting started and for working through some kind of, like, logical thought process of exploring some data, Jupyter Notebooks is really a great choice.
Become a Member to join the conversation.