Skip to main content

Python cells

Users can edit and execute any valid Python in a Python cell.

Python cells can optionally have outputs, which are visualizations of elements from the code.

If any line of a Python cell explicitly prints a value (e.g: print("hello!") ), that value will be included in the Output along with any other values explicitly printed by other lines.

Lines that implicitly print a value (e.g: 2+2) are only included in output if they occur on the last line of a Python cell.

If a cell has no explicit print statements and the last line does not print a value explicitly or implicitly (e.g: x = 5), nothing is displayed as output. This is perfectly fine, and is often done to keep things readable while setting the stage for another cell that will display something.

Converting cells#

You can convert a cell from a Python to a Markdown cell and vice-versa using the dropdown in the upper right.

Or use keyboard shortcuts to convert between cell types:

  • Go from Python to Markdown cells with esc + m
  • Go from Markdown to Python cells with esc + y

On this page