JL Apps

Guides for Python Editor

Jupyter notebooks on iPad: cells, Markdown and charts

Jupyter notebooks mix code, text and results in one document. That makes them popular in school, at university and in data science: you can explain a step, run it and show the result right below.

This guide explains how notebooks work – cells, shared state, charts and the .ipynb format – and how you can open and write them on an iPad or iPhone.

Python Editor app icon

The app for this

Python Editor: Learn & Code

Run Python 3 Code Offline

Download on the App Store

What a notebook is

A normal Python script runs from top to bottom in one go. A notebook is split into cells. Code cells contain Python and show their output directly below. Markdown cells contain text with headings, lists and emphasis to explain what's going on.

Because you run cells one at a time, you can explore step by step: load data, look at it, try a calculation, adjust it and run just that cell again.

Cells share their variables

All code cells in a notebook run in the same Python session – in Jupyter this is called the kernel. A variable you create in one cell is available in every cell you run afterwards. Here is a small dice experiment split into three cells. The first one creates 600 random rolls:

import numpy as np
import matplotlib.pyplot as plt

rng = np.random.default_rng(42)
rolls = rng.integers(1, 7, size=600)

Counting the results

The second cell uses rolls from the first one. np.bincount counts how often each number appears; [1:] drops the count for 0, which can't be rolled.

counts = np.bincount(rolls, minlength=7)[1:]
print(counts)
print("Mean:", rolls.mean())

Charts with matplotlib

The third cell turns the counts into a bar chart. In a notebook, the chart appears right below the cell that created it, so explanation, code and picture stay together.

plt.bar(range(1, 7), counts)
plt.xlabel("Face")
plt.ylabel("Count")
plt.title("600 dice rolls")
plt.show()
Do it with Python EditorLearn more →

Execution order matters

Because cells share state, the order in which you run them counts – not the order in which they appear on the page. If you run the second cell before the first, Python stops with NameError: name 'rolls' is not defined. If you change a variable in a later cell and then run an earlier cell again, that earlier cell sees the new value.

This is the most common source of confusion in notebooks. A few habits help:

  • Put imports and setup in the first cells.
  • Run cells from top to bottom when you open a notebook.
  • Avoid reusing variable names for different things in different cells.
  • Before sharing a notebook, run all cells in order once to make sure it works.

Writing good Markdown cells

A notebook is meant to be read. A short heading for each step and one or two sentences about why you do something make it much easier to follow – for your teacher, your colleagues or yourself in three months.

  • # Heading, ## Subheading
  • **bold** and *italic*
  • - list items on their own lines
  • `code` for names of variables and functions

What's inside an .ipynb file

An .ipynb file is a JSON document. It stores a list of cells, each with its type (code or markdown), its source text and, for code cells, the outputs of the last run. That's why a notebook you receive can already show results before you run anything – and why notebooks with many large charts can become big files.

Since the format is the same everywhere, a notebook from a course or from JupyterLab on a computer can be opened in other notebook apps as well.

Notebook or script?

Notebooks shine when you explore: analyzing data, trying formulas, documenting an experiment or handing in an assignment that mixes explanation and results. For programs that should run the same way every time – a game, a tool, anything with input() in a loop – a plain .py script is usually the better fit. A common workflow is to experiment in a notebook and move the finished code into a script once it works.

Notebooks on iPad and iPhone

Python Editor opens and writes .ipynb files: code cells you run one at a time, with text and output in between, and cells that share their variables – just like in Jupyter. numpy and matplotlib are built in, and Python runs on the device, also offline. Notebooks are part of the free features.

Frequently asked questions

How do I open an .ipynb file on iPad?

You need an app that understands the notebook format. In Python Editor you can open .ipynb files, including from a folder in the Files app or iCloud Drive.

Why do I get a NameError in a notebook?

Most likely, the cell that defines the variable hasn't run yet in this session. Run the cells above it first, from top to bottom.

Do Jupyter notebooks on iPad need internet?

Not in Python Editor: Python, numpy and matplotlib run on the device. Only extra packages such as pandas download once, the first time you import them.

More guides

Python EditorFree on the App StoreGet