1003 lines
41 KiB
Plaintext
1003 lines
41 KiB
Plaintext
|
{
|
||
|
"cells": [
|
||
|
{
|
||
|
"cell_type": "markdown",
|
||
|
"metadata": {},
|
||
|
"source": [
|
||
|
"# Mémo Python\n",
|
||
|
"\n",
|
||
|
"[Python par Repl.it](#Avec-Repl.it)\n",
|
||
|
"\n",
|
||
|
"-----------\n",
|
||
|
"Notions de programmation\n",
|
||
|
"* [Les variables](#Les-variables)\n",
|
||
|
"* [input](#input)\n",
|
||
|
"* [Les conditions if](#Condition-if)\n",
|
||
|
"* [Les boucles for](#Boucles-for)\n",
|
||
|
"* [Les boucles while](#Boucles-while)\n",
|
||
|
"* [Les fonctions](#Fonctions)\n",
|
||
|
"* [Les listes](#Listes)\n",
|
||
|
"* [Les graphiques](#Graphiques)\n",
|
||
|
"------------\n",
|
||
|
"Ressouces Python\n",
|
||
|
"* [site du zero](http://openclassrooms.com/courses/apprenez-a-programmer-en-python) (cours en ligne)\n",
|
||
|
"* [codeacademy](http://www.codecademy.com/) (cours en ligne)\n",
|
||
|
"* [code conbat](http://codecombat.com) (jeu en ligne qui se joue en codant)\n",
|
||
|
"* [checkio](http://www.checkio.org/) (jeu en ligne - anglais - avec beaucoup de langage différents)"
|
||
|
]
|
||
|
},
|
||
|
{
|
||
|
"cell_type": "markdown",
|
||
|
"metadata": {},
|
||
|
"source": [
|
||
|
"## Avec Repl.it\n",
|
||
|
"\n",
|
||
|
"Se rendre sur le site de [repl.it](https://repl.it/repls/SpiffyOpulentBackend). \n",
|
||
|
"\n",
|
||
|
"L'interface se sépare en 2 parties:\n",
|
||
|
"\n",
|
||
|
"![interface replit](./fig/replit_global.png)\n",
|
||
|
"\n",
|
||
|
"- **Zone Script**: Éditeur de texte où l'on pourra écrire notre programme python. Pour executer son contenu, il faudra cliquer sur ![replit run](./fig/replit_run.png)\n",
|
||
|
"- **Zone Shell**: Line de commande pour interagir avec python. Ici vous pouvez tester vos commandes python et presser la touche *entrer* pour l'executer. Par contre on ne peut pas écrire sur plusieurs lignes.\n",
|
||
|
"\n",
|
||
|
"Il est conseillé d'utiliser en priorité la **zone script** car elle permet d'écrire sur plusieurs lignes et de corriger après l'execution. La **zone shell** servira à tester des commandes pour voir directement leurs effets. \n",
|
||
|
"\n",
|
||
|
"Pour sauvergarder votre travail, vous cliquerez sur les 3 points à côté de *Files* puis sur *download as zip*.\n",
|
||
|
"\n",
|
||
|
"![replit save](./fig/replit_files.png)"
|
||
|
]
|
||
|
},
|
||
|
{
|
||
|
"cell_type": "markdown",
|
||
|
"metadata": {},
|
||
|
"source": [
|
||
|
"## Les variables\n",
|
||
|
"\n",
|
||
|
"Les variables sont des *enveloppes* où l'on stockera des nombres, des mots, des phrases ou des choses plus compliqués."
|
||
|
]
|
||
|
},
|
||
|
{
|
||
|
"cell_type": "code",
|
||
|
"execution_count": 1,
|
||
|
"metadata": {},
|
||
|
"outputs": [],
|
||
|
"source": [
|
||
|
"un_nombre = 10"
|
||
|
]
|
||
|
},
|
||
|
{
|
||
|
"cell_type": "markdown",
|
||
|
"metadata": {},
|
||
|
"source": [
|
||
|
"Ainsi dans *l'enveloppe* appelée **un_nombre** on y met le nombre 10.\n",
|
||
|
"\n",
|
||
|
"C'est ce que l'on appelle **assigner** une **valeur** à une variable ou **stocker** une valeur dans une variable."
|
||
|
]
|
||
|
},
|
||
|
{
|
||
|
"cell_type": "code",
|
||
|
"execution_count": 2,
|
||
|
"metadata": {},
|
||
|
"outputs": [
|
||
|
{
|
||
|
"name": "stdout",
|
||
|
"output_type": "stream",
|
||
|
"text": [
|
||
|
"10\n"
|
||
|
]
|
||
|
}
|
||
|
],
|
||
|
"source": [
|
||
|
"un_nombre = 10\n",
|
||
|
"print(un_nombre) "
|
||
|
]
|
||
|
},
|
||
|
{
|
||
|
"cell_type": "markdown",
|
||
|
"metadata": {},
|
||
|
"source": [
|
||
|
"Pour stocker des mots ou des phrases, il faut les mettre entre guillemets"
|
||
|
]
|
||
|
},
|
||
|
{
|
||
|
"cell_type": "code",
|
||
|
"execution_count": 3,
|
||
|
"metadata": {},
|
||
|
"outputs": [],
|
||
|
"source": [
|
||
|
"un_mot = \"Coucou\"\n",
|
||
|
"une_phrase = \"ceci est une phrase\""
|
||
|
]
|
||
|
},
|
||
|
{
|
||
|
"cell_type": "markdown",
|
||
|
"metadata": {},
|
||
|
"source": [
|
||
|
"\n",
|
||
|
"## input\n",
|
||
|
"\n",
|
||
|
"Contrairement à ce que l'on a fait hier on ne met plus rien dans les parenthèses d'un `input`.\n",
|
||
|
"\n",
|
||
|
"`input()` est une commande qui va demander à l'utilisateur une information "
|
||
|
]
|
||
|
},
|
||
|
{
|
||
|
"cell_type": "code",
|
||
|
"execution_count": 4,
|
||
|
"metadata": {},
|
||
|
"outputs": [
|
||
|
{
|
||
|
"name": "stdout",
|
||
|
"output_type": "stream",
|
||
|
"text": [
|
||
|
"Comment t'appelles tu?\n",
|
||
|
"bobo\n",
|
||
|
"Ah! Tu t'appelles bobo\n"
|
||
|
]
|
||
|
}
|
||
|
],
|
||
|
"source": [
|
||
|
"print(\"Comment t'appelles tu?\")\n",
|
||
|
"nom = input()\n",
|
||
|
"print(\"Ah! Tu t'appelles\", nom)"
|
||
|
]
|
||
|
},
|
||
|
{
|
||
|
"cell_type": "markdown",
|
||
|
"metadata": {},
|
||
|
"source": [
|
||
|
"Après avoir afficher la question, l'ordinateur se met en pose et attend que l'utilisateur réponde quelque chose. Une fois que l'utilisateur a répondu (a appuyé sur `entrer`) la réponse est stocké, ici, dans la variable `nom`."
|
||
|
]
|
||
|
},
|
||
|
{
|
||
|
"cell_type": "markdown",
|
||
|
"metadata": {},
|
||
|
"source": [
|
||
|
"## Condition if\n",
|
||
|
"\n",
|
||
|
"Pour différencier plusieurs cas, on utilisera la commande `if` (si), `elif` (sinon si) et `else` (sinon)."
|
||
|
]
|
||
|
},
|
||
|
{
|
||
|
"cell_type": "code",
|
||
|
"execution_count": 5,
|
||
|
"metadata": {},
|
||
|
"outputs": [
|
||
|
{
|
||
|
"name": "stdout",
|
||
|
"output_type": "stream",
|
||
|
"text": [
|
||
|
"a est plus petit que b\n"
|
||
|
]
|
||
|
}
|
||
|
],
|
||
|
"source": [
|
||
|
"a = 2\n",
|
||
|
"b = 3\n",
|
||
|
"\n",
|
||
|
"if a > b: # Si\n",
|
||
|
" print(\"a plus grand que b\")\n",
|
||
|
"elif a == b: # Sinon si\n",
|
||
|
" print(\"a est égal à b\")\n",
|
||
|
"else: # Sinon\n",
|
||
|
" print(\"a est plus petit que b\")"
|
||
|
]
|
||
|
},
|
||
|
{
|
||
|
"cell_type": "markdown",
|
||
|
"metadata": {},
|
||
|
"source": [
|
||
|
"## Boucles for\n",
|
||
|
"\n",
|
||
|
"Les boucles **for** permettent de répéter un certain nombre de fois la même action.\n",
|
||
|
"\n",
|
||
|
"* Générer plusieurs valeurs:"
|
||
|
]
|
||
|
},
|
||
|
{
|
||
|
"cell_type": "code",
|
||
|
"execution_count": 6,
|
||
|
"metadata": {},
|
||
|
"outputs": [
|
||
|
{
|
||
|
"name": "stdout",
|
||
|
"output_type": "stream",
|
||
|
"text": [
|
||
|
"0\n",
|
||
|
"1\n",
|
||
|
"2\n",
|
||
|
"3\n",
|
||
|
"4\n",
|
||
|
"5\n",
|
||
|
"6\n",
|
||
|
"7\n",
|
||
|
"8\n",
|
||
|
"9\n"
|
||
|
]
|
||
|
}
|
||
|
],
|
||
|
"source": [
|
||
|
"for x in range(10):\n",
|
||
|
" print(x)"
|
||
|
]
|
||
|
},
|
||
|
{
|
||
|
"cell_type": "markdown",
|
||
|
"metadata": {},
|
||
|
"source": [
|
||
|
"Python a créé une variable `x` puis lui a fait prendre toutes les valeurs entre 0 et 9.\n",
|
||
|
"\n",
|
||
|
"* Ajouter 5 fois 100 d'affilé"
|
||
|
]
|
||
|
},
|
||
|
{
|
||
|
"cell_type": "code",
|
||
|
"execution_count": 7,
|
||
|
"metadata": {},
|
||
|
"outputs": [
|
||
|
{
|
||
|
"name": "stdout",
|
||
|
"output_type": "stream",
|
||
|
"text": [
|
||
|
"Au debut a vaut 2\n",
|
||
|
"a vaut maintenant 102\n",
|
||
|
"a vaut maintenant 202\n",
|
||
|
"a vaut maintenant 302\n",
|
||
|
"a vaut maintenant 402\n",
|
||
|
"a vaut maintenant 502\n",
|
||
|
"Finalement a vaut 502\n"
|
||
|
]
|
||
|
}
|
||
|
],
|
||
|
"source": [
|
||
|
"a = 2\n",
|
||
|
"print(\"Au debut a vaut\", a)\n",
|
||
|
"for i in range(5):\n",
|
||
|
" a = a + 100\n",
|
||
|
" print(\"a vaut maintenant\", a)\n",
|
||
|
"print(\"Finalement a vaut\", a)"
|
||
|
]
|
||
|
},
|
||
|
{
|
||
|
"cell_type": "markdown",
|
||
|
"metadata": {},
|
||
|
"source": [
|
||
|
"* On peut aussi parcourir les lettres d'un mot ou d'une phrase"
|
||
|
]
|
||
|
},
|
||
|
{
|
||
|
"cell_type": "code",
|
||
|
"execution_count": 8,
|
||
|
"metadata": {},
|
||
|
"outputs": [
|
||
|
{
|
||
|
"name": "stdout",
|
||
|
"output_type": "stream",
|
||
|
"text": [
|
||
|
"On enumere >>> boujour toi\n",
|
||
|
"b\n",
|
||
|
"o\n",
|
||
|
"u\n",
|
||
|
"j\n",
|
||
|
"o\n",
|
||
|
"u\n",
|
||
|
"r\n",
|
||
|
" \n",
|
||
|
"t\n",
|
||
|
"o\n",
|
||
|
"i\n",
|
||
|
"Toutes les lettres ont été énumérées\n"
|
||
|
]
|
||
|
}
|
||
|
],
|
||
|
"source": [
|
||
|
"phrase = \"boujour toi\"\n",
|
||
|
"print(\"On enumere >>> \", phrase)\n",
|
||
|
"for l in phrase:\n",
|
||
|
" print(l)\n",
|
||
|
"print(\"Toutes les lettres ont été énumérées\")"
|
||
|
]
|
||
|
},
|
||
|
{
|
||
|
"cell_type": "markdown",
|
||
|
"metadata": {},
|
||
|
"source": [
|
||
|
"* Ou encore tous les éléments d'une liste"
|
||
|
]
|
||
|
},
|
||
|
{
|
||
|
"cell_type": "code",
|
||
|
"execution_count": 9,
|
||
|
"metadata": {},
|
||
|
"outputs": [
|
||
|
{
|
||
|
"name": "stdout",
|
||
|
"output_type": "stream",
|
||
|
"text": [
|
||
|
"On enumère >>> ['premier element', 2, 'coucou', 1, 'aie', 0]\n",
|
||
|
"premier element\n",
|
||
|
"2\n",
|
||
|
"coucou\n",
|
||
|
"1\n",
|
||
|
"aie\n",
|
||
|
"0\n",
|
||
|
"Tout a été énuméré\n"
|
||
|
]
|
||
|
}
|
||
|
],
|
||
|
"source": [
|
||
|
"liste = [\"premier element\", 2, \"coucou\", 1, \"aie\", 0]\n",
|
||
|
"print(\"On enumère >>>\", liste)\n",
|
||
|
"for i in liste:\n",
|
||
|
" print(i)\n",
|
||
|
"print(\"Tout a été énuméré\")"
|
||
|
]
|
||
|
},
|
||
|
{
|
||
|
"cell_type": "markdown",
|
||
|
"metadata": {},
|
||
|
"source": [
|
||
|
"## Boucles while\n",
|
||
|
"\n",
|
||
|
"En anglais, `while` signifie **tant que**. On l'utilisera quand on veut refaire quelque plusieurs fois **tant que** quelque chose n'est pas vrais.\n",
|
||
|
"\n",
|
||
|
"Ajouter 3 **tant que** que `u` n'a pas dépassé 19: "
|
||
|
]
|
||
|
},
|
||
|
{
|
||
|
"cell_type": "code",
|
||
|
"execution_count": 10,
|
||
|
"metadata": {},
|
||
|
"outputs": [
|
||
|
{
|
||
|
"name": "stdout",
|
||
|
"output_type": "stream",
|
||
|
"text": [
|
||
|
"u vaut 5\n",
|
||
|
"u vaut 8\n",
|
||
|
"u vaut 11\n",
|
||
|
"u vaut 14\n",
|
||
|
"u vaut 17\n",
|
||
|
"u vaut 20\n",
|
||
|
"u a depassé 50 et vaut 20\n"
|
||
|
]
|
||
|
}
|
||
|
],
|
||
|
"source": [
|
||
|
"u = 2\n",
|
||
|
"while u < 19:\n",
|
||
|
" u = u + 3\n",
|
||
|
" print(\"u vaut \", u)\n",
|
||
|
"print(\"u a depassé 50 et vaut\", u)"
|
||
|
]
|
||
|
},
|
||
|
{
|
||
|
"cell_type": "markdown",
|
||
|
"metadata": {},
|
||
|
"source": [
|
||
|
"Poser toujours la même question quand que l'utilisateur n'a pas bien répondu:"
|
||
|
]
|
||
|
},
|
||
|
{
|
||
|
"cell_type": "code",
|
||
|
"execution_count": 11,
|
||
|
"metadata": {},
|
||
|
"outputs": [
|
||
|
{
|
||
|
"name": "stdout",
|
||
|
"output_type": "stream",
|
||
|
"text": [
|
||
|
"Quelle est la couleur du cheval blanc d'Henri 4?\n",
|
||
|
"vert\n",
|
||
|
"Non! Recommence!\n",
|
||
|
"Quelle est la couleur du cheval blanc d'Henri 4?\n",
|
||
|
"rouge\n",
|
||
|
"Non! Recommence!\n",
|
||
|
"Quelle est la couleur du cheval blanc d'Henri 4?\n",
|
||
|
"blanc\n",
|
||
|
"Bravo!\n",
|
||
|
"Voila tu as réussi!\n"
|
||
|
]
|
||
|
}
|
||
|
],
|
||
|
"source": [
|
||
|
"aPasTrouve = True # True signifie vrai en anglais.\n",
|
||
|
"while aPasTrouve:\n",
|
||
|
" print(\"Quelle est la couleur du cheval blanc d'Henri 4?\")\n",
|
||
|
" rep = input()\n",
|
||
|
" if rep == \"blanc\":\n",
|
||
|
" print(\"Bravo!\")\n",
|
||
|
" aPasTrouve = False # False signifie faux en anglais\n",
|
||
|
" else:\n",
|
||
|
" print(\"Non! Recommence!\")\n",
|
||
|
"print(\"Voila tu as réussi!\")"
|
||
|
]
|
||
|
},
|
||
|
{
|
||
|
"cell_type": "markdown",
|
||
|
"metadata": {},
|
||
|
"source": [
|
||
|
"## Fonctions\n",
|
||
|
"\n",
|
||
|
"Une fonction est un morceau de programme qui évitera de coder plusieurs fois la même chose. Quand on programme on dit souvent `Si c'est la 3e fois que l'on écrit ces lignes c'est qu'il faut en faire une fonction`.\n",
|
||
|
"\n",
|
||
|
"Voici différentes utilisations de fonctions."
|
||
|
]
|
||
|
},
|
||
|
{
|
||
|
"cell_type": "markdown",
|
||
|
"metadata": {},
|
||
|
"source": [
|
||
|
"### Fonctions numériques\n",
|
||
|
"\n",
|
||
|
"En math, on utilise les fonctions pour décrire les transformations (de nombres le plus souvent). \n",
|
||
|
"\n",
|
||
|
"Par exemple:\n",
|
||
|
"$$ f:x \\mapsto 3x + 2$$\n",
|
||
|
"Cette fonction $f$ prend un nombre, le multiplie par 3 puis ajoute 2. On pourra la coder de la façon suivante:"
|
||
|
]
|
||
|
},
|
||
|
{
|
||
|
"cell_type": "code",
|
||
|
"execution_count": 12,
|
||
|
"metadata": {},
|
||
|
"outputs": [],
|
||
|
"source": [
|
||
|
"def f(x):\n",
|
||
|
" return 3*x+2"
|
||
|
]
|
||
|
},
|
||
|
{
|
||
|
"cell_type": "markdown",
|
||
|
"metadata": {},
|
||
|
"source": [
|
||
|
"On vient de coder cette fonction, on peut ensuite l'utiliser"
|
||
|
]
|
||
|
},
|
||
|
{
|
||
|
"cell_type": "code",
|
||
|
"execution_count": 13,
|
||
|
"metadata": {},
|
||
|
"outputs": [
|
||
|
{
|
||
|
"name": "stdout",
|
||
|
"output_type": "stream",
|
||
|
"text": [
|
||
|
"14\n",
|
||
|
"L'image de 2.5 par la fonction f est 9.5\n",
|
||
|
"f(-2) = -4\n"
|
||
|
]
|
||
|
}
|
||
|
],
|
||
|
"source": [
|
||
|
"print(f(4))\n",
|
||
|
"print(\"L'image de 2.5 par la fonction f est \", f(2.5))\n",
|
||
|
"print(\"f(-2) = \", f(-2))"
|
||
|
]
|
||
|
},
|
||
|
{
|
||
|
"cell_type": "markdown",
|
||
|
"metadata": {},
|
||
|
"source": [
|
||
|
"Au collège, on a vu les \"programmes de calculs\". Ils peuvent eux aussi être codé avec des fonctions.\n",
|
||
|
"\n",
|
||
|
"- Choisir un nombre\n",
|
||
|
"- Ajouter 5\n",
|
||
|
"- Diviser par 10\n",
|
||
|
"\n",
|
||
|
"Se code de la façon suivante:"
|
||
|
]
|
||
|
},
|
||
|
{
|
||
|
"cell_type": "code",
|
||
|
"execution_count": 14,
|
||
|
"metadata": {},
|
||
|
"outputs": [],
|
||
|
"source": [
|
||
|
"def programme(nombre):\n",
|
||
|
" reponse = nombre + 5\n",
|
||
|
" reponse = reponse / 10\n",
|
||
|
" return reponse"
|
||
|
]
|
||
|
},
|
||
|
{
|
||
|
"cell_type": "code",
|
||
|
"execution_count": 15,
|
||
|
"metadata": {},
|
||
|
"outputs": [
|
||
|
{
|
||
|
"name": "stdout",
|
||
|
"output_type": "stream",
|
||
|
"text": [
|
||
|
"6.5\n"
|
||
|
]
|
||
|
}
|
||
|
],
|
||
|
"source": [
|
||
|
"print(programme(60))"
|
||
|
]
|
||
|
},
|
||
|
{
|
||
|
"cell_type": "markdown",
|
||
|
"metadata": {},
|
||
|
"source": [
|
||
|
"### D'autres fonctions\n",
|
||
|
"\n",
|
||
|
"Les fonctions numériques sont très utilisées en math mais en programmation, on manipule beaucoup d'autres types de fonctions.\n",
|
||
|
"\n",
|
||
|
"On pourrait vouloir transformer un texte en un titre entouré de symboles `#`."
|
||
|
]
|
||
|
},
|
||
|
{
|
||
|
"cell_type": "code",
|
||
|
"execution_count": 16,
|
||
|
"metadata": {},
|
||
|
"outputs": [],
|
||
|
"source": [
|
||
|
"def entoure(titre):\n",
|
||
|
" return '##### ' + titre + ' #####'"
|
||
|
]
|
||
|
},
|
||
|
{
|
||
|
"cell_type": "code",
|
||
|
"execution_count": 17,
|
||
|
"metadata": {},
|
||
|
"outputs": [
|
||
|
{
|
||
|
"name": "stdout",
|
||
|
"output_type": "stream",
|
||
|
"text": [
|
||
|
"##### Mon titre #####\n",
|
||
|
"##### L'histoire du petit chaperon rouge #####\n",
|
||
|
"##### Fin #####\n"
|
||
|
]
|
||
|
}
|
||
|
],
|
||
|
"source": [
|
||
|
"print(entoure('Mon titre'))\n",
|
||
|
"print(entoure(\"L'histoire du petit chaperon rouge\"))\n",
|
||
|
"print(entoure('Fin'))"
|
||
|
]
|
||
|
},
|
||
|
{
|
||
|
"cell_type": "markdown",
|
||
|
"metadata": {},
|
||
|
"source": [
|
||
|
"On peut même mettre un autre argument (en plus de `titre`) pour entourer avec autre chose que `#`."
|
||
|
]
|
||
|
},
|
||
|
{
|
||
|
"cell_type": "code",
|
||
|
"execution_count": 18,
|
||
|
"metadata": {},
|
||
|
"outputs": [],
|
||
|
"source": [
|
||
|
"def entoure(texte, symbole):\n",
|
||
|
" return symbole*4 + ' ' + texte + ' ' + symbole*4"
|
||
|
]
|
||
|
},
|
||
|
{
|
||
|
"cell_type": "code",
|
||
|
"execution_count": 19,
|
||
|
"metadata": {
|
||
|
"scrolled": true
|
||
|
},
|
||
|
"outputs": [
|
||
|
{
|
||
|
"name": "stdout",
|
||
|
"output_type": "stream",
|
||
|
"text": [
|
||
|
"---- La belle au bois dormant ----\n"
|
||
|
]
|
||
|
}
|
||
|
],
|
||
|
"source": [
|
||
|
"print(entoure('La belle au bois dormant', '-'))"
|
||
|
]
|
||
|
},
|
||
|
{
|
||
|
"cell_type": "markdown",
|
||
|
"metadata": {},
|
||
|
"source": [
|
||
|
"## Listes"
|
||
|
]
|
||
|
},
|
||
|
{
|
||
|
"cell_type": "code",
|
||
|
"execution_count": 20,
|
||
|
"metadata": {},
|
||
|
"outputs": [],
|
||
|
"source": [
|
||
|
"L = [5, 2, 1, 2, 4, 5, 5]"
|
||
|
]
|
||
|
},
|
||
|
{
|
||
|
"cell_type": "markdown",
|
||
|
"metadata": {},
|
||
|
"source": [
|
||
|
"- `max`: valeur maximal de la liste"
|
||
|
]
|
||
|
},
|
||
|
{
|
||
|
"cell_type": "code",
|
||
|
"execution_count": 21,
|
||
|
"metadata": {},
|
||
|
"outputs": [
|
||
|
{
|
||
|
"name": "stdout",
|
||
|
"output_type": "stream",
|
||
|
"text": [
|
||
|
"5\n"
|
||
|
]
|
||
|
}
|
||
|
],
|
||
|
"source": [
|
||
|
"print(max(L))"
|
||
|
]
|
||
|
},
|
||
|
{
|
||
|
"cell_type": "markdown",
|
||
|
"metadata": {},
|
||
|
"source": [
|
||
|
"- `min`: valeur minimal de la liste "
|
||
|
]
|
||
|
},
|
||
|
{
|
||
|
"cell_type": "code",
|
||
|
"execution_count": 22,
|
||
|
"metadata": {},
|
||
|
"outputs": [
|
||
|
{
|
||
|
"name": "stdout",
|
||
|
"output_type": "stream",
|
||
|
"text": [
|
||
|
"1\n"
|
||
|
]
|
||
|
}
|
||
|
],
|
||
|
"source": [
|
||
|
"print(min(L))"
|
||
|
]
|
||
|
},
|
||
|
{
|
||
|
"cell_type": "markdown",
|
||
|
"metadata": {},
|
||
|
"source": [
|
||
|
"- `len`: calculer le nombre d'éléments dans la liste"
|
||
|
]
|
||
|
},
|
||
|
{
|
||
|
"cell_type": "code",
|
||
|
"execution_count": 23,
|
||
|
"metadata": {},
|
||
|
"outputs": [
|
||
|
{
|
||
|
"name": "stdout",
|
||
|
"output_type": "stream",
|
||
|
"text": [
|
||
|
"7\n"
|
||
|
]
|
||
|
}
|
||
|
],
|
||
|
"source": [
|
||
|
"print(len(L))"
|
||
|
]
|
||
|
},
|
||
|
{
|
||
|
"cell_type": "markdown",
|
||
|
"metadata": {},
|
||
|
"source": [
|
||
|
"- `sum`: calculer la somme des éléments de la liste"
|
||
|
]
|
||
|
},
|
||
|
{
|
||
|
"cell_type": "code",
|
||
|
"execution_count": 24,
|
||
|
"metadata": {},
|
||
|
"outputs": [
|
||
|
{
|
||
|
"name": "stdout",
|
||
|
"output_type": "stream",
|
||
|
"text": [
|
||
|
"24\n"
|
||
|
]
|
||
|
}
|
||
|
],
|
||
|
"source": [
|
||
|
"print(sum(L))"
|
||
|
]
|
||
|
},
|
||
|
{
|
||
|
"cell_type": "markdown",
|
||
|
"metadata": {},
|
||
|
"source": [
|
||
|
"- `sorted`: trier les éléments de la liste"
|
||
|
]
|
||
|
},
|
||
|
{
|
||
|
"cell_type": "code",
|
||
|
"execution_count": 25,
|
||
|
"metadata": {},
|
||
|
"outputs": [
|
||
|
{
|
||
|
"name": "stdout",
|
||
|
"output_type": "stream",
|
||
|
"text": [
|
||
|
"[1, 2, 2, 4, 5, 5, 5]\n"
|
||
|
]
|
||
|
}
|
||
|
],
|
||
|
"source": [
|
||
|
"print(sorted(L))"
|
||
|
]
|
||
|
},
|
||
|
{
|
||
|
"cell_type": "markdown",
|
||
|
"metadata": {},
|
||
|
"source": [
|
||
|
"- Récupérer le i-ième élément de la liste (**/!\\ on commence à compter à partir de 0**)"
|
||
|
]
|
||
|
},
|
||
|
{
|
||
|
"cell_type": "code",
|
||
|
"execution_count": 26,
|
||
|
"metadata": {},
|
||
|
"outputs": [
|
||
|
{
|
||
|
"name": "stdout",
|
||
|
"output_type": "stream",
|
||
|
"text": [
|
||
|
"5\n",
|
||
|
"1\n"
|
||
|
]
|
||
|
}
|
||
|
],
|
||
|
"source": [
|
||
|
"# Le premier élément de la liste\n",
|
||
|
"print(L[0])\n",
|
||
|
"# le 3e élément de la liste\n",
|
||
|
"print(L[2])"
|
||
|
]
|
||
|
},
|
||
|
{
|
||
|
"cell_type": "markdown",
|
||
|
"metadata": {},
|
||
|
"source": [
|
||
|
"- Compter l'effectif d'une valeur"
|
||
|
]
|
||
|
},
|
||
|
{
|
||
|
"cell_type": "code",
|
||
|
"execution_count": 27,
|
||
|
"metadata": {},
|
||
|
"outputs": [
|
||
|
{
|
||
|
"data": {
|
||
|
"text/plain": [
|
||
|
"2"
|
||
|
]
|
||
|
},
|
||
|
"execution_count": 27,
|
||
|
"metadata": {},
|
||
|
"output_type": "execute_result"
|
||
|
}
|
||
|
],
|
||
|
"source": [
|
||
|
"L.count(2)"
|
||
|
]
|
||
|
},
|
||
|
{
|
||
|
"cell_type": "markdown",
|
||
|
"metadata": {},
|
||
|
"source": [
|
||
|
"- Faire une boucle sur tous les éléments de la liste"
|
||
|
]
|
||
|
},
|
||
|
{
|
||
|
"cell_type": "code",
|
||
|
"execution_count": 28,
|
||
|
"metadata": {},
|
||
|
"outputs": [
|
||
|
{
|
||
|
"name": "stdout",
|
||
|
"output_type": "stream",
|
||
|
"text": [
|
||
|
"5\n",
|
||
|
"2\n",
|
||
|
"1\n",
|
||
|
"2\n",
|
||
|
"4\n",
|
||
|
"5\n",
|
||
|
"5\n"
|
||
|
]
|
||
|
}
|
||
|
],
|
||
|
"source": [
|
||
|
"for x in L:\n",
|
||
|
" print(x)"
|
||
|
]
|
||
|
},
|
||
|
{
|
||
|
"cell_type": "markdown",
|
||
|
"metadata": {},
|
||
|
"source": [
|
||
|
"## Graphiques\n",
|
||
|
"\n",
|
||
|
"Pour faire des graphiques, il faut que la ligne suivante fasse partie des premières lignes de votre programme."
|
||
|
]
|
||
|
},
|
||
|
{
|
||
|
"cell_type": "code",
|
||
|
"execution_count": 29,
|
||
|
"metadata": {},
|
||
|
"outputs": [],
|
||
|
"source": [
|
||
|
"import matplotlib.pyplot as plt"
|
||
|
]
|
||
|
},
|
||
|
{
|
||
|
"cell_type": "markdown",
|
||
|
"metadata": {},
|
||
|
"source": [
|
||
|
"Ensuite, on définit les abscisses et les ordonnées sous forme de listes (il faut que les 2 listes aient le même nombre d'éléments)."
|
||
|
]
|
||
|
},
|
||
|
{
|
||
|
"cell_type": "code",
|
||
|
"execution_count": 30,
|
||
|
"metadata": {},
|
||
|
"outputs": [],
|
||
|
"source": [
|
||
|
"abscisses = [1, 2, 3, 4, 5, 6]\n",
|
||
|
"ordonnees = [4, 10, 1, -3, 6, 0]"
|
||
|
]
|
||
|
},
|
||
|
{
|
||
|
"cell_type": "markdown",
|
||
|
"metadata": {},
|
||
|
"source": [
|
||
|
"On peut tracer une courbe:"
|
||
|
]
|
||
|
},
|
||
|
{
|
||
|
"cell_type": "code",
|
||
|
"execution_count": 31,
|
||
|
"metadata": {},
|
||
|
"outputs": [
|
||
|
{
|
||
|
"data": {
|
||
|
"text/plain": [
|
||
|
"[<matplotlib.lines.Line2D at 0x7f0ad9c090b8>]"
|
||
|
]
|
||
|
},
|
||
|
"execution_count": 31,
|
||
|
"metadata": {},
|
||
|
"output_type": "execute_result"
|
||
|
},
|
||
|
{
|
||
|
"data": {
|
||
|
"image/png": "iVBORw0KG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Al0VkvYgUiUhnA45rutqjZ/CrD7e7toIJ5F9YmseFJQqDhsZm/PqTndhdd9LqURzJiGCPATAGwEuqOhrAaQBzWr5IRJ4QkTIRKfN4PAacNjQt74JxYwUTqHNcDB4a3w8fb+HCEpnvw8378Icvd+MHC9bjXGOT1eM4jhHBXgugVlVX+T5fDG/QX0RV56pqrqrmpqamGnDa0PgrmGfuGIbM7u6sYFp6dFIWokTwCheWyESqiqKSCvTo3Ak7D57E77/YbfVIjhNysKvqAQA1IjLE96UpALaFelwz1RzxVjB5A1NcsYgUrPTkBNwxKh1vcmGJTLSq4gi27juBJ28bgnuvzcRLX+/Bplrb/LWcLRh1V8wPASwQkU0ArgHwK4OOazhVxZylmwAAz88Y6foKpqWCPC4skbn8V+v/MDoDP5s+HCldOuFf3t7ISsZAhgS7qm7w1SyjVPVuVY3YWysWrq7Gst2HWcFcwajMbhiX3QMvL+PCEhmv3HMKX+w4iJkT+iM+NhrJCbF4/p5R+PbgKfz3F7usHs8xXLV5ygomOAV52dh77Cw+2cqFJTLWy8sqERsVhVkTvnso/I1D03DvtZn409flrGQM4ppg91cwIsIKpg03D+uF/j0TUVTKhSUyzrEzDXh7bQ3uHt0HqUlxF/3az6YPR2qXOFYyBnFNsC9Y5atgprGCaYt3YSkb67mwRAZasKoa9eebUZCXc8mvJSfE4rl7RrKSMYgrgr3myBk895G3gnlwXF+rx7GFe6/NRNf4GBTzqp0M0NDYjFeXVyJ/UAqG9E667GtYyRjH8cGuqvjJElYw7eVdWOqPv205wIUlCtk
|
||
|
"text/plain": [
|
||
|
"<Figure size 432x288 with 1 Axes>"
|
||
|
]
|
||
|
},
|
||
|
"metadata": {
|
||
|
"needs_background": "light"
|
||
|
},
|
||
|
"output_type": "display_data"
|
||
|
}
|
||
|
],
|
||
|
"source": [
|
||
|
"plt.plot(abscisses, ordonnees)"
|
||
|
]
|
||
|
},
|
||
|
{
|
||
|
"cell_type": "markdown",
|
||
|
"metadata": {},
|
||
|
"source": [
|
||
|
"Un nuage de points"
|
||
|
]
|
||
|
},
|
||
|
{
|
||
|
"cell_type": "code",
|
||
|
"execution_count": 32,
|
||
|
"metadata": {},
|
||
|
"outputs": [
|
||
|
{
|
||
|
"data": {
|
||
|
"text/plain": [
|
||
|
"[<matplotlib.lines.Line2D at 0x7f0ad9b9d978>]"
|
||
|
]
|
||
|
},
|
||
|
"execution_count": 32,
|
||
|
"metadata": {},
|
||
|
"output_type": "execute_result"
|
||
|
},
|
||
|
{
|
||
|
"data": {
|
||
|
"image/png": "iVBORw0KGgoAAAANSUhEUgAAAXYAAAD8CAYAAABjAo9vAAAABHNCSVQICAgIfAhkiAAAAAlwSFlzAAALEgAACxIB0t1+/AAAADl0RVh0U29mdHdhcmUAbWF0cGxvdGxpYiB2ZXJzaW9uIDMuMC4zLCBodHRwOi8vbWF0cGxvdGxpYi5vcmcvnQurowAADV1JREFUeJzt3V+MXPdZxvHnwZuoTRrqolipibNMpK5TVRGQMgqUQKiyMUprq+llKqUqBWkvgLI1oGhDhSLuLIHqWgKBrDglqCERyh+1ikPJ4qYqlZrArhPIH4d1FZwmIcGuSkgDFyHwcOERcizb651zZs7Ou9+PZHlm9uzvvHPz1dnfzsw6iQAAdfxI1wMAANpF2AGgGMIOAMUQdgAohrADQDGEHQCKIewAUAxhB4BiCDsAFDPVxUkvvfTS9Hq9Lk4NABNreXn5+0m2rHZcJ2Hv9XpaWlrq4tQAMLFsv3g+x7EVAwDFEHYAKIawA0AxhB0AiiHsAFDMeYfd9l22j9t+5pTHfsz2ou2jg//fN5oxN7a9iytdjwBggqzliv3PJd102mMLkg4lmZF0aHAfLdt36GjXIwCYIOcd9iTfkvSD0x6+WdLdg9t3S/pkS3MBAIbU9A1KlyV5dXD7NUmXne1A23OS5iRpenq64Wnr27u48o4r9d7CQUnS/OyMdu/Y3tVYACaA1/LHrG33JD2c5OrB/deTbD7l6/+eZNV99n6/H955ev56Cwd1bM/OrscA0DHby0n6qx3X9FUx/2Z76+CEWyUdb7geAKChpmH/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35Y0n+TxjkcbKdu/Lakv6UeT7Op6nlGzfUxSP8mGeQ2
|
||
|
"text/plain": [
|
||
|
"<Figure size 432x288 with 1 Axes>"
|
||
|
]
|
||
|
},
|
||
|
"metadata": {
|
||
|
"needs_background": "light"
|
||
|
},
|
||
|
"output_type": "display_data"
|
||
|
}
|
||
|
],
|
||
|
"source": [
|
||
|
"plt.plot(abscisses, ordonnees, '+')"
|
||
|
]
|
||
|
},
|
||
|
{
|
||
|
"cell_type": "markdown",
|
||
|
"metadata": {},
|
||
|
"source": [
|
||
|
"Un diagramme bar"
|
||
|
]
|
||
|
},
|
||
|
{
|
||
|
"cell_type": "code",
|
||
|
"execution_count": 33,
|
||
|
"metadata": {},
|
||
|
"outputs": [
|
||
|
{
|
||
|
"data": {
|
||
|
"text/plain": [
|
||
|
"<BarContainer object of 6 artists>"
|
||
|
]
|
||
|
},
|
||
|
"execution_count": 33,
|
||
|
"metadata": {},
|
||
|
"output_type": "execute_result"
|
||
|
},
|
||
|
{
|
||
|
"data": {
|
||
|
"image/png": "iVBORw0KGgoAAAANSUhEUgAAAXYAAAD8CAYAAABjAo9vAAAABHNCSVQICAgIfAhkiAAAAAlwSFlzAAALEgAACxIB0t1+/AAAADl0RVh0U29mdHdhcmUAbWF0cGxvdGxpYiB2ZXJzaW9uIDMuMC4zLCBodHRwOi8vbWF0cGxvdGxpYi5vcmcvnQurowAADChJREFUeJzt3V+sZfVZh/Hn6xxIC8VSwwkiw/GQ2JA0xAjuoBWDBqihDim96AVNIG3VnBuLVE3IYGOId5NomjbRaE6AiilCzABpU7AytjS1iaWdAZQ/g7bBoR0EZ5pGW/QC0deL2RcU5885ey1mcd55Psnk7L3Pmt96182TNWuvPTtVhSSpjx+ZegBJ0rgMuyQ1Y9glqRnDLknNGHZJasawS1Izhl2SmjHsktSMYZekZpam2Ok555xTq6urU+xakrasffv2fbeqlk+03SRhX11dZe/evVPsWpK2rCTPb2Q7L8VIUjOGXZKaMeyS1Ixhl6RmDLskNbPhs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CfG/qOcZSVS9W1WPzxz8A9gPnTzvVMHXEy/Onp83/bOmzkSTbgR3A7VPPov8vyduBK4A7AKrqla0UdTjFw95ZklXgEuDRaScZbn7Z4gngELCnqrb6MX0SuAX436kHGVEBDyfZl2Rt6mEGuhA4DHx6frns9iRnTj3UZhj2hpK8DbgP+FhVfX/qeYaqqv+pqp8BtgOXJdmyl82SXAscqqp9U88ysl+sqkuB9wK/Ob/MuVUtAZcCf1pVlwD/CeycdqTNMezNzK9D3wfcXVX3Tz3PmOb/HH4EuGbqWQa4HHjf/Jr0vcCVST4z7UjDVdUL85+HgAeAy6adaJCDwMHX/MtwN0dCv2UY9kbmbzTeAeyvqk9
|
||
|
"text/plain": [
|
||
|
"<Figure size 432x288 with 1 Axes>"
|
||
|
]
|
||
|
},
|
||
|
"metadata": {
|
||
|
"needs_background": "light"
|
||
|
},
|
||
|
"output_type": "display_data"
|
||
|
}
|
||
|
],
|
||
|
"source": [
|
||
|
"plt.bar(abscisses, ordonnees)"
|
||
|
]
|
||
|
},
|
||
|
{
|
||
|
"cell_type": "code",
|
||
|
"execution_count": null,
|
||
|
"metadata": {},
|
||
|
"outputs": [],
|
||
|
"source": []
|
||
|
}
|
||
|
],
|
||
|
"metadata": {
|
||
|
"kernelspec": {
|
||
|
"display_name": "Python 3",
|
||
|
"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.7.3"
|
||
|
}
|
||
|
},
|
||
|
"nbformat": 4,
|
||
|
"nbformat_minor": 1
|
||
|
}
|