Code Cells¶
An empty code cell:
In [1]:
A cell with no output:
In [1]:
None
A simple output:
In [2]:
6 * 7
Out[2]:
42
The standard output stream:
In [3]:
print('Hello, world!')
Hello, world!
Normal output + standard output
In [4]:
print('Hello, world!')
6 * 7
Hello, world!
Out[4]:
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.
In [5]:
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
Out[5]:
'I am the "normal" output'
Special Display Formats¶
TODO: tables? e.g. Pandas DataFrame?
In [6]:
from IPython.display import display, Image, SVG, Math, YouTubeVideo
Local Image Files¶
In [7]:
i = Image(filename='images/notebook_icon.png')
i
Out[7]:
In [8]:
display(i)
For some reason this doesn’t work with Image(...)
:
In [9]:
SVG(filename='images/python_logo.svg')
Out[9]:
Image URLs¶
In [10]:
Image(url='https://www.python.org/static/img/python-logo-large.png')
Out[10]:
In [11]:
Image(url='https://www.python.org/static/img/python-logo-large.png', embed=True)
Out[11]:
In [12]:
Image(url='http://jupyter.org/assets/nav_logo.svg')
Out[12]:
In [13]:
Image(url='https://www.python.org/static/favicon.ico')
Out[13]:
In [14]:
Image(url='http://python.org/images/python-logo.gif')
Out[14]:
Math¶
In [15]:
eq = Math(r"\int_{-\infty}^\infty f(x) \delta(x - x_0) dx = f(x_0)")
eq
Out[15]:
\[\int_{-\infty}^\infty f(x) \delta(x - x_0) dx = f(x_0)\]
In [16]:
display(eq)
\[\int_{-\infty}^\infty f(x) \delta(x - x_0) dx = f(x_0)\]
In [17]:
%%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}\]
In [18]:
YouTubeVideo('iV2ViNJFZC8')
Out[18]: