Commit 82976a53 authored by Andrei - Tudor Corduneanu's avatar Andrei - Tudor Corduneanu
Browse files

last_version with docker

parent 38cf9487
This diff is collapsed.
FROM jupyter/scipy-notebook:584f43f06586
RUN pip install \
jupyter_contrib_nbextensions==0.5.1 \
autopep8==1.5.6
RUN jupyter contrib nbextension install --user
RUN git clone https://gitlab.poul.org/corsi/jupyter-poul-theme.git .theme; \
pip install ./.theme
RUN jt -t poul -tfs 25 -fs 25 -ofs 25 -cellw 80%
COPY --chown=jovyan:users ./config/ /home/jovyan/
ENTRYPOINT start-notebook.sh
%% Cell type:markdown id: tags:
# Esempi Introduzione a Python
%% Cell type:markdown id: tags:
## Espressioni
%% Cell type:code id: tags:
``` python
2 + 2
```
%% Cell type:code id: tags:
``` python
3 * 3
```
%% Cell type:code id: tags:
``` python
4 < 5
```
%% Cell type:markdown id: tags:
## Commenti
%% Cell type:code id: tags:
``` python
print('ciao') # Ciao, io sono un commento
```
%% Cell type:markdown id: tags:
## Errori
%% Cell type:code id: tags:
``` python
3 / 0
```
%% Cell type:markdown id: tags:
## Variabili
%% Cell type:code id: tags:
``` python
x = 6
y = 2
```
%% Cell type:code id: tags:
``` python
x
```
%% Cell type:code id: tags:
``` python
y
```
%% Cell type:code id: tags:
``` python
2 * y
```
%% Cell type:code id: tags:
``` python
x + y
```
%% Cell type:code id: tags:
``` python
z = x + y
```
%% Cell type:code id: tags:
``` python
z
```
%% Cell type:markdown id: tags:
## Liste
%% Cell type:code id: tags:
``` python
lista = [False, 1, "due", 3.0, 4, 5]
```
%% Cell type:code id: tags:
``` python
lista
```
%% Cell type:code id: tags:
``` python
lista[0] = 0.0
```
%% Cell type:code id: tags:
``` python
lista
```
%% Cell type:code id: tags:
``` python
lista.append('sei')
```
%% Cell type:code id: tags:
``` python
lista
```
%% Cell type:code id: tags:
``` python
lista.remove('sei')
```
%% Cell type:code id: tags:
``` python
lista
```
%% Cell type:code id: tags:
``` python
lista.reverse()
```
%% Cell type:code id: tags:
``` python
lista
```
%% Cell type:code id: tags:
``` python
len(lista)
```
%% Cell type:markdown id: tags:
## Tuple
%% Cell type:code id: tags:
``` python
tupla = ('a', 1, 2, '3.0')
```
%% Cell type:code id: tags:
``` python
tupla
```
%% Cell type:code id: tags:
``` python
tupla[1] = 1.0
```
%% Cell type:code id: tags:
``` python
tupla.append('sei')
```
%% Cell type:markdown id: tags:
## Dizionari
%% Cell type:code id: tags:
``` python
d = {"chiave": "valore",
"nome":"Tancredi",
"cognome":"Orlando",
('immutable', 'types'): ['are', 'cool']
}
```
%% Cell type:code id: tags:
``` python
d
```
%% Cell type:code id: tags:
``` python
d['nome']
```
%% Cell type:code id: tags:
``` python
z = d[('immutable', 'types')]
```
%% Cell type:code id: tags:
``` python
print('these things ' + z[0] + ' ' + z[1])
```
%% Cell type:markdown id: tags:
## Formattazione Output
%% Cell type:code id: tags:
``` python
s = 'Corsi {} {}'
```
%% Cell type:code id: tags:
``` python
s.format('Python', '2019')
```
%% Cell type:code id: tags:
``` python
s.format('Linux', 'base')
```
%% Cell type:code id: tags:
``` python
s = 'Corsi {argomento} {tipo}'
```
%% Cell type:code id: tags:
``` python
s.format(tipo = 'avanzati', argomento = 'Linux')
```
%% Cell type:code id: tags:
``` python
nome = input("Inserisci il tuo nome: ")
```
%% Cell type:code id: tags:
``` python
'Il tuo nome è {}.'.format(nome)
```
%% Cell type:markdown id: tags:
## Controllo Flusso
%% Cell type:code id: tags:
``` python
for i in [0, 1, 2, 3, 4]:
print(i)
```
%% Cell type:code id: tags:
``` python
for i in range(0,5):
print(i)
```
%% Cell type:code id: tags:
``` python
for i in lista:
print(i)
```
%% Cell type:code id: tags:
``` python
for i in [0, 1, 2, 3, 4, 5, 6, 7]:
if i == 2:
continue
if i == 6:
break
print(i)
```
%% Cell type:markdown id: tags:
## Funzioni
%% Cell type:code id: tags:
``` python
def say_hello():
print("Hello, world!")
```
%% Cell type:code id: tags:
``` python
say_hello()
say_hello()
```
%% Cell type:markdown id: tags:
%% Cell type:code id: tags:
``` python
def somma(a, b):
return a + b
```
%% Cell type:code id: tags:
``` python
somma(1, 2)
```
%% Cell type:code id: tags:
``` python
a = 3
b = 14
```
%% Cell type:code id: tags:
``` python
c = somma(a, b)
c
```
%% Cell type:code id: tags:
``` python
def f(a, b = 3, c = 6):
print(a, b, c)
```
%% Cell type:code id: tags:
``` python
f(1)
```
%% Cell type:code id: tags:
``` python
f(1, 2)
```
%% Cell type:code id: tags:
``` python
f(1, c = 4)
```
%% Cell type:code id: tags:
``` python
f(c = 10, a = 8, b = 3)
```
%% Cell type:markdown id: tags:
%% Cell type:code id: tags:
``` python
def somma_migliorata(*args):
accumulatore = 0
for i in args:
accumulatore += i
return accumulatore
```
%% Cell type:code id: tags:
``` python
somma_migliorata(4,7)
```
%% Cell type:code id: tags:
``` python
somma_migliorata(1,2,3,4)
```
%% Cell type:code id: tags:
``` python
def operazione(*args, **kwargs):
if kwargs['operazione'] == 'somma':
accumulatore = 0
for i in args:
accumulatore += i
elif kwargs['operazione'] == 'moltiplicazione':
accumulatore = 1
for i in args:
accumulatore *= i
return accumulatore
```
%% Cell type:code id: tags:
``` python
operazione(1,2,3,4,5,6,7,8, operazione = 'somma')
```
%% Cell type:code id: tags:
``` python
operazione(1,2,3,4,5,6,7,8, operazione = 'moltiplicazione')
```
%% Cell type:markdown id: tags:
## Scoping
%% Cell type:code id: tags:
``` python
x = 'globale'
def f():
x = 'locale'
```
%% Cell type:code id: tags:
``` python
f()
x
```
%% Cell type:code id: tags:
``` python
x = 'globale'
def f():
print(x)
f()
```
%% Cell type:code id: tags:
``` python
def f():
print(x)
x = 'variabile ' + x
```
%% Cell type:code id: tags:
``` python
f()
```
%% Cell type:markdown id: tags:
## Null
%% Cell type:code id: tags:
``` python
def p():
print("Sono una funzione")
x = p()
```
%% Cell type:code id: tags:
``` python
x is None
```
This diff is collapsed.
# POuL reveal.js template # Jupyter notebook POuL
This is a base template that will allow you to make state-of-art presentations This Jupyter notebook container includes the POuL template and some plugin useful for the python talk.
using advanced technologies such as Markdown, reveal.js (thus the
industry-standard language JavaScript), still complying with the mandatory
design guidelines.
## Getting Started ## Plugins
In order for the slides to work (ie. display anything) you need to run: - autoscroller to the selected cell
`git submodule update --init --depth 1` - reveals one cell at a time
In case you need the mathjax submodule as well ## Use
`git submodule update --init --depth 1 --recursive`
## How do I use this thing? ### Build image
### Where do I write my stuff? ```
docker build -t poul/jupyter-notebook .
```
[Download][download] this repo and put your content inside the 'content.md' ### Run container
file placed in the root of this directory. What were you expecting?
### How do I write my stuff? Move you to the project folder and run
Using a text editor and typing Markdown syntax on your keyboard. ```
docker run --name jupyter -p 8888:8888 -v $PWD:/home/jovyan/work --rm poul/jupyter-notebook
```
[Here][markdown-guide] you can find a comprehensive guide to the syntax. Jupyter will be available at the address [http://127.0.0.1:8888](http://127.0.0.1:8888)
Remember to use three dashes (`---`) to create a new slide horizontally and
four dashes (`----`) to create a new one vertically.
### How do I see my stuff?
Make sure you have Python 3 installed. Nothing more is required.
Make the deploy.py script executable with
chmod +x deploy.py
Then just run
./deploy.py --show
A new tab will open in your default browser showing the presentation.
You can spacify your browser using the `BROWSER` environment variable.
BROWSER=surf ./deploy.py --show
You can see what kind of trickery this script is able to do running it with the
`-h` or `--help` flag.
#### Why?
This is required since modern browsers won't allow you to include a local file
(the Markdown document) from JavaScript.
The Python script will run a small HTTP server and fix this issue.
## How do I make a PDF out of the slides?
Append `?print-pdf` at the end of the URL.
For instance if you're running the `deploy.py` script locally the URL will be
something like `http://127.0.0.1:8080/?print-pdf`.
Then just use the print function of your browser to make a PDF of the page.
On **Firefox** it is advised to enable *Print Backgrounds* under the *Options* tab,
to select paper size *Choukei 2 Envelope* and *Landscape* orientation.
[download]: https://gitlab.poul.org/corsi/revealjs-poul/repository/archive.zip?ref=master
[markdown-guide]: https://github.com/adam-p/markdown-here/wiki/Markdown-Cheatsheet
import matplotlib.pyplot as plt
from jupyterthemes import jtplot
jtplot.style(
context="notebook",
theme="chesterish",
figsize=(14.,8.),
fscale=1.4,
spines=False,
gridlines="--")
## custom.css
The theme is based on `chesterish` from project [jupyter-themes](https://github.com/dunovank/jupyter-themes) relased under `MIT License`.
The base theme are got with
```sh
jt -t chesterish -tfs 25 -fs 25 -ofs 25 -cellw 80%
```
### changes
- Remove colored border in the middle
Delete rows
```css
border-right: 2px solid rgba(0,156,209,.5);
```
- Add some margin between cells
```css
.cell {
margin: 5vh 0 !important;
}