An Example Notebook

This notebook is meant for testing conversion to other formats.

It contains Markdown cells and code cells with different kinds of outputs.

Markdown

We can write in italics (same with underscores), in boldface (same with undescores) and [STRIKEOUT:strikethrough]. We also can write preformatted text.

Equations

Equations can be formatted really nicely, either inline, like \(\text{e}^{i\pi} = -1\), or on a separate line, like

\[\int_{-\infty}^\infty f(x) \delta(x - x_0) dx = f(x_0)\]

Code

We can also write code with nice syntax highlighting:

print("Hello, world!")

Tables

A B A and B
False False False
True False False
False True False
True True True

Images

Jupyter notebook icon (local): Jupyter notebook icon

Python logo (local): Python logo

Jupyter logo (remote): Jupyter logo (remote)

Python logo (remote): Python logo (remote)

Code Cells

An empty code cell:

A cell with no output:

None

A simple output:

6 * 7
42

The standard output stream:

print('Hello, world!')
Hello, world!

Normal output + standard output

print('Hello, world!')
6 * 7
Hello, world!
42

The standard error stream is highlighted and displayed just below the code cell. The standard output stream comes afterwards (with no special highlighting). Finally, the “normal” output is displayed.

import logging
logging.warning('I am a warning and I will appear on the standard error stream')
print('I will appear on the standard output stream')
'I am the "normal" output'
WARNING:root:I am a warning and I will appear on the standard error stream
I will appear on the standard output stream
'I am the "normal" output'

Special Display Formats

See IPython example notebook.

TODO: tables? e.g. Pandas DataFrame?

from IPython.display import display, Image, SVG, Math, YouTubeVideo

Local Image Files

i = Image(filename='images/notebook_icon.png')
i
_images/example_17_0.png
display(i)
_images/example_18_0.png

For some reason this doesn’t work with Image(...):

SVG(filename='images/python_logo.svg')

Image URLs

Image(url='https://www.python.org/static/img/python-logo-large.png')
Image(url='https://www.python.org/static/img/python-logo-large.png', embed=True)
_images/example_23_0.png
Image(url='http://jupyter.org/assets/nav_logo.svg')
Image(url='https://www.python.org/static/favicon.ico')
Image(url='http://python.org/images/python-logo.gif')

Math

eq = Math(r"\int_{-\infty}^\infty f(x) \delta(x - x_0) dx = f(x_0)")
eq
\[\int_{-\infty}^\infty f(x) \delta(x - x_0) dx = f(x_0)\]
display(eq)
\[\int_{-\infty}^\infty f(x) \delta(x - x_0) dx = f(x_0)\]
%%latex
\begin{equation}
\int_{-\infty}^\infty f(x) \delta(x - x_0) dx = f(x_0)
\end{equation}
\[\begin{equation} \int_{-\infty}^\infty f(x) \delta(x - x_0) dx = f(x_0) \end{equation}\]
YouTubeVideo('iV2ViNJFZC8')

Raw Cells

Raw cells are interpreted as reStructuredText and parsed by Sphinx.

Back to main page