Feat: Reorganisation boucle et liste finie
This commit is contained in:
parent
1a9879891c
commit
51eaf953b0
@ -15,14 +15,14 @@
|
|||||||
"\n",
|
"\n",
|
||||||
"Nous allons tracer la représentation graphique de \n",
|
"Nous allons tracer la représentation graphique de \n",
|
||||||
"\n",
|
"\n",
|
||||||
"$$ f : x \\mapsto \\frac{x^2}{10} - 5 $$\n",
|
"$$ f : x \\mapsto x^2 - 10x + 20 $$\n",
|
||||||
"\n",
|
"\n",
|
||||||
"**Recopier** le programme suivant, **compléter** les pointillés et calculer les images jusqu'à 8."
|
"**Recopier** le programme suivant, **compléter** les pointillés et calculer les images jusqu'à 8."
|
||||||
]
|
]
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"cell_type": "code",
|
"cell_type": "code",
|
||||||
"execution_count": 3,
|
"execution_count": 1,
|
||||||
"metadata": {},
|
"metadata": {},
|
||||||
"outputs": [
|
"outputs": [
|
||||||
{
|
{
|
||||||
@ -36,7 +36,7 @@
|
|||||||
],
|
],
|
||||||
"source": [
|
"source": [
|
||||||
"def f(x):\n",
|
"def f(x):\n",
|
||||||
" return x**2/10 - 5\n",
|
" return x**2 - 10*x + 20\n",
|
||||||
"\n",
|
"\n",
|
||||||
"# image de 0\n",
|
"# image de 0\n",
|
||||||
"print(\"L'image de\", \"...\",\" est\", \"...\")\n",
|
"print(\"L'image de\", \"...\",\" est\", \"...\")\n",
|
||||||
@ -57,7 +57,7 @@
|
|||||||
},
|
},
|
||||||
{
|
{
|
||||||
"cell_type": "code",
|
"cell_type": "code",
|
||||||
"execution_count": 4,
|
"execution_count": 2,
|
||||||
"metadata": {},
|
"metadata": {},
|
||||||
"outputs": [
|
"outputs": [
|
||||||
{
|
{
|
||||||
@ -81,7 +81,7 @@
|
|||||||
"print(\"L'image de\", \"...\",\" est\", \"...\", \"On l'ajoute à la liste\")\n",
|
"print(\"L'image de\", \"...\",\" est\", \"...\", \"On l'ajoute à la liste\")\n",
|
||||||
"antecedents.append(0) # On ajoute (append) 0 à la liste des antecedents\n",
|
"antecedents.append(0) # On ajoute (append) 0 à la liste des antecedents\n",
|
||||||
"# image de 1\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": [
|
"source": [
|
||||||
"Vous avez tracer la courbe représentative de de la fonction $f$.\n",
|
"Vous avez tracer la courbe représentative de de la fonction $f$.\n",
|
||||||
"\n",
|
"\n",
|
||||||
"![Représentation graphique de f](./fig/cos_pas1.png)\n",
|
"![Représentation graphique de f](./fig/plt_f.png)\n",
|
||||||
"\n",
|
"\n",
|
||||||
"Dans un nouveau fichier, **tracer** la courbe représentative pour x allant de 0 à 50 de la fonction $g$ tel que\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^2 - 4$$\n",
|
"$$ g : x \\mapsto -(x - 5)^2 + 5$$\n",
|
||||||
"\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": [
|
"source": [
|
||||||
"## Précision et controle du tracé\n",
|
"## Précision et controle du tracé\n",
|
||||||
"\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": [
|
"source": [
|
||||||
"## Boucle `while` (tant que )\n",
|
"## Boucle `while` (tant que )\n",
|
||||||
"\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",
|
"\n",
|
||||||
"Les 2 programmes ci-dessous font la même chose."
|
"Les 2 programmes ci-dessous font la même chose."
|
||||||
]
|
]
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"cell_type": "code",
|
"cell_type": "code",
|
||||||
"execution_count": null,
|
"execution_count": 3,
|
||||||
"metadata": {},
|
"metadata": {
|
||||||
"outputs": [],
|
"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": [
|
"source": [
|
||||||
"for x in range(10):\n",
|
"x = 0\n",
|
||||||
" print(x)"
|
"\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",
|
"cell_type": "code",
|
||||||
"execution_count": null,
|
"execution_count": 4,
|
||||||
"metadata": {},
|
"metadata": {
|
||||||
"outputs": [],
|
"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": [
|
"source": [
|
||||||
"x = 0\n",
|
"x = 0\n",
|
||||||
"while x < 10:\n",
|
"while x < 10:\n",
|
||||||
@ -208,9 +277,22 @@
|
|||||||
"images = []\n",
|
"images = []\n",
|
||||||
"antecedants = []\n",
|
"antecedants = []\n",
|
||||||
"\n",
|
"\n",
|
||||||
"for x in range(20):\n",
|
"# image de 0\n",
|
||||||
" images.append(h(x))\n",
|
"print(\"L'image de\", \"...\",\" est\", \"...\", \"On les ajoute à la liste\")\n",
|
||||||
" antecedants.append(x)\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",
|
"\n",
|
||||||
"print(\"Les images sont \", images)"
|
"print(\"Les images sont \", images)"
|
||||||
]
|
]
|
||||||
|
File diff suppressed because one or more lines are too long
BIN
PreStSauveur/Programmation/fig/plt_f.png
Normal file
BIN
PreStSauveur/Programmation/fig/plt_f.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 9.1 KiB |
BIN
PreStSauveur/Programmation/fig/plt_g.png
Normal file
BIN
PreStSauveur/Programmation/fig/plt_g.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 9.9 KiB |
Loading…
Reference in New Issue
Block a user