Demo of RISE for slides with Jupyter notebooks (Python)

By Lilian Besson, Sept.2017.


Title 2

Title 3

Title 4

Title 5
Title 6

Text

With text, emphasis, bold, striked, inline code and

Quote.

-- By a guy.

Maths

With inline math $\sin(x)^2 + \cos(x)^2 = 1$ and equations: $$\sin(x)^2 + \cos(x)^2 = \left(\frac{\mathrm{e}^{ix} - \mathrm{e}^{-ix}}{2i}\right)^2 + \left(\frac{\mathrm{e}^{ix} + \mathrm{e}^{-ix}}{2}\right)^2 = \frac{-\mathrm{e}^{2ix}-\mathrm{e}^{-2ix}+2 \; ++\mathrm{e}^{2ix}+\mathrm{e}^{-2ix}+2}{4} = 1.$$

And code

In Markdown:

from sys import version
print(version)

And in a executable cell (with Python 3 kernel) :

In [1]:
from sys import version
print(version)
3.6.9 (default, Oct  8 2020, 12:12:24) 
[GCC 8.4.0]

More demo of Markdown code

Lists

  • Unordered
  • lists
  • are easy.

And

  1. and ordered also ! Just
  2. start lines by 1., 2. etc
  3. or simply 1., 1., ...

Images

With a HTML <img/> tag or the ![alt](url) Markdown code:

agreg/images/dooku.jpg

In [8]:
# https://gist.github.com/dm-wyncode/55823165c104717ca49863fc526d1354
"""Embed a YouTube video via its embed url into a notebook."""
from functools import partial

from IPython.display import display, IFrame

width, height = (560, 315, )

def _iframe_attrs(embed_url):
    """Get IFrame args."""
    return (
        ('src', 'width', 'height'), 
        (embed_url, width, height, ),
    )

def _get_args(embed_url):
    """Get args for type to create a class."""
    iframe = dict(zip(*_iframe_attrs(embed_url)))
    attrs = {
        'display': partial(display, IFrame(**iframe)),
    }
    return ('YouTubeVideo', (object, ), attrs, )

def youtube_video(embed_url):
    """Embed YouTube video into a notebook.

    Place this module into the same directory as the notebook.

    >>> from embed import youtube_video
    >>> youtube_video(url).display()
    """
    YouTubeVideo = type(*_get_args(embed_url)) # make a class
    return YouTubeVideo() # return an object
Out[8]:
'Embed a YouTube video via its embed url into a notebook.'

And Markdown can include raw HTML

This is a centered span, colored in green.

Iframes are disabled by default, but by using the IPython internals we can include let say a YouTube video:

In [9]:
youtube_video("https://www.youtube.com/embed/FNg5_2UUCNU").display()
In [3]:
print(2**2021)
240780458385579342400393461351617812815637161357071131707208942081962936661153218844512115504763375697200879163458183553026017242301187821441055479544760906104973534996069938628004474568289906582206917095065620305216254432816950650228843795794816095162791355341943390986975847866692139272448065870433527123346286515814575123941041341323886584452213168407427683905346733773730890398535581783579726464034446453496393589067919979673611753823620422962335479358086639875375670825770647896268644196740771259886611570273762180917307714137084771977480688440721015151914970095703226362506437887288273484956889253937152

End of this demo