Code cells are cells that execute your code. This is the default cell type in the Jupyter Notebook. Python variables set in a cell are stored at the notebook level and can be used by any cell.
Code Cells have 2 modes:
- Edit Mode: Edit mode is the mode that allows you to edit the code in the cell. When in edit mode keyboard input is interpreted as cell content. Edit mode can be identified by the green outline on the cell. To enter command mode click in a cell.
- Command Mode: Command mode is the mode where you can execute keyboard shortcuts. Keyboard input is interpreted as keyboard shortcuts. To enter command mode click outside the cells or press the escape key.
Create a code cell
Code cells are created by default. You can tell a cell is a code cell by clicking on the cell and verifying the cell type drop down is equal to Code and by the “ln [ ]:” next to the cell. You can also switch a cell from another type to cell using the steps below:
- Select a cell in an open Jupyter Notebook
- In the toolbar select “Code” from the cell type dropdown
Execute Code in a cell
- Enter code in the Code Cell
- To execute a cell us the SHIFT + ENTER keys.
- Jupyter Lesson 1: Installing the Jupyter Notebook
- Jupyter Lesson 2: Starting the Jupyter Notebook
- Jupyter Lesson 3: Create a working folder in the Jupyter Notebook
- Jupyter Lesson 4: Create a new Jupyter Notebook
- Jupyter Lesson 5: Working with MarkDown Cells
- Jupyter Lesson 6: Working with Code Cells
- Jupyter Lesson 7: Using Magic Commands
- Jupyter Lesson 8: Jupyter Notebook Keyboard Shortcuts
- Jupyter Lesson 9: How to Interrupt the Kernel (Stop code from running)
- Jupyter Lesson 10: How to reset the Kernel (Clear all in memory objects and stop the code)