

This brief code example is similar to what you already saw in Lesson 2. Soup = BeautifulSoup(html, 'html.parser') Then enter the following Python code: from bs4 import BeautifulSoup Click on the text field of the second cell so that the bar on the left turns green and you have a blinking cursor at the beginning of the text field. Let’s start by putting some Python code into the second(!) cell of our notebook. The type of a cell can also be changed by using the keyboard shortcuts ‘Y’ for ‘Code’ and ‘M’ for ‘Markdown’ when in ‘Command mode’.įigure 3.8 Notebook with two cells with the second cell being a 'Code' cell When you do this, the “In :” will disappear and your notebook should look similar to Figure 3.8 below. To change the type of the first cell to Markdown, select that cell by clicking on it, then change the type from ‘Code’ to ‘Markdown’ in the dropdown menu in the toolbar at the top. This indicates that these are ‘Code’ cells, so the content will be interpreted by Jupyter as executable code. To get an overview on the different keyboard shortcuts, you can use Help -> Keyboard Shortcuts in the menu at the top.īoth cells that we have in our notebook now start with “In :” in front of the text field for the actual cell content. Both adding a cell above and below the current one can also be done by using the keyboard shortcuts ‘A’ and ‘B’ while in ‘Command mode’. In the ‘Insert’ menu at the top, you will also find the option to add a new cell above the currently active one. The new cell will be added below the first one and become the new active cell shown by the blue bar (and frame around the cell’s content). To add a second cell, you can simply click on the symbol. Let’s start with a simple example for which we need two cells, the first one with some heading and explaining text and the second one with some simple Python code.

Clicking anywhere outside of the text area of a cell will change back to ‘Command mode’. When you click into the corresponding text field to add or modify the content of the cell, the bar color will change to green indicating that you are now in ‘Edit mode’. The notebook you created in the previous section currently consists of a single empty cell marked by a blue bar on the left that indicates that this is the currently active cell and that you are in ‘Command mode’. Jupyter Notebook Tutorial: The Definitive GuideĪ Jupyter notebook is always organized as a sequence of so called ‘cells’ with each cell either containing some code or rich text created using the Markdown notation approach (further explained in a moment).28 Jupyter Notebook tips, tricks, and shortcuts.We cannot cover all the details here, so if you enjoy working with Jupyter and want to learn all it has to offer as well as all the little tricks that make life easier, the following resources may serve as good starting points: We will now explain the basics of editing a Jupyter Notebook.
