Rich output is what makes a notebook a readable analysis rather than a script with print statements.
Markdown cells support headings (#, ##), bold and italic, lists, links, images, code blocks, tables and LaTeX math ($E = mc^2$ inline, $$...$$ on its own line). Press Shift+Enter to render, double-click to edit. Headings also build the table of contents panel in JupyterLab, which helps navigate long notebooks.
Code cells display the value of their last expression using the richest format the object supports. That is why a pandas DataFrame appears as an HTML table and a Matplotlib or Plotly figure appears as a chart: the object offers HTML, PNG or JSON representations, and the front end picks the best one.
To show more than the last expression, or to display from inside loops and functions, use display() (available automatically in notebooks, or from IPython.display). That module also has helpers:
Markdown("**bold**")andHTML("<b>bold</b>")render text you generate;Image("plot.png")orImage(url=...),SVG,Video,Audio;JSON(data)for a collapsible tree in JupyterLab.
End a line with ; to suppress the display of its value, for example after a Matplotlib call that returns objects you do not want printed.
Outputs are stored in the notebook file. Large images and HTML tables make files big and diffs noisy, so avoid printing huge DataFrames; df.head() or df.sample(5) is usually enough.
Example
from IPython.display import display, Markdown, HTML
import pandas as pd
df = pd.DataFrame({"city": ["Oslo", "Lima"], "temp": [4.5, 19.0]})
display(Markdown(f"**{len(df)} cities**, warmest: *{df.loc[df.temp.idxmax(), 'city']}*"))
display(df) # rendered as an HTML table in a notebook
html = df.to_html(index=False)
display(HTML(html))
for city in df.city:
display(Markdown(f"- {city}")) # display works inside loops
df.temp.mean() # last expression is shown: 11.75
# In a notebook: Markdown/HTML render as formatted text; a plain
# Python shell prints their text fallback instead.Remember
- Markdown cells give headings, lists, links and LaTeX math
- The last expression is shown in its richest format;
display()shows anything else IPython.displayhas Markdown, HTML, Image, JSON and media helpers
Watch out for
- Displaying an entire million-row DataFrame or huge images, bloating the saved notebook.