 In this video, we're going to learn how to navigate the Google Lab environment. So let's first take a quick tour. At the top, we have a navigation bar, which has common items that we also know from other pieces of software like Word and Excel, like a file menu, an editor window, and a couple of others. On the left-hand side, currently, we see the files and folders of the folder we are currently in. The folders up here, they resemble the chapters of the book that belongs to this course. And down here, we have a couple of other files. In the center and on the right-hand side, we have the big main window. Currently, we see that there is a special window called the launcher. And the launcher window is a window that allows us to create new files of a certain type. So in the beginning, we're going to work with notebook files and the Python 3 kernel in it. So basically, a notebook file with Python 3 running in them. So let's click on that. And we see that a new file opens and the launcher goes away. And the new file has a name. It's called untitled ipinb. The file could be renamed. And we can do that by simply right-clicking here and click on Rename. And let's simply call it a tour on the JupyterLab. Okay, we also see that this file exists down here on the left-hand side, right here. And we could also have renamed the file here with a right-click and then we go on Rename. So it's a very intuitive user interface here. So let's start to code. So let's click with our mouse in the code cell that we see here. And we see that we are inside a code cell, not only because the cursor is blinking right here, but also as the border of the code cell has become blue. Okay, when I use my mouse and I click on the outside, the border will become gray as we see. So now I use my mouse and I click inside the code cell and now we are back in the code cell. So now let's write some Python. Let's write 1 plus 2. Okay, so that is valid Python. And now let's say I want to execute this code. How could I do that? There are a couple of ways. Using your mouse, the best way to go would be to simply click on the Run button here on the arrow here. So let's click here. And now we see the number 3 here and we get a new code cell. And now let me explain to you first what is the meaning of the numbers that are here in the beginning, on the left hand side of a code cell. You will always see two numbers that go together. So this is always the same number. And here the number 1 means that it was the first cell that has been executed. So let's go in the second cell and do something similar. Let's write here 2 plus 3. But now instead of pushing the button here with the mouse, I want to use a different way to execute this code cell. And the way to do that on a Linux machine or also on a Windows machine is to hit the Control key and then the Enter button. And now 2 plus 3 gives me back 5. I say that on a Windows and Linux machine because on a Mac OS some of the shortcuts are a little bit different. And since I don't have a Mac, I don't know really which key you have to press here, but you will figure that out on your own. And if you have a Mac on your own and you want to contribute to this course, maybe just put some of the comments inside the comment section below the video so that other people may know how that works on a Mac OS system. But let's continue with the example here. So now I have executed two code cells and we see that the lower of the two has now a number 2 standing here. So this is the second code cell that has been executed. We refer to these numbers as the so-called execution count. So now let's go back to the first cell with our mouse and let's also hit Control Enter here and we see that we can re-execute a code cell. So what we learned from this is that a document, a notebook document, consists of several code cells and they can be executed in any order. So just because there is a natural top-to-bottom order here doesn't mean that we have to execute the code cell from top to bottom. We can execute the code cells in any order. And the execution count will always tell us the last order in which the cells have been executed. Okay, so let's learn a couple of more things. So first of all, now I use my mouse to click inside the upper code cell again and we see that with the blue highlight and the blinking cursor. But a good way to go about using JupyterLab is to try to not use the mouse. So how do we do that? So in order to leave a code cell you can simply press the escape key on your keyboard and that basically leads us to go outside the code cell. You see that because the blue focus goes away, the border is not blue anymore, it has become gray. But on the left-hand side we still see the blue bars here and these blue bars they tell us on which cell we currently are. So with my arrow keys on the keyboard, if I press the down key, I go down. If I press the up key, I go back up. I can only do that when I'm not inside the cell. I have to leave the cells first and I do that with the escape button. So if I go back up to the upper cell and let's say I want to go inside the cell without the mouse, the simpler way to do that is to just hit the enter button. Then we are inside the cell and just to tell you that if you hit the enter button inside a cell, all that does is it creates a new line. So inside a code cell that is how we create new lines. And let's now go ahead and change the number two, maybe for example in the number one as well. And what we see here is that the result of the code cell does not change. So we only get the new result after we run the code cell and in the beginning students often forget to re-run a cell. Just by making changes to a current code cell that is not enough you have to actually run them by hitting control enter. And then we can run it as often as we want. So another trick to know is if you want to run a cell but also go to the next cell at the same time instead of hitting control enter you will hit shift enter. So let me do that, let me run shift enter and this will now run the upper cell and move the blue bars here one cell lower. So now shift enter and we see that the execution count went from 10 to 11 and the focus is now on the lower of the two cells. Okay so that is some easy navigation tricks. Okay so let's go a step further. So let's say I want to create a new cell. How can we do that? Well there are two options to do that. First I can create a cell that is above the current cell. Second I can create a new cell that is below my current cell. So there is a keyboard shortcut for that and when I'm outside cells most of the buttons on the keyboard have a second meaning. So when I'm outside a cell and I press A what I get is a new cell that is above the current cell. Okay, if I want to remove this cell again I can delete it and the easy way to delete it is by simply pressing double D. So it's double D not just single D because deleting should have a little confirmation to it so that is why you have to press the key D twice. So let's do it double D and the cell goes away. Now guess how can we create a new cell below the current one? Well it is B for below. So this will create a new cell that is below the current one and of course using double D this cell can also be deleted. So now let's assume I am on the cell that says 2 plus 3 and let's say I accidentally deleted it with double D. Now I want to restore it. How could I go a step back? So the way to do that is by simply pressing the set key. Set is like undo and that brings me back the cell that I just deleted. You could, if you don't remember those shortcuts you could always go to the menu up here and here in the edit menu you will see that here undo cell operation and the shortcut is set and then we have created a new cell. Do we have that here? We actually don't. So maybe let's check another menu. Okay, we don't have that here. So not all of the shortcuts are here but A and B for above and below you can I guess easily remember them. Let's try a couple of other ones. And now we are on the upper cell and let's say I want to cut it out and paste it below the second one. How could I do that? Well I press the X key that will cut out the cell that is currently highlighted and then the V key will paste it into the system back again. However below the current selection so the V key will paste to below so that is how we can cut and paste or copy paste. And we would have seen that it's X and V right here and C just as in other programs would just be copied. So if I want to copy the one plus one cell I just press C and V and then I get the second one plus one cell. And let's delete them again. So this is some easy operations on how to create cells and how to remove cells. Okay so let's take that a step further. So let's create a new cell below the current one and let's create a variable. Let's say I go in the cell first with Enter and now let's create a variable and let's call it X. And I will set X to the number 42. So using the single equal sign it's all called assignment statement. This is how we set or how we create a variable X and set it to 42. Okay so let's execute it. Control Enter. So now X has been set and we see that there is no output. So above here the upper two cells they always have an output below the cell. The cell here does not have an output and this is often an indication that something must have changed in memory and here we can guess what happened in memory. Well a new variable was created. That is why we don't see an output. So let's try to go ahead and see if we can access this variable. So how do we do that? Let's first go ahead and create a new cell. Enter it and then access the X variable. Okay let's hit control enter and X is indeed 42. So in the upper cell we set X to 42 in the lower cell we ask Python hey hey Python what is X and Python of course remembers what the value is. So now let's see some thing that some little caveat that you have to watch out for. So let's go to the very top and let's create a new cell above the first cell. Let's enter and let's ask Python hey Python what is X. And of course X is 42. However we are setting X to the number 42 down here and now we are accessing the variable up here. Could this ever be a problem? And the answer is yes. If we close the file and reopen it then what happens is Python forgets everything that is in memory regarding this file. This is like closing another program and opening it again. Usually any temporary state is usually lost. Just think of it as restarting your computer. So we are basically restarting the Python program that is running in the background and associated with this notebook file here. So let's do that. So how can we go ahead and restart the Python program in the background? So here with the mouse we click on kernel and we simply say restart kernel. And there is a shortcut for that. It would be 00. But let's simply click on restart kernel. It will ask us to confirm and here it says do you want to restart the kernel? All variables will be lost. So yes, we want to do that. So let's do that. So nothing has changed here. It looks as if nothing has happened but in the background we have basically restarted the process. So if I go back up here and I ask Python hey what is X now I get an error message that is what the red background means and Python is giving me a so-called name error and it says the name X is not defined and that makes sense. After a restart we haven't set the variable X yet so how does Python know what X is? It doesn't. It can't. So that is how we see that in this program the order of the cells may not be ideal. We first have to go down here create X then we can go back up here and now Python knows what X is. There are a couple of variants concerning the restart of the kernel. For example there is the option to restart the kernel and clear all outputs. This will delete everything that is below the cells this will basically empty out the entire notebook except for what is inside the cells. So now if I go ahead and ask Python hey what is X then again I get the error message and then there is another trick that I suggest students know in the beginning. So when you work on a problem set and you think you are done and you want to check if the notebook file can actually work then what you do is the trick is this you go click on kernel and then you click on restart kernel and run all cells and what this will do is it will restart the Python process in the background and run all the cells from top to bottom and whenever you do that before turning in homework for example then this should run through this should not cause an error because if it causes an error that means if I ask the teacher that corrects your assignment your machine then I will get the same error message because my machine definitely does not have anything in memory that your machine had in memory. So in other words we know that this first cell is not a good idea to have here so what I am going to do is I simply delete it for now and if I now go back and click on kernel and say restart kernel and run all the cells now what is going to happen is it should run from top to bottom for example that it actually the process hangs so what we could also do is we could click here it is actually a good example here so we could click on the second button here and here we see all the active Python processes in the background and I could also click on shutdown here and I could kill the process so to say so this is similar to it is actually the same then just to say restart kernel so now let's try again to restart the kernel and run all the cells so what we now see is all the cells now run from top to bottom without error and that is good so if this were like a homework assignment then now you are good to turn it in because now you know if I as a teacher open your file after you send it to me I can also run it from top to bottom and it won't cause an error so then another nice things you should know the black dot that you see up here what this basically means is that means the file that you are currently looking at has been changed but the changes have not yet been saved to disk so what you could do is you could go ahead and click on file and simply say save notebook but you also see here that there is a shortcut for that it is control S and control S you already know from other pieces of software so if you say saving complete control S then the file gets saved and what you see is the black dot goes away so let's say I make another change here instead of 2 plus 3 I will say 2 plus 2 and I will execute this now we see the black dot here again and what I now do is I click control and S for saving and now the black dot will go away that means I have stored my intermediate results I mention that here because since you are working in a web browser there is a chance that the web browser may die in the meantime or your computer just dies and you should always just keep a copy of your work, of your temporary work and save a lot so that you don't lose too much in case your program or in case your computer dies okay so this is how we work in Jupyter Lab so let me see if there are a couple of other options that are interesting to know so if you ever want to get a launcher window back you would simply go ahead and click on the plus button this gives you a new launcher if you want to create a folder you can do so here if you want to upload stuff into this project you could do that here so maybe if you downloaded the files and unpacked them and you have them somewhere where you cannot see them here on the left hand side you could actually upload the materials, the book materials inside the Jupyter Lab right here but you could also just simply do that in your file browser so this is just another way of doing that and then a couple of other nice things to know is you could go ahead and for example under settings, under Jupyter Lab choose the dark theme so some people prefer that their web browser is in a dark theme because it's easy to read for some people in this course I will keep the theme light and then what else can we see here under view we can show line numbers this will show line numbers inside a code cell sometimes this is very useful to know and let's deactivate this again so sometimes I will activate that and then I will tell you line 3 does that and so on so this may be helpful and under help you have a lot of links that go to web based help pages so in order for them to work you need internet access but other than that you will always get the most up to date version of any help file right here and yeah, that should be enough to get going and there are a couple of more things to find out either just whenever you yourself are using the mouse too much try to figure out what is a shortcut to use and if you are very advanced you could also under settings adapt the keyboard shortcuts you will find many tutorials online on how to do that I'm not going to show you that here and yeah, that concludes our brief introduction on how to navigate the Jupyter lab environment