notebook-examples/usecase.ipynb

265 lines
9.7 KiB
Plaintext
Raw Normal View History

2024-06-14 10:58:25 +00:00
{
"cells": [
{
"cell_type": "markdown",
"metadata": {},
"source": [
"*this notebook works in any Sandbox environments* "
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"# Markdown\n",
"The following table shows the general description of the Markdwon syntax to format text."
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"| Markdown Syntax | Description |\n",
"| :------------------------------------------------ | :----------------------------------------------------------|\n",
"| ** text ** | format text as **bold** |\n",
"| * text * | format text as *italic* |\n",
"| *** text *** | format text as ***bold &italic*** |\n",
"| # Heading 1 | format text as Heading Level 1 |\n",
"| ## Heading 2 | format text as Heading Level 2 |\n",
"| ### Heading 3 | format text as Heading Level 3 |\n",
"| 1. Listitem <br> 2. Listitem <br> 3. Listitem | format list as Ordered List |\n",
"| * Listitem 1 <br> * Listitem 2 <br> * Listitem 3 | format list as Unordered List (instead of * it can be +, - used) |\n",
"| > blockqute | Blockquote |\n",
"| [ linkdescription ] ( http://URL ) | format text as link |\n",
"| ![ imagecaption ] ( /path/to/image ) | add image to text |\n",
"| --- | Horizontal Rule |\n",
"| ```python 3x(`) | can be used to show embed python syntax with highlighting |\n",
"| `code` (1x`) | can be used to show a small chunk of code |\n",
"|- [x] Write the press release | Tasklist |\n",
"| sup html tag >sup< | use sup tag to superscript characters |\n",
"| sub html tag >sub< | use sub tag to subscript characters |\n",
"\n",
" "
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"## example for markdown\n",
"the following text is just a placeholder to viszualize the text format. Inside the ***example*** all *markdown syntax* is used which is shown in the **table** above."
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"# Header first Level\n",
"Lorem ipsum dolor sit amet, consetetur sadipscing elitr, sed diam nonumy eirmod tempor invidunt ut labore et dolore magna aliquyam erat, sed diam voluptua. At vero eos et accusam et justo duo dolores et ea rebum. Stet clita kasd gubergren,\n",
"\n",
"## Header second level\n",
"Lorem ipsum dolor sit amet, consetetur sadipscing elitr, sed diam nonumy eirmod tempor invidunt ut labore et dolore magna aliquyam erat, sed diam voluptua. At vero eos et accusam et justo duo dolores et ea rebum. Stet clita kasd gubergren, ea rebum. Stet clita kasd gubergren, no sea takimata sanctus est Lorem **ipsum** dolor sit amet.\n",
"1. voluptua\n",
"2. magna\n",
"3. consetetur\n",
"\n",
"\n",
"<img src=\"cal_housing_scatter.png\" width=\"800\" height=\"400\">\n",
"\n",
"### Header third level\n",
"Lorem *ipsum* dolor sit amet, consetetur sadipscing elitr, sed diam nonumy eirmod tempor invidunt ut labore et dolore magna aliquyam erat, sed diam voluptua. At vero eos et accusam et justo duo dolores et ea rebum. Stet clita kasd gubergren,\n",
"* Lorem\n",
"* dolor\n",
"* ***gubergren***\n",
"\n",
"Lorem *ipsum* dolor sit amet, consetetur sadipscing elitr, sed diam nonumy eirmod tempor invidunt ut labore et dolore magna aliquyam erat, sed diam voluptua. At vero eos et accusam et justo duo dolores et ea rebum. Stet clita kasd gubergren,Lorem ipsum dolor sit amet, consetetur sadipscing elitr, sed diam nonumy eirmod tempor invidunt ut labore et dolore magna aliquyam erat, sed diam voluptua. At vero eos et accusam et justo duo dolores et ea rebum. Stet clita kasd gubergren, ea rebum. Stet clita kasd gubergren, no sea takimata sanctus est Lorem **ipsum** dolor \n",
"\n",
"```python\n",
"def foo(): \n",
" print(\"bar\")\n",
"\n",
"foo()\n",
"```\n",
"\n",
"Lorem *ipsum* dolor sit amet, consetetur sadipscing elitr, sed diam nonumy eirmod tempor invidunt ut labore et dolore magna aliquyam erat, sed diam voluptua. At vero eos et accusam et justo duo dolores et ea rebum. Stet clita kasd gubergren,Lorem ipsum dolor sit amet, consetetur sadipscing elitr, sed diam nonumy eirmod tempor invidunt ut labore et dolore magna aliquyam erat, sed diam voluptua.\n",
"\n",
"\n",
"\n",
"\n",
"\n",
"\n",
"![md](https://upload.wikimedia.org/wikipedia/commons/thumb/4/48/Markdown-mark.svg/208px-Markdown-mark.svg.png)\n",
"\n",
"if you want to know more about markdown syntax just use the [documentation](https://www.markdownguide.org)\n",
"\n",
"\n",
"\n"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"# *voilà*\n",
"\n",
"In the following examples **controls** are provided with *voila* to show or manipulate diagrams and create interactive notebooks.\n",
"\n",
"1. ***small number multiplicator*** for integers between 0 and 100"
]
},
{
"cell_type": "code",
"execution_count": 1,
"metadata": {
"scrolled": true
},
"outputs": [
{
"data": {
"application/vnd.jupyter.widget-view+json": {
"model_id": "04713a82a921423aa71381040a9d56a8",
"version_major": 2,
"version_minor": 0
},
"text/plain": [
"HBox(children=(VBox(children=(IntSlider(value=0), IntSlider(value=0))), Output()))"
]
},
"metadata": {},
"output_type": "display_data"
}
],
"source": [
"from ipywidgets import HBox, VBox, IntSlider, interactive_output\n",
"from IPython.display import display\n",
"\n",
"a = IntSlider()\n",
"b = IntSlider()\n",
"\n",
"def f(a, b):\n",
" print(\"{} * {} = {}\".format(a, b, a * b))\n",
"\n",
"out = interactive_output(f, { \"a\": a, \"b\": b })\n",
"\n",
"display(HBox([VBox([a, b]), out]))"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"2. Display **latex formulas** inside a notebook"
]
},
{
"cell_type": "code",
"execution_count": 2,
"metadata": {},
"outputs": [],
"source": [
"from IPython.display import display\n",
"from IPython.display import (\n",
" Latex, Math\n",
")"
]
},
{
"cell_type": "code",
"execution_count": 3,
"metadata": {},
"outputs": [
{
"data": {
"text/latex": [
"$F=ma$"
],
"text/plain": [
"<IPython.core.display.Latex object>"
]
},
"execution_count": 3,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"math = Latex(\"$F=ma$\")\n",
"math"
]
},
{
"cell_type": "code",
"execution_count": 4,
"metadata": {},
"outputs": [
{
"data": {
"text/latex": [
"\n",
"\\begin{align}\n",
"\\nabla \\times \\vec{\\mathbf{B}} -\\, \\frac1c\\, \\frac{\\partial\\vec{\\mathbf{E}}}{\\partial t} & = \\frac{4\\pi}{c}\\vec{\\mathbf{j}} \\\\ \\nabla \\cdot \\vec{\\mathbf{E}} & = 4 \\pi \\rho \\\\\n",
"\\nabla \\times \\vec{\\mathbf{E}}\\, +\\, \\frac1c\\, \\frac{\\partial\\vec{\\mathbf{B}}}{\\partial t} & = \\vec{\\mathbf{0}} \\\\\n",
"\\nabla \\cdot \\vec{\\mathbf{B}} & = 0\n",
"\\end{align}\n"
],
"text/plain": [
"<IPython.core.display.Latex object>"
]
},
"execution_count": 4,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"\n",
"maxwells = Latex(r\"\"\"\n",
"\\begin{align}\n",
"\\nabla \\times \\vec{\\mathbf{B}} -\\, \\frac1c\\, \\frac{\\partial\\vec{\\mathbf{E}}}{\\partial t} & = \\frac{4\\pi}{c}\\vec{\\mathbf{j}} \\\\ \\nabla \\cdot \\vec{\\mathbf{E}} & = 4 \\pi \\rho \\\\\n",
"\\nabla \\times \\vec{\\mathbf{E}}\\, +\\, \\frac1c\\, \\frac{\\partial\\vec{\\mathbf{B}}}{\\partial t} & = \\vec{\\mathbf{0}} \\\\\n",
"\\nabla \\cdot \\vec{\\mathbf{B}} & = 0\n",
"\\end{align}\n",
"\"\"\")\n",
"maxwells"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"$$a = b + c$$ (line break after the equation)"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"$$a = b + c$$ \n",
"\n",
"## (line break after the equation)"
]
}
],
"metadata": {
"kernelspec": {
"display_name": "Python 3 (ipykernel)",
"language": "python",
"name": "python3"
},
"language_info": {
"codemirror_mode": {
"name": "ipython",
"version": 3
},
"file_extension": ".py",
"mimetype": "text/x-python",
"name": "python",
"nbconvert_exporter": "python",
"pygments_lexer": "ipython3",
"version": "3.11.7"
}
},
"nbformat": 4,
"nbformat_minor": 4
}