This article will tell you how to create a Jupyter notebook file, what is the structure of the file and what content can you write in the file.
1. Create Jupyter Notebook File Steps.
- Click the New drop-down list on jupyter notebook home page top right corner.
- There is a list of menu items in the drop-down list.
- If you click the Folder submenu item, it will create a folder in the current jupyter web server folder. You should rename the folder on the server-side, and then the new folder name will be displayed on the web page.
- If you click the Python 3 submenu item, it will open a new browser tab to show the new python 3 script editing window.
- The top area of this tab window is the file operation menu bar. You can Insert, Delete, Copy, Paste python code in this window.
- After you input the python source code in each line, if you click the run button, it will display the code execution result under the code line.
2. Jupyter Notebook File Structure Introduction.
- Jupyter notebook file structure should follow the below rules.
- A document consists of a series of cells, one cell one line.
- Each cell is a multiline text input box.
- Cell content can be executed by press the shift + enter key, click the play button on the toolbar, or the command in the cell menu on the menu bar.
- The execution behavior of a cell is determined by the type of cell.
- There are four types of cells: code cell, markdown markup language text cell, title cell, and raw cell.
- When you insert a cell line, it original type is code. But you can change it’s type by clicking Cell —> Cell Type —> Code / Markdown / Raw NBConvert menu item.
3. Jupyter Notebook Cell Type Introduction.
- Code Type: This cell type allows you to edit and write new code with syntax highlighting and tab autocomplete. The programming language used depends on the kernel, the default kernel is python.
- When a code cell is executed, the code it contains is sent to the associated kernel, the kernel returns the result after calculation and displays the output after the corresponding cell.
- Output is not limited to text, there are many other possible forms of output, including Matplotlib diagrams, HTML, and so on.
- Markdown Type: Cell that can write markdown markup text.
- Raw Type: Used to write output directly. A notebook doesn’t do anything with it. It outputs whatever you edit.