Python code
Write Python in a lesson, run it in the browser, and explore DataFrames.
A code block set to Python runs right in the page. Nothing to install, for you or for your students: Python runs in their browser.
Adding a cell
Type /code in the editor and pick Code Block, then choose Python as its language. Every
Python block gets Run and Run all in its top right corner.
Running code
- Run runs this cell. A check mark and a counter (
[1],[2]โฆ) show that it ran. - Run all runs every Python cell from the top of the document down to this one, in order.
- While a cell runs, Run becomes Stop. A cell that runs longer than 30 seconds is stopped for you.
Cells share their variables, as in a notebook: define df in one cell and use it in the next.
Restart kernel, in the top bar, clears every variable and every output and starts fresh.
Import what you need: pandas, numpy, matplotlib and the other common scientific packages
install themselves the first time a cell imports them.
Reading the output
Text output shows its first three lines; Show all lines opens the rest. A matplotlib figure gives a Show image button.
Exploring a DataFrame
When a cell ends with a pandas DataFrame, press Show DataFrame under its output. The table opens full size:
- Search filters the rows across every column.
- Click a column name to sort it, once for ascending, twice for descending.
- Each column shows its type and a small histogram of its values.
- Rows come ten per page, with the total count at the bottom.
Who can run code
Everyone who can open the document runs it, students and visitors to a public course included. Each person runs their own copy: what a student runs does not change what others see. Students edit the code itself only where you enable student editing.