Skillversitas

Types of Cells

Notebooks contain three cell types, each with a different role: Code cells execute in the kernel and show output, Markdown cells render formatted documentation, and Raw cells pass through unchanged for tooling. Mixing them is what makes a notebook both a program and a report.

Code Cells

x = 10
print("computed:", x * 2)
# executes in the kernel; output appears below the cell
  • Outputs: text, images, HTML, LaTeX, errors - all render inline.
  • State: variables persist for the session, so code cells share a namespace.
  • Execution count: the [2] label shows the run order of each cell.

Markdown Cells

# Section Title

Explain the analysis here.

- bullet one
- bullet two

`inline code` and [links](https://jupyter.org)

Markdown cells render when executed (Shift+Enter) or when the notebook is exported. Use them for titles, narrative, and methodology - the parts a reader needs without running code.

Raw Cells

This text is stored verbatim and not executed or rendered.
Tools like nbconvert or template engines can use raw cells as input.

Changing Cell Types

  • Keyboard (command mode): M for Markdown, R for Raw, Y for Code.
  • Menu: Cell -> Cell Type -> choose.
  • Dropdown in the toolbar when a cell is selected.

Conventions That Keep Notebooks Readable

  • Start with a Markdown title cell and a "What this notebook does" section.
  • Group related code cells with a Markdown heading before each section.
  • Keep cells small: one logical step per cell makes run order obvious.
  • Tag important cells (Cell -> Edit Metadata) for test runners and nbclient-based tools.

Summary

Code cells run and keep state, Markdown cells document, and Raw cells carry tool-specific text. Switch types with M/R/Y in command mode, structure notebooks with Markdown headings and small single-purpose cells, and use cell metadata tags when automating the notebook.