Skip to main content
Lectra opens and runs Jupyter notebooks (.ipynb files), the format many data science and programming courses use for assignments. You can write Python in cells, run them one at a time, see charts below your code, keep notes in Markdown, and share the notebook back as a .ipynb file.
This page is about Python notebooks. For paper notebooks that you write in with Apple Pencil, see Create notebooks.

Before you begin

The first time you run a cell, your iPad needs an internet connection so Lectra can download Python. After that, notebooks run offline. To learn more, see Run Python.

Create a notebook

1

Go to Projects

In your library, tap Projects.
2

Create the notebook

Tap New, and then tap Python Notebook.
3

Name it

The notebook opens with a short Markdown cell and an empty code cell. Tap Notebook title at the top to give it a name.
Your notebooks appear in the Projects tab, after your project folders.

Open an existing notebook

To open a .ipynb file, such as one from your course site, use any of these:
  • From the Projects tab: tap New, and then tap Import Notebook. Choose the file.
  • From the Documents tab: tap New, and then tap Import PDF, which also accepts .ipynb files.
  • From another app or the Files app: share or open the file, and then choose Lectra.
  • From a project: tap a .ipynb file in a project’s file list. Lectra opens it full screen and saves your changes back to that file.
If the file isn’t a valid notebook, Lectra says “Could not read that notebook. Make sure it’s a valid .ipynb file.”

Write and run cells

A notebook is a list of cells. Code cells hold Python. Markdown cells hold notes.

Add a cell

At the bottom of the notebook, tap one of these. Lectra adds the new cell at the end.
  • Code: a Python cell.
  • Markdown: a text cell for notes and headings.
  • Data: brings in a data file. To learn more, see Load a data file.

Run code

  • To run one cell, tap Run on the cell.
  • To run every cell from top to bottom, tap Run All at the top.
A code cell shows its run number on the left: [ ] before it runs, [*] while it runs, and a number such as [3] after. If you change a cell after you run it, its output shows “Output is from older code — run to refresh.”

Use keyboard shortcuts

With a hardware keyboard:

Edit Markdown cells

Tap a Markdown cell, or tap its pencil, to edit it. Tap the pencil again to see it formatted. Markdown cells show headings (#, ##, ###), bulleted lists, and inline formatting such as bold, italics, and code.

Change, move, or delete a cell

On a cell, tap Cell actions (the three dots), and then tap one of these:
  • Run
  • Convert to Markdown or Convert to Code
  • Move Up or Move Down
  • Delete Cell

See your results

Below each code cell, Lectra shows:
  • Text that your code prints.
  • The value of the last line in the cell.
  • Charts from Matplotlib, as images.
  • Errors, in red.
Long output shows only its last 200 lines. Tap Show full output to see all of it.
pandas DataFrames show as plain text, not as formatted tables.

Load a data file

1

Tap Data

At the bottom of the notebook, tap Data, and then choose a CSV, TSV, or text file.
2

Choose the separator

In Import data, choose how values are separated: Comma, Tab, or Semicolon.
3

Choose how to load it

  • Tap Load as DataFrame to add a cell that reads the file into pandas.
  • Tap Just add the file to make the file available so you can read it with your own code.
The data file stays available only until you restart Python or close the notebook. After that, load it again.

Install a package

If a cell imports a package that isn’t installed, Lectra asks whether to download it. Tap Install. To manage packages, tap More (the three dots) > Manage Packages. To learn which packages are included and which you can add, see Run Python.

Save and share

Lectra saves your notebook automatically when you run cells, change the title, load data, or close it. There’s no Save button. To share a notebook, for example to submit it, tap More > Share Notebook (.ipynb). Lectra names the file after the notebook’s title.

Restart Python

Tap More > Restart Kernel. If a cell is running, this stops it. If nothing is running, it clears all variables, so you can start fresh. Your cells and their output stay. To close a notebook, tap Close.

Limits

  • There’s no button to clear outputs or to add a cell above another cell.
  • input() doesn’t ask you for text in a notebook. It returns an empty string.
  • Notebooks show text, images, and errors. Other kinds of output in a notebook you open, such as interactive widgets, aren’t shown, but Lectra keeps them in the file.
  • Files that your code writes aren’t saved. To learn more, see Run Python.

Troubleshooting

Python may still need its one-time download. Connect to the internet, and then run the cell again.
The file isn’t a valid .ipynb notebook. Download it again from its source, and then import it.
Tap More > Restart Kernel to stop it. If a single run takes longer than 3 minutes, Lectra stops waiting and shows “Python stopped responding”.
Variables don’t last after you close a notebook or restart Python. Tap Run All to run every cell again.

Run Python

Included packages, installing more, and limits.

Use the code editor

Work with project files and folders.