Hey, in this video
I'm going to share with you the Jupyter Notebook.
The Jupyter notebook is a great way to get started
with Python on the Coursera platform.
It's a great way to do data science and other
more advanced Python aspects on the platform too.
So let's dive in and take a look.
So when you log into the Jupyter platform
you'll be greeted with a screen that looks like this.
Jupyter is really built around this notion of code cells.
So here I have one cell.
Now there's a full Python interpreter
running in the background behind this.
So I can do things like create variables.
So here I'll just say x equals 10.
Then we'll just print x.
You see there is no output until
you actually go to run the cell.
But when you run the cell
the interpreter returns you the result.
You also get a little number
indicating how many cells have been run.
So you can see in this example I played
10 practice cells before actually showing this.
Now after it runs,
it's not like the application is finished running.
The kernel is still running in an interpreter mode
and we can continue to send queries to it.
So if we wanted to say x plus x,
and we wanted to print that,
you can see that prints out as we expected.
If you wanted to, you can stop the interpreter.
So if you feel that the state is
confusing or you just want a fresh Python instance.
It's actually pretty easy to do that.
You go to kernel and you say restart.
Often I use restart and clear output as a way that
reminds me that the interpreter
is actually been restarted.
You can cut, copy and paste cells and move them around.
So you could do those normal kinds of things.
The Jupyter notebook has a special feature,
it actually has a number of them.
But one is that if the result of
your last statement was an object.
There were some value returned
but you don't do anything with that,
it then automatically tries to print that to screen.
Good example might be this.
So if we say x equals 10 and then just the value x.
Then we actually run that.
We'll actually see the output.
So you'll often see in some of
the videos people just leaving the value towards the end.
You can individually run cells.
So for i in range 10.
So if we want to have a loop print i.
We could actually just not run this yet.
We can say down here,
wait what was the value of i and just run that
individual cell and i is not actually defined.
If we then decide we want to run that.
Okay, there's a bunch of i's.
Now run this cell again.
We could do that.
So you can see that we can have
a non-linear editing format.
That can be a little tricky actually because you can do
things like change the value in one cell.
But then you know this seems to
suggest that i should be nine,
but then when we run it we
actually see that it's minus one.
So you can sometimes get this irregular state,
or at least it feels irregular.
It's actually the interpreter,
the way that you've run the cells
in order determines the interpreter state.
You can often see that if you look at the cell number
here so six is greater than
five but it's greater than three.
So you can see that we're running
some things in a different order.
One of the benefits of
the Jupyter platform is that you can
adjust text in here as well.
So let's say I want to describe.
This is a great example of a loop.
Let's say I want this section to even be called loops.
So you can change the format of the cell here,
and there's a number of different formats.
You'll mostly use code
and then something called markdown.
So when you change it to markdown you'll note that the in
out goes away because
it won't be sent to the interpreter.
But when you run the cell it'll
actually run it in a data format called markdown.
So, like the pound sign here
or a double pound sign means give me a title.
So when you actually run that you get a nice bit of text.
So you can actually mark up your code execution
in a way that's a lot like a textbook might be.
You could create a whole textbook in this environment.
So those are the main features of the Jupyter notebook.
There are a bunch of other options.
So one that I often use is- we'll restart and run all.
So if I want to run all of the values in
a notebook I want to just see the whole execution trace.
You can do that. So in this case it
would- will do that here.
You'll see that it ran through the loop and then I
print it out i and it's set up our markdown.
That's a pretty common method.
If it runs into an error it will pause execution.
So that's important, because
sometimes in a lecture video you might see we
intentionally put an error in
there for a teachable moment.
Under the view there is some options as well.
Line numbers is one that I will often turn
on and that will number our cells as well.
Each Jupyter notebook has
a title for it and this determines the filename.
So I'll just call this Demo.
If you click on the Jupyter logo you'll
be taken to what's called the Tree interface
which is just a directory interface of
the files that you have for this project.
Within a given course on Coursera
or a specialization or a degree on
Coursera you may have any number of
different Jupyter systems with
different files spaces mounted on them.
I also really like to be able to
download my Jupyter Notebooks.
So sometimes I download them as HTML,
to show them to people or as a PDF version.
So that can be quite helpful as well.
So that's a quick tour of the Jupyter notebook.
Now most of the work you'll be doing in this course,
this specialization, or this degree
will be in the Jupyter notebook.
It's a great environment for doing
Python and there's ways to create
assignments and submit assignments
directly to auto-graders from within the platform.
I hope that we'll be able to share some of
our research tools as well on educational technology.
They are built into the Jupyter notebook.
But we'll see how that goes.
All right. We'll see you in the course.