Feat: Reorganisation boucle et liste finie
This commit is contained in:
parent
1a9879891c
commit
51eaf953b0
|
@ -15,14 +15,14 @@
|
|||
"\n",
|
||||
"Nous allons tracer la représentation graphique de \n",
|
||||
"\n",
|
||||
"$$ f : x \\mapsto \\frac{x^2}{10} - 5 $$\n",
|
||||
"$$ f : x \\mapsto x^2 - 10x + 20 $$\n",
|
||||
"\n",
|
||||
"**Recopier** le programme suivant, **compléter** les pointillés et calculer les images jusqu'à 8."
|
||||
]
|
||||
},
|
||||
{
|
||||
"cell_type": "code",
|
||||
"execution_count": 3,
|
||||
"execution_count": 1,
|
||||
"metadata": {},
|
||||
"outputs": [
|
||||
{
|
||||
|
@ -36,7 +36,7 @@
|
|||
],
|
||||
"source": [
|
||||
"def f(x):\n",
|
||||
" return x**2/10 - 5\n",
|
||||
" return x**2 - 10*x + 20\n",
|
||||
"\n",
|
||||
"# image de 0\n",
|
||||
"print(\"L'image de\", \"...\",\" est\", \"...\")\n",
|
||||
|
@ -57,7 +57,7 @@
|
|||
},
|
||||
{
|
||||
"cell_type": "code",
|
||||
"execution_count": 4,
|
||||
"execution_count": 2,
|
||||
"metadata": {},
|
||||
"outputs": [
|
||||
{
|
||||
|
@ -81,7 +81,7 @@
|
|||
"print(\"L'image de\", \"...\",\" est\", \"...\", \"On l'ajoute à la liste\")\n",
|
||||
"antecedents.append(0) # On ajoute (append) 0 à la liste des antecedents\n",
|
||||
"# image de 1\n",
|
||||
"print(\"L'image de\", \"...\",\" est\", \"...\", \"On l'ajoute à la liste\")"
|
||||
"print(\"L'image de\", \"...\",\" est\", \"...\")"
|
||||
]
|
||||
},
|
||||
{
|
||||
|
@ -125,12 +125,12 @@
|
|||
"source": [
|
||||
"Vous avez tracer la courbe représentative de de la fonction $f$.\n",
|
||||
"\n",
|
||||
"![Représentation graphique de f](./fig/cos_pas1.png)\n",
|
||||
"![Représentation graphique de f](./fig/plt_f.png)\n",
|
||||
"\n",
|
||||
"Dans un nouveau fichier, **tracer** la courbe représentative pour x allant de 0 à 50 de la fonction $g$ tel que\n",
|
||||
"$$ g : x \\mapsto x^2 - 4$$\n",
|
||||
"Dans un nouveau fichier, **tracer** la courbe représentative pour x allant de 0 à 15 de la fonction $g$ tel que\n",
|
||||
"$$ g : x \\mapsto -(x - 5)^2 + 5$$\n",
|
||||
"\n",
|
||||
"![Représentation graphique de f](./fig/g_pas1.png)"
|
||||
"![Représentation graphique de f](./fig/plt_g.png)"
|
||||
]
|
||||
},
|
||||
{
|
||||
|
@ -139,7 +139,9 @@
|
|||
"source": [
|
||||
"## Précision et controle du tracé\n",
|
||||
"\n",
|
||||
"Pour le moment, on sait donner un maximum à l'antécédent $x$ mais on ne peut pas contrôler le minimum ni le pas (l'écart en 2 valeurs de $x$). Or pour tracer précisément la représentation graphique d'une fonction, nous avons besoin de contrôler la fenêtre (minimum et maximum) et le pas."
|
||||
"Pour le moment, on sait donner un maximum à l'antécédent $x$ mais on ne peut pas contrôler le minimum ni le pas (l'écart en 2 valeurs de $x$). \n",
|
||||
"\n",
|
||||
"Or pour tracer précisément la représentation graphique d'une fonction, nous avons besoin de contrôler la **fenêtre** (minimum et maximum) et le **pas**."
|
||||
]
|
||||
},
|
||||
{
|
||||
|
@ -148,26 +150,93 @@
|
|||
"source": [
|
||||
"## Boucle `while` (tant que )\n",
|
||||
"\n",
|
||||
"Ce type de boucle donne plus de contrôle sur $x$ et nous évite d'utiliser `range` qui est une commande qui n'existe que en Python.\n",
|
||||
"Une boucle `while` permet de répeter une ou plusieurs actions **tant qu'** une condition est vérifiée.\n",
|
||||
"\n",
|
||||
"Les 2 programmes ci-dessous font la même chose."
|
||||
]
|
||||
},
|
||||
{
|
||||
"cell_type": "code",
|
||||
"execution_count": null,
|
||||
"metadata": {},
|
||||
"outputs": [],
|
||||
"execution_count": 3,
|
||||
"metadata": {
|
||||
"collapsed": true
|
||||
},
|
||||
"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)"
|
||||
"x = 0\n",
|
||||
"\n",
|
||||
"print(x)\n",
|
||||
"x = x+1\n",
|
||||
"\n",
|
||||
"print(x)\n",
|
||||
"x = x+1\n",
|
||||
"\n",
|
||||
"print(x)\n",
|
||||
"x = x+1\n",
|
||||
"\n",
|
||||
"print(x)\n",
|
||||
"x = x+1\n",
|
||||
"\n",
|
||||
"print(x)\n",
|
||||
"x = x+1\n",
|
||||
"\n",
|
||||
"print(x)\n",
|
||||
"x = x+1\n",
|
||||
"\n",
|
||||
"print(x)\n",
|
||||
"x = x+1\n",
|
||||
"\n",
|
||||
"print(x)\n",
|
||||
"x = x+1\n",
|
||||
"\n",
|
||||
"print(x)\n",
|
||||
"x = x+1\n",
|
||||
"\n",
|
||||
"print(x)\n",
|
||||
"x = x+1"
|
||||
]
|
||||
},
|
||||
{
|
||||
"cell_type": "code",
|
||||
"execution_count": null,
|
||||
"metadata": {},
|
||||
"outputs": [],
|
||||
"execution_count": 4,
|
||||
"metadata": {
|
||||
"collapsed": true
|
||||
},
|
||||
"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": [
|
||||
"x = 0\n",
|
||||
"while x < 10:\n",
|
||||
|
@ -208,9 +277,22 @@
|
|||
"images = []\n",
|
||||
"antecedants = []\n",
|
||||
"\n",
|
||||
"for x in range(20):\n",
|
||||
" images.append(h(x))\n",
|
||||
" antecedants.append(x)\n",
|
||||
"# image de 0\n",
|
||||
"print(\"L'image de\", \"...\",\" est\", \"...\", \"On les ajoute à la liste\")\n",
|
||||
"antecedents.append(0)\n",
|
||||
"images.append(h(0))\n",
|
||||
"\n",
|
||||
"# image de 1\n",
|
||||
"print(\"L'image de\", \"...\",\" est\", \"...\", \"On les ajoute à la liste\")\n",
|
||||
"antecedents.append(1)\n",
|
||||
"images.append(h(1))\n",
|
||||
"\n",
|
||||
"# ....\n",
|
||||
"\n",
|
||||
"# image de 20\n",
|
||||
"print(\"L'image de\", \"...\",\" est\", \"...\", \"On les ajoute à la liste\")\n",
|
||||
"antecedents.append(20)\n",
|
||||
"images.append(h(20))\n",
|
||||
"\n",
|
||||
"print(\"Les images sont \", images)"
|
||||
]
|
||||
|
|
File diff suppressed because one or more lines are too long
Binary file not shown.
After Width: | Height: | Size: 9.1 KiB |
Binary file not shown.
After Width: | Height: | Size: 9.9 KiB |
Loading…
Reference in New Issue