Creating a notebook within JupyterLab

Notebooks are still a central feature of JupyterLab's functionality, so we'll provide a brief walkthrough of how to launch one:

  1. To launch a notebook in JupyterLab, click on the Notebook icon in the launcher, as shown in the following screenshot:

  1. This will open a new notebook in the same window, as shown in the following screenshot:

  1. The top right-hand side of the notebook, as pointed to in the following screenshot, will designate the type of notebook that is running:

  1. Rename the notebook by clicking on Rename Notebook... in the File menu, as shown in the following screenshot:

  1. Enter the filename and click on the Rename button to change the filename: 

  1. Now that we have our initial notebook, we can write a script to see how it works. In the text area of the first cell, add the following Python script:
name = "Dan"
age = 37
print(name + ' is ' + str(age) + ' years old.')

In the preceding code, we declare and initialize two variables: name and age. Next, we use the print() method to print the information that is stored inside the variables, which we can view within our notebook.

When you enter the code into your notebook, it should match the code, as shown in the following screenshot:

Notice the way that the code is highlighted, as this highlighting indicates the types of data you are working with:

    • The code functions that are called in the notebook are printed using a green font.
    • The string literals of the script are printed using a red font.
    • The numeric literals included in the program are printed using a green font.
  1. Save the notebook by clicking on the diskette icon and it will be saved with our changes. Then, run the notebook by clicking on the right arrow icon at the top of the screen, which gives us the following result:

We have executed the code in the cell and can see our results in the preceding screenshot. We can also see that the cell now has a number, [1], and a new, empty cell has been generated below it.

..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset
18.188.252.23