Jupyter Lesson 6: Working with Code Cells

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:

  1. Select a cell in an open Jupyter Notebook
  2. In the toolbar select “Code” from the cell type dropdown

Execute Code in a cell

  1. Enter code in the Code Cell
  2. To execute a cell us the SHIFT + ENTER keys.