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
{
"cells": [
{
"cell_type": "markdown",
"metadata": {},
"source": [
"# Esempi Introduzione a Python"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"## Espressioni"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": [
"2 + 2"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": [
"3 * 3"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": [
"4 < 5"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"## Commenti"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": [
"print('ciao') # Ciao, io sono un commento"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"## Errori"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": [
"3 / 0"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"## Variabili"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": [
"x = 6\n",
"y = 2"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": [
"x"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": [
"y"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": [
"2 * y"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": [
"x + y"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": [
"z = x + y"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": [
"z"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"## Liste"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": [
"lista = [False, 1, \"due\", 3.0, 4, 5]"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": [
"lista"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": [
"lista[0] = 0.0"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": [
"lista"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": [
"lista.append('sei')"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": [
"lista"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": [
"lista.remove('sei')"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": [
"lista"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": [
"lista.reverse()"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": [
"lista"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": [
"len(lista)"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"## Tuple"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": [
"tupla = ('a', 1, 2, '3.0')"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": [
"tupla"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": [
"tupla[1] = 1.0"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": [
"tupla.append('sei')"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"## Dizionari"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": [
"d = {\"chiave\": \"valore\",\n",
" \"nome\":\"Tancredi\",\n",
" \"cognome\":\"Orlando\",\n",
" ('immutable', 'types'): ['are', 'cool'] \n",
" }"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": [
"d"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": [
"d['nome']"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": [
"z = d[('immutable', 'types')]"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": [
"print('these things ' + z[0] + ' ' + z[1])"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"## Formattazione Output"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": [
"s = 'Corsi {} {}'"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": [
"s.format('Python', '2019')"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": [
"s.format('Linux', 'base')"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": [
"s = 'Corsi {argomento} {tipo}'"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": [
"s.format(tipo = 'avanzati', argomento = 'Linux')"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": [
"nome = input(\"Inserisci il tuo nome: \")"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": [
"'Il tuo nome è {}.'.format(nome)"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"## Controllo Flusso"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": [
"for i in [0, 1, 2, 3, 4]:\n",
" print(i)"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": [
"for i in range(0,5):\n",
" print(i)"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": [
"for i in lista:\n",
" print(i)"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": [
"for i in [0, 1, 2, 3, 4, 5, 6, 7]:\n",
" if i == 2:\n",
" continue\n",
" if i == 6:\n",
" break\n",
" print(i)"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"## Funzioni"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": [
"def say_hello():\n",
" print(\"Hello, world!\")"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": [
"say_hello()\n",
"say_hello()"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
" "
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": [
"def somma(a, b):\n",
" return a + b"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": [
"somma(1, 2)"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": [
"a = 3\n",
"b = 14"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": [
"c = somma(a, b)\n",
"c"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": [
"def f(a, b = 3, c = 6):\n",
" print(a, b, c)"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": [
"f(1)"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": [
"f(1, 2)"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": [
"f(1, c = 4)"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": [
"f(c = 10, a = 8, b = 3)"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
" \n",
" "
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": [
"def somma_migliorata(*args):\n",
" accumulatore = 0\n",
" for i in args:\n",
" accumulatore += i\n",
" return accumulatore"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": [
"somma_migliorata(4,7)"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": [
"somma_migliorata(1,2,3,4)"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": [
"def operazione(*args, **kwargs):\n",
" if kwargs['operazione'] == 'somma':\n",
" accumulatore = 0\n",
" for i in args:\n",
" accumulatore += i\n",
" elif kwargs['operazione'] == 'moltiplicazione':\n",
" accumulatore = 1\n",
" for i in args:\n",
" accumulatore *= i\n",
" return accumulatore"
]