From 7851eb6c8abecce59e22112707baff679d8cba12 Mon Sep 17 00:00:00 2001 From: Divya SELVARAJU Date: Wed, 21 Sep 2022 11:12:23 +0200 Subject: [PATCH 01/23] travail --- .../TD01_prise_en_main/01_prise_en_main.ipynb | 128 ++++++++++++++---- 1 file changed, 104 insertions(+), 24 deletions(-) diff --git a/exercises/TD01_prise_en_main/01_prise_en_main.ipynb b/exercises/TD01_prise_en_main/01_prise_en_main.ipynb index 237397fac..11c49be14 100644 --- a/exercises/TD01_prise_en_main/01_prise_en_main.ipynb +++ b/exercises/TD01_prise_en_main/01_prise_en_main.ipynb @@ -44,7 +44,9 @@ "execution_count": null, "metadata": {}, "outputs": [], - "source": [] + "source": [ + "1+1" + ] }, { "cell_type": "markdown", @@ -62,7 +64,9 @@ "execution_count": null, "metadata": {}, "outputs": [], - "source": [] + "source": [ + "a= 1+1" + ] }, { "cell_type": "markdown", @@ -76,7 +80,9 @@ "execution_count": null, "metadata": {}, "outputs": [], - "source": [] + "source": [ + "a" + ] }, { "cell_type": "markdown", @@ -92,7 +98,9 @@ "tags": [] }, "outputs": [], - "source": [] + "source": [ + "print(a)" + ] }, { "cell_type": "markdown", @@ -108,7 +116,9 @@ "execution_count": null, "metadata": {}, "outputs": [], - "source": [] + "source": [ + "a= +1" + ] }, { "cell_type": "markdown", @@ -119,12 +129,26 @@ }, { "cell_type": "code", - "execution_count": null, + "execution_count": 2, "metadata": { "tags": [] }, - "outputs": [], - "source": [] + "outputs": [ + { + "ename": "NameError", + "evalue": "name 'a' is not defined", + "output_type": "error", + "traceback": [ + "\u001b[1;31m---------------------------------------------------------------------------\u001b[0m", + "\u001b[1;31mNameError\u001b[0m Traceback (most recent call last)", + "\u001b[1;32mc:\\Users\\Divya\\.vscode\\extensions\\l1-python\\exercises\\TD01_prise_en_main\\01_prise_en_main.ipynb Cellule 14\u001b[0m in \u001b[0;36m\u001b[1;34m()\u001b[0m\n\u001b[1;32m----> 1\u001b[0m \u001b[39mprint\u001b[39m(a)\n", + "\u001b[1;31mNameError\u001b[0m: name 'a' is not defined" + ] + } + ], + "source": [ + "print(a)" + ] }, { "cell_type": "markdown", @@ -149,12 +173,24 @@ }, { "cell_type": "code", - "execution_count": null, + "execution_count": 3, "metadata": { "tags": [] }, - "outputs": [], - "source": [] + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "5 2\n" + ] + } + ], + "source": [ + "a= 5 \n", + "b= 2\n", + "print(a, b)" + ] }, { "cell_type": "markdown", @@ -165,12 +201,15 @@ }, { "cell_type": "code", - "execution_count": null, + "execution_count": 4, "metadata": { "tags": [] }, "outputs": [], - "source": [] + "source": [ + "a=b\n", + "b=a" + ] }, { "cell_type": "markdown", @@ -181,11 +220,23 @@ }, { "cell_type": "code", - "execution_count": null, + "execution_count": 5, "metadata": { "tags": [] }, - "outputs": [], + "outputs": [ + { + "ename": "TypeError", + "evalue": "'a' is an invalid keyword argument for print()", + "output_type": "error", + "traceback": [ + "\u001b[1;31m---------------------------------------------------------------------------\u001b[0m", + "\u001b[1;31mTypeError\u001b[0m Traceback (most recent call last)", + "\u001b[1;32mc:\\Users\\Divya\\.vscode\\extensions\\l1-python\\exercises\\TD01_prise_en_main\\01_prise_en_main.ipynb Cellule 20\u001b[0m in \u001b[0;36m\u001b[1;34m()\u001b[0m\n\u001b[1;32m----> 1\u001b[0m \u001b[39mprint\u001b[39;49m (a\u001b[39m=\u001b[39;49ma, b\u001b[39m=\u001b[39;49mb)\n", + "\u001b[1;31mTypeError\u001b[0m: 'a' is an invalid keyword argument for print()" + ] + } + ], "source": [] }, { @@ -197,12 +248,23 @@ }, { "cell_type": "code", - "execution_count": null, + "execution_count": 7, "metadata": { "tags": [] }, - "outputs": [], - "source": [] + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "hello world\n" + ] + } + ], + "source": [ + "a= \"hello world\"\n", + "print(a)" + ] }, { "cell_type": "markdown", @@ -239,10 +301,23 @@ }, { "cell_type": "code", - "execution_count": null, + "execution_count": 9, "metadata": {}, - "outputs": [], - "source": [] + "outputs": [ + { + "data": { + "text/plain": [ + "float" + ] + }, + "execution_count": 9, + "metadata": {}, + "output_type": "execute_result" + } + ], + "source": [ + "type(5.0)\n" + ] }, { "cell_type": "markdown", @@ -730,7 +805,7 @@ ], "metadata": { "kernelspec": { - "display_name": "Python 3", + "display_name": "Python 3.10.4 ('l1-python')", "language": "python", "name": "python3" }, @@ -744,9 +819,14 @@ "name": "python", "nbconvert_exporter": "python", "pygments_lexer": "ipython3", - "version": "3.7.6-final" + "version": "3.10.4" + }, + "vscode": { + "interpreter": { + "hash": "c40ec1b8fe39daf00984f8ba30325fc08ad307055404f66b6babdfa1fdac6336" + } } }, "nbformat": 4, "nbformat_minor": 1 -} \ No newline at end of file +} From 800df8b591c44aad21725a463761d1c377cc125a Mon Sep 17 00:00:00 2001 From: Divya SELVARAJU Date: Wed, 21 Sep 2022 12:03:16 +0200 Subject: [PATCH 02/23] 3.2 nombres flottants --- .../TD01_prise_en_main/01_prise_en_main.ipynb | 147 +++++++++++++++--- 1 file changed, 122 insertions(+), 25 deletions(-) diff --git a/exercises/TD01_prise_en_main/01_prise_en_main.ipynb b/exercises/TD01_prise_en_main/01_prise_en_main.ipynb index 11c49be14..8452fae27 100644 --- a/exercises/TD01_prise_en_main/01_prise_en_main.ipynb +++ b/exercises/TD01_prise_en_main/01_prise_en_main.ipynb @@ -201,14 +201,24 @@ }, { "cell_type": "code", - "execution_count": 4, + "execution_count": 64, "metadata": { "tags": [] }, - "outputs": [], + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "2 5\n" + ] + } + ], "source": [ - "a=b\n", - "b=a" + "a=5\n", + "b=2\n", + "a,b=b,a\n", + "print(a,b)\n" ] }, { @@ -334,10 +344,23 @@ }, { "cell_type": "code", - "execution_count": null, + "execution_count": 14, "metadata": {}, - "outputs": [], - "source": [] + "outputs": [ + { + "data": { + "text/plain": [ + "list" + ] + }, + "execution_count": 14, + "metadata": {}, + "output_type": "execute_result" + } + ], + "source": [ + "type([5, 2])" + ] }, { "cell_type": "markdown", @@ -350,12 +373,22 @@ }, { "cell_type": "code", - "execution_count": null, + "execution_count": 18, "metadata": { "tags": [] }, - "outputs": [], - "source": [] + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "le type de x est \n" + ] + } + ], + "source": [ + "print (\"le type de x est \") if x==2 else true" + ] }, { "cell_type": "markdown", @@ -369,10 +402,12 @@ }, { "cell_type": "code", - "execution_count": null, + "execution_count": 19, "metadata": {}, "outputs": [], - "source": [] + "source": [ + "v=6" + ] }, { "cell_type": "markdown", @@ -385,12 +420,25 @@ }, { "cell_type": "code", - "execution_count": null, + "execution_count": 20, "metadata": { "tags": [] }, - "outputs": [], - "source": [] + "outputs": [ + { + "data": { + "text/plain": [ + "13.545454545454545" + ] + }, + "execution_count": 20, + "metadata": {}, + "output_type": "execute_result" + } + ], + "source": [ + "149/11" + ] }, { "cell_type": "markdown", @@ -404,10 +452,23 @@ }, { "cell_type": "code", - "execution_count": null, + "execution_count": 23, "metadata": {}, - "outputs": [], - "source": [] + "outputs": [ + { + "data": { + "text/plain": [ + "10" + ] + }, + "execution_count": 23, + "metadata": {}, + "output_type": "execute_result" + } + ], + "source": [ + "(3*10)//3" + ] }, { "cell_type": "markdown", @@ -426,12 +487,31 @@ }, { "cell_type": "code", - "execution_count": null, + "execution_count": 52, "metadata": { "tags": [] }, - "outputs": [], - "source": [] + "outputs": [ + { + "ename": "ModuleNotFoundError", + "evalue": "No module named '_curses'", + "output_type": "error", + "traceback": [ + "\u001b[1;31m---------------------------------------------------------------------------\u001b[0m", + "\u001b[1;31mModuleNotFoundError\u001b[0m Traceback (most recent call last)", + "\u001b[1;32mc:\\Users\\Divya\\.vscode\\extensions\\l1-python\\exercises\\TD01_prise_en_main\\01_prise_en_main.ipynb Cellule 38\u001b[0m in \u001b[0;36m\u001b[1;34m()\u001b[0m\n\u001b[1;32m----> 1\u001b[0m \u001b[39mfrom\u001b[39;00m \u001b[39mcurses\u001b[39;00m \u001b[39mimport\u001b[39;00m pair_content\n\u001b[0;32m 4\u001b[0m c\u001b[39m=\u001b[39m\u001b[39m4\u001b[39m\n\u001b[0;32m 5\u001b[0m \u001b[39mif\u001b[39;00m c\u001b[39m==\u001b[39mpair_content :(\u001b[39m\"\u001b[39m\u001b[39mtrue\u001b[39m\u001b[39m\"\u001b[39m) \u001b[39mor\u001b[39;00m c\u001b[39m==\u001b[39m\u001b[39many\u001b[39m (\u001b[39m\"\u001b[39m\u001b[39mfalse\u001b[39m\u001b[39m\"\u001b[39m)\n", + "File \u001b[1;32mc:\\Users\\Divya\\miniconda3\\envs\\l1-python\\lib\\curses\\__init__.py:13\u001b[0m, in \u001b[0;36m\u001b[1;34m\u001b[0m\n\u001b[0;32m 1\u001b[0m \u001b[39m\"\"\"curses\u001b[39;00m\n\u001b[0;32m 2\u001b[0m \n\u001b[0;32m 3\u001b[0m \u001b[39mThe main package for curses support for Python. Normally used by importing\u001b[39;00m\n\u001b[1;32m (...)\u001b[0m\n\u001b[0;32m 10\u001b[0m \n\u001b[0;32m 11\u001b[0m \u001b[39m\"\"\"\u001b[39;00m\n\u001b[1;32m---> 13\u001b[0m \u001b[39mfrom\u001b[39;00m \u001b[39m_curses\u001b[39;00m \u001b[39mimport\u001b[39;00m \u001b[39m*\u001b[39m\n\u001b[0;32m 14\u001b[0m \u001b[39mimport\u001b[39;00m \u001b[39mos\u001b[39;00m \u001b[39mas\u001b[39;00m \u001b[39m_os\u001b[39;00m\n\u001b[0;32m 15\u001b[0m \u001b[39mimport\u001b[39;00m \u001b[39msys\u001b[39;00m \u001b[39mas\u001b[39;00m \u001b[39m_sys\u001b[39;00m\n", + "\u001b[1;31mModuleNotFoundError\u001b[0m: No module named '_curses'" + ] + } + ], + "source": [ + "from curses import pair_content\n", + "\n", + "\n", + "c=4\n", + "if c==pair_content :(\"true\") or c==any (\"false\")" + ] }, { "cell_type": "markdown", @@ -442,12 +522,22 @@ }, { "cell_type": "code", - "execution_count": null, + "execution_count": 60, "metadata": { "tags": [] }, - "outputs": [], - "source": [] + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "115792089237316195423570985008687907853269984665640564039457584007913129639936 le nombre de chiffres est 78\n" + ] + } + ], + "source": [ + "print(2**256, \"le nombre de chiffres est\", len(str(2**256)))\n" + ] }, { "cell_type": "markdown", @@ -470,7 +560,14 @@ "tags": [] }, "outputs": [], - "source": [] + "source": [ + "print(2 ** 256, \"le nombre de chiffres est\", len(str(2 ** 256)))\n", + "s = input(\"Entrer un nombre entier\\n\")\n", + "print(int(s) % 2 == 0)\n", + "long = len(s)\n", + "print(int(s) // 10 ** (long - 1))\n", + "print(s[0])" + ] }, { "cell_type": "markdown", From c49a5d6d16c94c2c5f446ffb84c46e7e3bfe7e41 Mon Sep 17 00:00:00 2001 From: Divya SELVARAJU Date: Wed, 12 Oct 2022 10:44:11 +0200 Subject: [PATCH 03/23] travail --- .../03_structures_iteratives.ipynb | 9 +- .../TD01_prise_en_main/01_prise_en_main.ipynb | 189 ++++++++++-------- .../02_structures_controle.ipynb | 153 ++++++++++---- exercises/hello/hello.py | 4 +- 4 files changed, 228 insertions(+), 127 deletions(-) diff --git a/cours/03_structures_iteratives/03_structures_iteratives.ipynb b/cours/03_structures_iteratives/03_structures_iteratives.ipynb index f201afd3e..b7dd61257 100644 --- a/cours/03_structures_iteratives/03_structures_iteratives.ipynb +++ b/cours/03_structures_iteratives/03_structures_iteratives.ipynb @@ -825,7 +825,7 @@ "metadata": { "celltoolbar": "Diaporama", "kernelspec": { - "display_name": "Python 3", + "display_name": "Python 3.10.4 ('l1-python')", "language": "python", "name": "python3" }, @@ -839,7 +839,12 @@ "name": "python", "nbconvert_exporter": "python", "pygments_lexer": "ipython3", - "version": "3.7.6" + "version": "3.10.4" + }, + "vscode": { + "interpreter": { + "hash": "c40ec1b8fe39daf00984f8ba30325fc08ad307055404f66b6babdfa1fdac6336" + } } }, "nbformat": 4, diff --git a/exercises/TD01_prise_en_main/01_prise_en_main.ipynb b/exercises/TD01_prise_en_main/01_prise_en_main.ipynb index 8452fae27..58173196e 100644 --- a/exercises/TD01_prise_en_main/01_prise_en_main.ipynb +++ b/exercises/TD01_prise_en_main/01_prise_en_main.ipynb @@ -117,7 +117,8 @@ "metadata": {}, "outputs": [], "source": [ - "a= +1" + "a = 1 + 1\n", + "a = a + 1" ] }, { @@ -129,23 +130,11 @@ }, { "cell_type": "code", - "execution_count": 2, + "execution_count": null, "metadata": { "tags": [] }, - "outputs": [ - { - "ename": "NameError", - "evalue": "name 'a' is not defined", - "output_type": "error", - "traceback": [ - "\u001b[1;31m---------------------------------------------------------------------------\u001b[0m", - "\u001b[1;31mNameError\u001b[0m Traceback (most recent call last)", - "\u001b[1;32mc:\\Users\\Divya\\.vscode\\extensions\\l1-python\\exercises\\TD01_prise_en_main\\01_prise_en_main.ipynb Cellule 14\u001b[0m in \u001b[0;36m\u001b[1;34m()\u001b[0m\n\u001b[1;32m----> 1\u001b[0m \u001b[39mprint\u001b[39m(a)\n", - "\u001b[1;31mNameError\u001b[0m: name 'a' is not defined" - ] - } - ], + "outputs": [], "source": [ "print(a)" ] @@ -173,7 +162,7 @@ }, { "cell_type": "code", - "execution_count": 3, + "execution_count": 9, "metadata": { "tags": [] }, @@ -201,7 +190,7 @@ }, { "cell_type": "code", - "execution_count": 64, + "execution_count": 10, "metadata": { "tags": [] }, @@ -230,24 +219,22 @@ }, { "cell_type": "code", - "execution_count": 5, + "execution_count": 11, "metadata": { "tags": [] }, "outputs": [ { - "ename": "TypeError", - "evalue": "'a' is an invalid keyword argument for print()", - "output_type": "error", - "traceback": [ - "\u001b[1;31m---------------------------------------------------------------------------\u001b[0m", - "\u001b[1;31mTypeError\u001b[0m Traceback (most recent call last)", - "\u001b[1;32mc:\\Users\\Divya\\.vscode\\extensions\\l1-python\\exercises\\TD01_prise_en_main\\01_prise_en_main.ipynb Cellule 20\u001b[0m in \u001b[0;36m\u001b[1;34m()\u001b[0m\n\u001b[1;32m----> 1\u001b[0m \u001b[39mprint\u001b[39;49m (a\u001b[39m=\u001b[39;49ma, b\u001b[39m=\u001b[39;49mb)\n", - "\u001b[1;31mTypeError\u001b[0m: 'a' is an invalid keyword argument for print()" + "name": "stdout", + "output_type": "stream", + "text": [ + "a vaut 2 et b vaut 5\n" ] } ], - "source": [] + "source": [ + "print(\"a vaut\", a, \"et b vaut\", b)" + ] }, { "cell_type": "markdown", @@ -258,7 +245,7 @@ }, { "cell_type": "code", - "execution_count": 7, + "execution_count": 12, "metadata": { "tags": [] }, @@ -311,7 +298,7 @@ }, { "cell_type": "code", - "execution_count": 9, + "execution_count": 13, "metadata": {}, "outputs": [ { @@ -320,7 +307,7 @@ "float" ] }, - "execution_count": 9, + "execution_count": 13, "metadata": {}, "output_type": "execute_result" } @@ -344,7 +331,7 @@ }, { "cell_type": "code", - "execution_count": 14, + "execution_count": 16, "metadata": {}, "outputs": [ { @@ -353,7 +340,7 @@ "list" ] }, - "execution_count": 14, + "execution_count": 16, "metadata": {}, "output_type": "execute_result" } @@ -387,7 +374,8 @@ } ], "source": [ - "print (\"le type de x est \") if x==2 else true" + "x=5\n", + "print (\"le type de x est \") " ] }, { @@ -420,24 +408,22 @@ }, { "cell_type": "code", - "execution_count": 20, + "execution_count": 23, "metadata": { "tags": [] }, "outputs": [ { - "data": { - "text/plain": [ - "13.545454545454545" - ] - }, - "execution_count": 20, - "metadata": {}, - "output_type": "execute_result" + "ename": "SyntaxError", + "evalue": "unterminated string literal (detected at line 1) (2196359626.py, line 1)", + "output_type": "error", + "traceback": [ + "\u001b[1;36m Input \u001b[1;32mIn [23]\u001b[1;36m\u001b[0m\n\u001b[1;33m print(v, \"=\", v //11, \"x 11 \"+\", v % 11)\u001b[0m\n\u001b[1;37m ^\u001b[0m\n\u001b[1;31mSyntaxError\u001b[0m\u001b[1;31m:\u001b[0m unterminated string literal (detected at line 1)\n" + ] } ], "source": [ - "149/11" + "print(v, \"=\", v //11, \"x 11 +\", v % 11)" ] }, { @@ -452,22 +438,22 @@ }, { "cell_type": "code", - "execution_count": 23, + "execution_count": 21, "metadata": {}, "outputs": [ { "data": { "text/plain": [ - "10" + "9" ] }, - "execution_count": 23, + "execution_count": 21, "metadata": {}, "output_type": "execute_result" } ], "source": [ - "(3*10)//3" + "3*(10//3)" ] }, { @@ -487,30 +473,25 @@ }, { "cell_type": "code", - "execution_count": 52, + "execution_count": 24, "metadata": { "tags": [] }, "outputs": [ { - "ename": "ModuleNotFoundError", - "evalue": "No module named '_curses'", - "output_type": "error", - "traceback": [ - "\u001b[1;31m---------------------------------------------------------------------------\u001b[0m", - "\u001b[1;31mModuleNotFoundError\u001b[0m Traceback (most recent call last)", - "\u001b[1;32mc:\\Users\\Divya\\.vscode\\extensions\\l1-python\\exercises\\TD01_prise_en_main\\01_prise_en_main.ipynb Cellule 38\u001b[0m in \u001b[0;36m\u001b[1;34m()\u001b[0m\n\u001b[1;32m----> 1\u001b[0m \u001b[39mfrom\u001b[39;00m \u001b[39mcurses\u001b[39;00m \u001b[39mimport\u001b[39;00m pair_content\n\u001b[0;32m 4\u001b[0m c\u001b[39m=\u001b[39m\u001b[39m4\u001b[39m\n\u001b[0;32m 5\u001b[0m \u001b[39mif\u001b[39;00m c\u001b[39m==\u001b[39mpair_content :(\u001b[39m\"\u001b[39m\u001b[39mtrue\u001b[39m\u001b[39m\"\u001b[39m) \u001b[39mor\u001b[39;00m c\u001b[39m==\u001b[39m\u001b[39many\u001b[39m (\u001b[39m\"\u001b[39m\u001b[39mfalse\u001b[39m\u001b[39m\"\u001b[39m)\n", - "File \u001b[1;32mc:\\Users\\Divya\\miniconda3\\envs\\l1-python\\lib\\curses\\__init__.py:13\u001b[0m, in \u001b[0;36m\u001b[1;34m\u001b[0m\n\u001b[0;32m 1\u001b[0m \u001b[39m\"\"\"curses\u001b[39;00m\n\u001b[0;32m 2\u001b[0m \n\u001b[0;32m 3\u001b[0m \u001b[39mThe main package for curses support for Python. Normally used by importing\u001b[39;00m\n\u001b[1;32m (...)\u001b[0m\n\u001b[0;32m 10\u001b[0m \n\u001b[0;32m 11\u001b[0m \u001b[39m\"\"\"\u001b[39;00m\n\u001b[1;32m---> 13\u001b[0m \u001b[39mfrom\u001b[39;00m \u001b[39m_curses\u001b[39;00m \u001b[39mimport\u001b[39;00m \u001b[39m*\u001b[39m\n\u001b[0;32m 14\u001b[0m \u001b[39mimport\u001b[39;00m \u001b[39mos\u001b[39;00m \u001b[39mas\u001b[39;00m \u001b[39m_os\u001b[39;00m\n\u001b[0;32m 15\u001b[0m \u001b[39mimport\u001b[39;00m \u001b[39msys\u001b[39;00m \u001b[39mas\u001b[39;00m \u001b[39m_sys\u001b[39;00m\n", - "\u001b[1;31mModuleNotFoundError\u001b[0m: No module named '_curses'" - ] + "data": { + "text/plain": [ + "True" + ] + }, + "execution_count": 24, + "metadata": {}, + "output_type": "execute_result" } ], "source": [ - "from curses import pair_content\n", - "\n", - "\n", - "c=4\n", - "if c==pair_content :(\"true\") or c==any (\"false\")" + "a=56\n", + "a % 2 == 0" ] }, { @@ -522,7 +503,7 @@ }, { "cell_type": "code", - "execution_count": 60, + "execution_count": 25, "metadata": { "tags": [] }, @@ -555,18 +536,24 @@ }, { "cell_type": "code", - "execution_count": null, + "execution_count": 26, "metadata": { "tags": [] }, - "outputs": [], + "outputs": [ + { + "data": { + "text/plain": [ + "6" + ] + }, + "execution_count": 26, + "metadata": {}, + "output_type": "execute_result" + } + ], "source": [ - "print(2 ** 256, \"le nombre de chiffres est\", len(str(2 ** 256)))\n", - "s = input(\"Entrer un nombre entier\\n\")\n", - "print(int(s) % 2 == 0)\n", - "long = len(s)\n", - "print(int(s) // 10 ** (long - 1))\n", - "print(s[0])" + "a % 10" ] }, { @@ -578,12 +565,25 @@ }, { "cell_type": "code", - "execution_count": null, + "execution_count": 29, "metadata": { "tags": [] }, - "outputs": [], - "source": [] + "outputs": [ + { + "data": { + "text/plain": [ + "5" + ] + }, + "execution_count": 29, + "metadata": {}, + "output_type": "execute_result" + } + ], + "source": [ + "(a % 100) // 10" + ] }, { "cell_type": "markdown", @@ -597,12 +597,25 @@ }, { "cell_type": "code", - "execution_count": null, + "execution_count": 30, "metadata": { "tags": [] }, - "outputs": [], - "source": [] + "outputs": [ + { + "data": { + "text/plain": [ + "(0, 2, True, 6)" + ] + }, + "execution_count": 30, + "metadata": {}, + "output_type": "execute_result" + } + ], + "source": [ + "0,2+0,4 >= 0,6" + ] }, { "cell_type": "markdown", @@ -613,12 +626,26 @@ }, { "cell_type": "code", - "execution_count": null, + "execution_count": 31, "metadata": { "tags": [] }, - "outputs": [], - "source": [] + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "0.5\n" + ] + } + ], + "source": [ + "x=0.5 \n", + "x=x*2**30\n", + "print(int(x)/(2**30))\n", + "\n", + "\n" + ] }, { "cell_type": "markdown", diff --git a/exercises/TD02_structures_controle/02_structures_controle.ipynb b/exercises/TD02_structures_controle/02_structures_controle.ipynb index 10b551cbf..5a6800474 100644 --- a/exercises/TD02_structures_controle/02_structures_controle.ipynb +++ b/exercises/TD02_structures_controle/02_structures_controle.ipynb @@ -42,14 +42,31 @@ }, { "cell_type": "code", - "execution_count": null, + "execution_count": 7, "metadata": { "slideshow": { "slide_type": "notes" } }, - "outputs": [], - "source": [] + "outputs": [ + { + "ename": "NameError", + "evalue": "name 'num1' is not defined", + "output_type": "error", + "traceback": [ + "\u001b[1;31m---------------------------------------------------------------------------\u001b[0m", + "\u001b[1;31mNameError\u001b[0m Traceback (most recent call last)", + "\u001b[1;32mc:\\Users\\Divya\\.vscode\\extensions\\l1-python\\exercises\\TD02_structures_controle\\02_structures_controle.ipynb Cellule 3\u001b[0m in \u001b[0;36m\u001b[1;34m()\u001b[0m\n\u001b[1;32m----> 1\u001b[0m num1 \u001b[39m==\u001b[39m \u001b[39m15\u001b[39m\n\u001b[0;32m 2\u001b[0m num2 \u001b[39m==\u001b[39m \u001b[39m5\u001b[39m\n\u001b[0;32m 3\u001b[0m \u001b[39m15\u001b[39m \u001b[39m%\u001b[39m \u001b[39m5\u001b[39m \u001b[39m==\u001b[39m\u001b[39m0\u001b[39m\n", + "\u001b[1;31mNameError\u001b[0m: name 'num1' is not defined" + ] + } + ], + "source": [ + "num1 == 15\n", + "num2 == 5\n", + "\n", + "num1 % num2 == 0" + ] }, { "cell_type": "markdown", @@ -70,14 +87,32 @@ }, { "cell_type": "code", - "execution_count": null, + "execution_count": 9, "metadata": { "slideshow": { "slide_type": "notes" } }, - "outputs": [], - "source": [] + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "School is cancelled\n" + ] + } + ], + "source": [ + "state = \"Georgia\"\n", + "if state == \"Georgia\" :\n", + " print(\"School is cancelled\")\n", + "elif state == \"New Jersey\" :\n", + " print (\"School isn't cancelled\")\n", + "elif state == \"North Carolina\" :\n", + " print(\"School is postponed\")\n", + "else :\n", + " print (\"School's status is unknown\")" + ] }, { "cell_type": "markdown", @@ -108,14 +143,28 @@ }, { "cell_type": "code", - "execution_count": null, + "execution_count": 16, "metadata": { "slideshow": { "slide_type": "notes" } }, - "outputs": [], - "source": [] + "outputs": [ + { + "data": { + "text/plain": [ + "5" + ] + }, + "execution_count": 16, + "metadata": {}, + "output_type": "execute_result" + } + ], + "source": [ + "annee = 1997\n", + "1997 % 12" + ] }, { "cell_type": "markdown", @@ -132,14 +181,29 @@ }, { "cell_type": "code", - "execution_count": null, + "execution_count": 17, "metadata": { "slideshow": { "slide_type": "notes" } }, - "outputs": [], - "source": [] + "outputs": [ + { + "ename": "NameError", + "evalue": "name 'celsius' is not defined", + "output_type": "error", + "traceback": [ + "\u001b[1;31m---------------------------------------------------------------------------\u001b[0m", + "\u001b[1;31mNameError\u001b[0m Traceback (most recent call last)", + "\u001b[1;32mc:\\Users\\Divya\\.vscode\\extensions\\l1-python\\exercises\\TD02_structures_controle\\02_structures_controle.ipynb Cellule 9\u001b[0m in \u001b[0;36m\u001b[1;34m()\u001b[0m\n\u001b[0;32m 1\u001b[0m temperature \u001b[39m=\u001b[39m \u001b[39m-\u001b[39m\u001b[39m3.7\u001b[39m\n\u001b[0;32m 2\u001b[0m \u001b[39mif\u001b[39;00m temperature \u001b[39m==\u001b[39m \u001b[39m-\u001b[39m\u001b[39m3.7\u001b[39m :\n\u001b[1;32m----> 3\u001b[0m \u001b[39mprint\u001b[39m(celsius)\n\u001b[0;32m 4\u001b[0m \u001b[39melse\u001b[39;00m :\n\u001b[0;32m 5\u001b[0m \u001b[39mprint\u001b[39m(fahrenheit)\n", + "\u001b[1;31mNameError\u001b[0m: name 'celsius' is not defined" + ] + } + ], + "source": [ + "temperature = -3.7\n", + "celsius = True\n" + ] }, { "cell_type": "markdown", @@ -167,6 +231,8 @@ "source": [] }, { + "cell_type": "markdown", + "metadata": {}, "source": [ "---\n", "\n", @@ -176,9 +242,7 @@ "\n", "1. Ecrire un programme qui permet d'afficher tous les nombres entre 1 et 10 (bornes incluses).\n", "2. Ecrire un programme se limitant à la boucle *for* qui permet d'afficher tous les nombres pairs entre 1 et 20 (bornes incluses). Proposer une deuxième solution en incluant une structure conditionnelle." - ], - "cell_type": "markdown", - "metadata": {} + ] }, { "cell_type": "code", @@ -188,15 +252,15 @@ "source": [] }, { + "cell_type": "markdown", + "metadata": {}, "source": [ "**Exercice 7:**\n", " \n", "1. Ecrire un programme qui demande à l'utilisateur de saisir *n* nombres, *n* étant choisi par l'utilisateur, puis d'afficher la moyenne de ces nombres.\n", "\n", "2. Même question, mais l'utilisateur ne choisit pas à l'avance le nombre *n*, la procédure s'arrête quand il saisit le nombre -1.\n" - ], - "cell_type": "markdown", - "metadata": {} + ] }, { "cell_type": "code", @@ -213,6 +277,8 @@ "source": [] }, { + "cell_type": "markdown", + "metadata": {}, "source": [ "**Exercice 8:**\n", "\n", @@ -221,9 +287,7 @@ "\n", "1. Une première version en utilisant la boucle *for*\n", "2. Une seconde version en utilisant la boucle *while*" - ], - "cell_type": "markdown", - "metadata": {} + ] }, { "cell_type": "code", @@ -308,13 +372,13 @@ "source": [] }, { + "cell_type": "markdown", + "metadata": {}, "source": [ "**Exercice 11:**\n", " \n", "Ecrire un programme qui permet de calculer la somme des chiffres d'un entier *n* donné. Le nombre *n* doit être compris entre 10 et 20 (bornes incluses)." - ], - "cell_type": "markdown", - "metadata": {} + ] }, { "cell_type": "code", @@ -324,14 +388,14 @@ "source": [] }, { + "cell_type": "markdown", + "metadata": {}, "source": [ "**Exercice 12:**\n", "\n", "1. Ecrire un programme qui permet de générer aléatoirement deux nombres entre 0 et 9, de calculer leurs différences (en valeur absolue), puis d'inviter l'utilisateur à répondre à la question suivante *que vaut abs(number1 - number2)?*. Le programme doit permettre à l'utilisateur de répondre plusieurs fois jusqu'à la saisie de la bonne réponse.\n", "2. Modifier le programme précédent de telle sorte qu'il génère cinq occurences à la suite invitant à répondre à la question précédente. A la fin, le programme affiche le nombre moyen de tentatives qu'il a fallu à l'utilisateur pour répondre à une question." - ], - "cell_type": "markdown", - "metadata": {} + ] }, { "cell_type": "code", @@ -354,13 +418,13 @@ ] }, { + "cell_type": "markdown", + "metadata": {}, "source": [ "**Exercice 13:**\n", "\n", "Ecrire un programme qui permet de calculer le nombre de mots dans une phrase saisie par l'utilisateur." - ], - "cell_type": "markdown", - "metadata": {} + ] }, { "cell_type": "code", @@ -488,6 +552,8 @@ "source": [] }, { + "cell_type": "markdown", + "metadata": {}, "source": [ "**Exercice 17:**\n", "\n", @@ -500,9 +566,7 @@ "*****\n", "******\n", "```" - ], - "cell_type": "markdown", - "metadata": {} + ] }, { "cell_type": "code", @@ -514,6 +578,8 @@ "source": [] }, { + "cell_type": "markdown", + "metadata": {}, "source": [ "**Exercice 18:**\n", "\n", @@ -526,9 +592,7 @@ " *****\n", "******\n", "```" - ], - "cell_type": "markdown", - "metadata": {} + ] }, { "cell_type": "code", @@ -540,13 +604,13 @@ "source": [] }, { + "cell_type": "markdown", + "metadata": {}, "source": [ "**Exercice 19:**\n", "\n", "Ecrire un programme qui calcule, étant donné un entier *n* rentré par l'utilisateur, la plus grande puissance de *n* inférieure à un million." - ], - "cell_type": "markdown", - "metadata": {} + ] }, { "cell_type": "code", @@ -561,7 +625,7 @@ "metadata": { "celltoolbar": "Diaporama", "kernelspec": { - "display_name": "Python 3", + "display_name": "Python 3.10.4 ('l1-python')", "language": "python", "name": "python3" }, @@ -575,9 +639,14 @@ "name": "python", "nbconvert_exporter": "python", "pygments_lexer": "ipython3", - "version": "3.7.6-final" + "version": "3.10.4" + }, + "vscode": { + "interpreter": { + "hash": "c40ec1b8fe39daf00984f8ba30325fc08ad307055404f66b6babdfa1fdac6336" + } } }, "nbformat": 4, "nbformat_minor": 4 -} \ No newline at end of file +} diff --git a/exercises/hello/hello.py b/exercises/hello/hello.py index 1dbbb857f..859c0025e 100644 --- a/exercises/hello/hello.py +++ b/exercises/hello/hello.py @@ -1,2 +1,2 @@ -msg = "" -print() +msg = "hello world" +print(msg.capitalize ()) From 793a8bc41cb38216e65d34784a22c42277c7236b Mon Sep 17 00:00:00 2001 From: Divya SELVARAJU Date: Wed, 12 Oct 2022 16:18:29 +0200 Subject: [PATCH 04/23] oui --- .../02_structures_controle.ipynb | 100 ++++++++++++------ 1 file changed, 70 insertions(+), 30 deletions(-) diff --git a/exercises/TD02_structures_controle/02_structures_controle.ipynb b/exercises/TD02_structures_controle/02_structures_controle.ipynb index 5a6800474..d8b3d6d9a 100644 --- a/exercises/TD02_structures_controle/02_structures_controle.ipynb +++ b/exercises/TD02_structures_controle/02_structures_controle.ipynb @@ -42,7 +42,7 @@ }, { "cell_type": "code", - "execution_count": 7, + "execution_count": 29, "metadata": { "slideshow": { "slide_type": "notes" @@ -50,22 +50,21 @@ }, "outputs": [ { - "ename": "NameError", - "evalue": "name 'num1' is not defined", - "output_type": "error", - "traceback": [ - "\u001b[1;31m---------------------------------------------------------------------------\u001b[0m", - "\u001b[1;31mNameError\u001b[0m Traceback (most recent call last)", - "\u001b[1;32mc:\\Users\\Divya\\.vscode\\extensions\\l1-python\\exercises\\TD02_structures_controle\\02_structures_controle.ipynb Cellule 3\u001b[0m in \u001b[0;36m\u001b[1;34m()\u001b[0m\n\u001b[1;32m----> 1\u001b[0m num1 \u001b[39m==\u001b[39m \u001b[39m15\u001b[39m\n\u001b[0;32m 2\u001b[0m num2 \u001b[39m==\u001b[39m \u001b[39m5\u001b[39m\n\u001b[0;32m 3\u001b[0m \u001b[39m15\u001b[39m \u001b[39m%\u001b[39m \u001b[39m5\u001b[39m \u001b[39m==\u001b[39m\u001b[39m0\u001b[39m\n", - "\u001b[1;31mNameError\u001b[0m: name 'num1' is not defined" + "name": "stdout", + "output_type": "stream", + "text": [ + "Factors!\n" ] } ], "source": [ - "num1 == 15\n", - "num2 == 5\n", + "num1 = 15\n", + "num2 = 5\n", "\n", - "num1 % num2 == 0" + "if num1 % num2 == 0 or num2 % num1 == 0 :\n", + " print(\"Factors!\")\n", + "else :\n", + " print(\"not factors\")" ] }, { @@ -181,7 +180,7 @@ }, { "cell_type": "code", - "execution_count": 17, + "execution_count": 19, "metadata": { "slideshow": { "slide_type": "notes" @@ -189,20 +188,20 @@ }, "outputs": [ { - "ename": "NameError", - "evalue": "name 'celsius' is not defined", - "output_type": "error", - "traceback": [ - "\u001b[1;31m---------------------------------------------------------------------------\u001b[0m", - "\u001b[1;31mNameError\u001b[0m Traceback (most recent call last)", - "\u001b[1;32mc:\\Users\\Divya\\.vscode\\extensions\\l1-python\\exercises\\TD02_structures_controle\\02_structures_controle.ipynb Cellule 9\u001b[0m in \u001b[0;36m\u001b[1;34m()\u001b[0m\n\u001b[0;32m 1\u001b[0m temperature \u001b[39m=\u001b[39m \u001b[39m-\u001b[39m\u001b[39m3.7\u001b[39m\n\u001b[0;32m 2\u001b[0m \u001b[39mif\u001b[39;00m temperature \u001b[39m==\u001b[39m \u001b[39m-\u001b[39m\u001b[39m3.7\u001b[39m :\n\u001b[1;32m----> 3\u001b[0m \u001b[39mprint\u001b[39m(celsius)\n\u001b[0;32m 4\u001b[0m \u001b[39melse\u001b[39;00m :\n\u001b[0;32m 5\u001b[0m \u001b[39mprint\u001b[39m(fahrenheit)\n", - "\u001b[1;31mNameError\u001b[0m: name 'celsius' is not defined" + "name": "stdout", + "output_type": "stream", + "text": [ + "Not freezing\n" ] } ], "source": [ "temperature = -3.7\n", - "celsius = True\n" + "celsius = True\n", + "if temperature >= 32 :\n", + " print(\"Freezing\")\n", + "else :\n", + " print(\"Not freezing\")" ] }, { @@ -221,14 +220,28 @@ }, { "cell_type": "code", - "execution_count": null, + "execution_count": 1, "metadata": { "slideshow": { "slide_type": "notes" } }, - "outputs": [], - "source": [] + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "année non bissextile\n" + ] + } + ], + "source": [ + "A = 2022 \n", + "if (A % 4 == 0 and A % 100 != 0) or A % 400 == 0:\n", + " print(\"année bissextile\")\n", + "else :\n", + " print(\"année non bissextile\")" + ] }, { "cell_type": "markdown", @@ -246,10 +259,32 @@ }, { "cell_type": "code", - "execution_count": null, + "execution_count": 20, "metadata": {}, - "outputs": [], - "source": [] + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "Afficher les valeurs dans l'intervalle:\n", + "i = 1\n", + "i = 2\n", + "i = 3\n", + "i = 4\n", + "i = 5\n", + "i = 6\n", + "i = 7\n", + "i = 8\n", + "i = 9\n", + "i = 10\n" + ] + } + ], + "source": [ + "print(\"Afficher les valeurs dans l'intervalle:\")\n", + "for i in range(1, 11) :\n", + " print(\"i =\", i)" + ] }, { "cell_type": "markdown", @@ -264,10 +299,15 @@ }, { "cell_type": "code", - "execution_count": null, + "execution_count": 27, "metadata": {}, "outputs": [], - "source": [] + "source": [ + "nb = int(input(\"choisir un nombre d'entrées\"))\n", + "\n", + "for a in range (0,nb) :\n", + " input(\"entrez un nombre\")\n" + ] }, { "cell_type": "code", From 8b95854c0c161e1253762bfdd17e57fbd098d7e9 Mon Sep 17 00:00:00 2001 From: Divya SELVARAJU Date: Wed, 12 Oct 2022 16:39:07 +0200 Subject: [PATCH 05/23] oui --- .../03_structures_iteratives.ipynb | 156 +++++++++++++++++- .../02_structures_controle.ipynb | 24 ++- 2 files changed, 166 insertions(+), 14 deletions(-) diff --git a/cours/03_structures_iteratives/03_structures_iteratives.ipynb b/cours/03_structures_iteratives/03_structures_iteratives.ipynb index b7dd61257..b9500d043 100644 --- a/cours/03_structures_iteratives/03_structures_iteratives.ipynb +++ b/cours/03_structures_iteratives/03_structures_iteratives.ipynb @@ -129,13 +129,32 @@ }, { "cell_type": "code", - "execution_count": null, + "execution_count": 1, "metadata": { "slideshow": { "slide_type": "fragment" } }, - "outputs": [], + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "Afficher les valeurs dans l'intervalle:\n", + "i = 1\n", + "i = 2\n", + "i = 3\n", + "i = 4\n", + "i = 5\n", + "i = 6\n", + "i = 7\n", + "i = 8\n", + "i = 9\n", + "i = 10\n", + "Terminé\n" + ] + } + ], "source": [ "print(\"Afficher les valeurs dans l'intervalle:\")\n", "for i in range(1, 11) :\n", @@ -237,13 +256,109 @@ }, { "cell_type": "code", - "execution_count": null, + "execution_count": 2, "metadata": { "slideshow": { "slide_type": "fragment" } }, - "outputs": [], + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "Afficher les valeurs dans l intervalle:\n", + "i = 4\n", + "i = 3\n", + "i = 2\n", + "Terminé\n", + "Help on class range in module builtins:\n", + "\n", + "class range(object)\n", + " | range(stop) -> range object\n", + " | range(start, stop[, step]) -> range object\n", + " | \n", + " | Return an object that produces a sequence of integers from start (inclusive)\n", + " | to stop (exclusive) by step. range(i, j) produces i, i+1, i+2, ..., j-1.\n", + " | start defaults to 0, and stop is omitted! range(4) produces 0, 1, 2, 3.\n", + " | These are exactly the valid indices for a list of 4 elements.\n", + " | When step is given, it specifies the increment (or decrement).\n", + " | \n", + " | Methods defined here:\n", + " | \n", + " | __bool__(self, /)\n", + " | True if self else False\n", + " | \n", + " | __contains__(self, key, /)\n", + " | Return key in self.\n", + " | \n", + " | __eq__(self, value, /)\n", + " | Return self==value.\n", + " | \n", + " | __ge__(self, value, /)\n", + " | Return self>=value.\n", + " | \n", + " | __getattribute__(self, name, /)\n", + " | Return getattr(self, name).\n", + " | \n", + " | __getitem__(self, key, /)\n", + " | Return self[key].\n", + " | \n", + " | __gt__(self, value, /)\n", + " | Return self>value.\n", + " | \n", + " | __hash__(self, /)\n", + " | Return hash(self).\n", + " | \n", + " | __iter__(self, /)\n", + " | Implement iter(self).\n", + " | \n", + " | __le__(self, value, /)\n", + " | Return self<=value.\n", + " | \n", + " | __len__(self, /)\n", + " | Return len(self).\n", + " | \n", + " | __lt__(self, value, /)\n", + " | Return self integer -- return number of occurrences of value\n", + " | \n", + " | index(...)\n", + " | rangeobject.index(value) -> integer -- return index of value.\n", + " | Raise ValueError if the value is not present.\n", + " | \n", + " | ----------------------------------------------------------------------\n", + " | Static methods defined here:\n", + " | \n", + " | __new__(*args, **kwargs) from builtins.type\n", + " | Create and return a new object. See help(type) for accurate signature.\n", + " | \n", + " | ----------------------------------------------------------------------\n", + " | Data descriptors defined here:\n", + " | \n", + " | start\n", + " | \n", + " | step\n", + " | \n", + " | stop\n", + "\n" + ] + } + ], "source": [ "print('Afficher les valeurs dans l intervalle:')\n", "for i in range(4, 1, -1) :\n", @@ -265,13 +380,30 @@ }, { "cell_type": "code", - "execution_count": null, + "execution_count": 3, "metadata": { "slideshow": { "slide_type": "fragment" } }, - "outputs": [], + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "Avant addition i = 1\n", + "Après addition i = 2\n", + "Avant addition i = 4\n", + "Après addition i = 5\n", + "Avant addition i = 7\n", + "Après addition i = 8\n", + "Avant addition i = 10\n", + "Après addition i = 11\n", + "Dernière valeur, i = 11\n", + "Terminé\n" + ] + } + ], "source": [ "for i in range(1, 11, 3) :\n", " print(\"Avant addition i =\", i)\n", @@ -309,13 +441,21 @@ }, { "cell_type": "code", - "execution_count": null, + "execution_count": 5, "metadata": { "slideshow": { "slide_type": "fragment" } }, - "outputs": [], + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "La somme vaut : 10\n" + ] + } + ], "source": [ "n = int(input(\"Entrez un nombre :\"))\n", "result = 0\n", diff --git a/exercises/TD02_structures_controle/02_structures_controle.ipynb b/exercises/TD02_structures_controle/02_structures_controle.ipynb index d8b3d6d9a..45d81421d 100644 --- a/exercises/TD02_structures_controle/02_structures_controle.ipynb +++ b/exercises/TD02_structures_controle/02_structures_controle.ipynb @@ -259,7 +259,7 @@ }, { "cell_type": "code", - "execution_count": 20, + "execution_count": 7, "metadata": {}, "outputs": [ { @@ -276,14 +276,26 @@ "i = 7\n", "i = 8\n", "i = 9\n", - "i = 10\n" + "i = 10\n", + "i= 2\n", + "i= 4\n", + "i= 6\n", + "i= 8\n", + "i= 10\n", + "i= 12\n", + "i= 14\n", + "i= 16\n", + "i= 18\n", + "i= 20\n" ] } ], "source": [ "print(\"Afficher les valeurs dans l'intervalle:\")\n", "for i in range(1, 11) :\n", - " print(\"i =\", i)" + " print(\"i =\", i)\n", + "for i in range(2, 22, 2) :\n", + " print(\"i=\", i)" ] }, { @@ -303,10 +315,10 @@ "metadata": {}, "outputs": [], "source": [ - "nb = int(input(\"choisir un nombre d'entrées\"))\n", + "n = int(input(\"nombre de nombre\"))\n", "\n", - "for a in range (0,nb) :\n", - " input(\"entrez un nombre\")\n" + "for i in range (n) :\n", + " x = int(input(\"saisir un nombre\"))\n" ] }, { From 68e77d1062a4e96b58a71c3a896dd8dd741a39f6 Mon Sep 17 00:00:00 2001 From: Divya SELVARAJU Date: Wed, 12 Oct 2022 16:47:37 +0200 Subject: [PATCH 06/23] oui --- .../TD02_structures_controle/02_structures_controle.ipynb | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/exercises/TD02_structures_controle/02_structures_controle.ipynb b/exercises/TD02_structures_controle/02_structures_controle.ipynb index 45d81421d..075b8d4c9 100644 --- a/exercises/TD02_structures_controle/02_structures_controle.ipynb +++ b/exercises/TD02_structures_controle/02_structures_controle.ipynb @@ -316,9 +316,10 @@ "outputs": [], "source": [ "n = int(input(\"nombre de nombre\"))\n", - "\n", + "s = 0\n", "for i in range (n) :\n", - " x = int(input(\"saisir un nombre\"))\n" + " x = int(input(\"saisir un nombre\"))\n", + " s += x \n" ] }, { From 11137ee9f9edd1600e300542f5150a981687a657 Mon Sep 17 00:00:00 2001 From: Divya SELVARAJU Date: Wed, 19 Oct 2022 10:00:55 +0200 Subject: [PATCH 07/23] oui --- .../02_structures_controle.ipynb | 76 ++++++++++++++++--- 1 file changed, 64 insertions(+), 12 deletions(-) diff --git a/exercises/TD02_structures_controle/02_structures_controle.ipynb b/exercises/TD02_structures_controle/02_structures_controle.ipynb index 075b8d4c9..d297d8423 100644 --- a/exercises/TD02_structures_controle/02_structures_controle.ipynb +++ b/exercises/TD02_structures_controle/02_structures_controle.ipynb @@ -311,15 +311,30 @@ }, { "cell_type": "code", - "execution_count": 27, + "execution_count": 1, "metadata": {}, - "outputs": [], + "outputs": [ + { + "ename": "ValueError", + "evalue": "invalid literal for int() with base 10: ''", + "output_type": "error", + "traceback": [ + "\u001b[1;31m---------------------------------------------------------------------------\u001b[0m", + "\u001b[1;31mValueError\u001b[0m Traceback (most recent call last)", + "\u001b[1;32mc:\\Users\\Divya\\.vscode\\extensions\\l1-python\\exercises\\TD02_structures_controle\\02_structures_controle.ipynb Cellule 15\u001b[0m in \u001b[0;36m\u001b[1;34m()\u001b[0m\n\u001b[0;32m 3\u001b[0m s \u001b[39m=\u001b[39m \u001b[39m0\u001b[39m\n\u001b[0;32m 5\u001b[0m \u001b[39mfor\u001b[39;00m i \u001b[39min\u001b[39;00m \u001b[39mrange\u001b[39m (n) :\n\u001b[1;32m----> 6\u001b[0m x \u001b[39m=\u001b[39m \u001b[39mint\u001b[39;49m(\u001b[39minput\u001b[39;49m(\u001b[39m\"\u001b[39;49m\u001b[39msaisir un nombre\u001b[39;49m\u001b[39m\"\u001b[39;49m))\n\u001b[0;32m 7\u001b[0m s \u001b[39m=\u001b[39m s \u001b[39m+\u001b[39m x \n\u001b[0;32m 8\u001b[0m \u001b[39mreturn\u001b[39;00m s \u001b[39m/\u001b[39m n\n", + "\u001b[1;31mValueError\u001b[0m: invalid literal for int() with base 10: ''" + ] + } + ], "source": [ - "n = int(input(\"nombre de nombre\"))\n", + "n = int(input('nombre de nombre ?'))\n", + "\n", "s = 0\n", + "\n", "for i in range (n) :\n", - " x = int(input(\"saisir un nombre\"))\n", - " s += x \n" + " x = int(input('saisir un nombre'))\n", + " s = s + x \n", + "print(s / n)\n" ] }, { @@ -327,7 +342,14 @@ "execution_count": null, "metadata": {}, "outputs": [], - "source": [] + "source": [ + "s = 0\n", + "x = 0 \n", + "while x != -1 :\n", + " s s + x\n", + " x = int(input('saisir un nombre'))\n", + "print (s / n)" + ] }, { "cell_type": "markdown", @@ -344,17 +366,47 @@ }, { "cell_type": "code", - "execution_count": null, + "execution_count": 2, "metadata": {}, - "outputs": [], - "source": [] + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "24\n" + ] + } + ], + "source": [ + "f = 1\n", + "n = 4\n", + "for i in range(2, n + 1) :\n", + " f = f*i\n", + "print(f)" + ] }, { "cell_type": "code", - "execution_count": null, + "execution_count": 4, "metadata": {}, - "outputs": [], - "source": [] + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "24\n" + ] + } + ], + "source": [ + "f = 1\n", + "i = 2\n", + "n = 4\n", + "while i <= n :\n", + " f = f*i\n", + " i = i + 1\n", + "print(f)" + ] }, { "cell_type": "markdown", From f99f9c6072d371da68a472049034eca888a6557b Mon Sep 17 00:00:00 2001 From: Divya SELVARAJU Date: Wed, 19 Oct 2022 10:43:01 +0200 Subject: [PATCH 08/23] oui --- .../02_structures_controle.ipynb | 33 ++++++++++++++++--- 1 file changed, 29 insertions(+), 4 deletions(-) diff --git a/exercises/TD02_structures_controle/02_structures_controle.ipynb b/exercises/TD02_structures_controle/02_structures_controle.ipynb index d297d8423..ccd15deaa 100644 --- a/exercises/TD02_structures_controle/02_structures_controle.ipynb +++ b/exercises/TD02_structures_controle/02_structures_controle.ipynb @@ -438,14 +438,30 @@ }, { "cell_type": "code", - "execution_count": null, + "execution_count": 10, "metadata": { "slideshow": { "slide_type": "notes" } }, - "outputs": [], - "source": [] + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "10\n" + ] + } + ], + "source": [ + "n = 0\n", + "for i in range(5) :\n", + " reponse = input(\"le nombre est-il dans l'ensemble\" + str(i + 1) + \" ? \")\n", + " if reponse =='oui' :\n", + " n= n + 2**i\n", + "\n", + "print(n)\n" + ] }, { "cell_type": "markdown", @@ -474,7 +490,16 @@ } }, "outputs": [], - "source": [] + "source": [ + "import random \n", + "\n", + "nombre_a_generer : random.radint(0, 99)\n", + "reponse_utilisateur = int(input(\"saisir un nombre a deux chiffres\"))\n", + "\n", + "if reponse_utilisateur == nombre_a_generer : \n", + " print(\"10 000€\")\n", + "elif reponse_utilisateur " + ] }, { "cell_type": "markdown", From 6c1d79b930822f6753bd2c65ab255676450c0607 Mon Sep 17 00:00:00 2001 From: Divya SELVARAJU Date: Wed, 19 Oct 2022 11:05:12 +0200 Subject: [PATCH 09/23] oui --- .../02_structures_controle.ipynb | 34 ++++++++++++++----- 1 file changed, 26 insertions(+), 8 deletions(-) diff --git a/exercises/TD02_structures_controle/02_structures_controle.ipynb b/exercises/TD02_structures_controle/02_structures_controle.ipynb index ccd15deaa..ffd6c02b7 100644 --- a/exercises/TD02_structures_controle/02_structures_controle.ipynb +++ b/exercises/TD02_structures_controle/02_structures_controle.ipynb @@ -483,22 +483,40 @@ }, { "cell_type": "code", - "execution_count": null, + "execution_count": 11, "metadata": { "slideshow": { "slide_type": "notes" } }, - "outputs": [], + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "7 2\n", + "gagné 1 000 €\n" + ] + } + ], "source": [ "import random \n", "\n", - "nombre_a_generer : random.radint(0, 99)\n", - "reponse_utilisateur = int(input(\"saisir un nombre a deux chiffres\"))\n", - "\n", - "if reponse_utilisateur == nombre_a_generer : \n", - " print(\"10 000€\")\n", - "elif reponse_utilisateur " + "d = random.randint(0, 9)\n", + "u = random.randint(0, 9)\n", + "print(u, d)\n", + "n = int(input(\"saisir un nombre à (au plus) deux chiffres\"))\n", + "a = n // 10\n", + "b = n % 10\n", + "\n", + "if d == a and u == b :\n", + " print(\"gagné 10 000 €\")\n", + "elif d == b and u == a :\n", + " print(\"gagné 3 000 €\")\n", + "elif d == a or d == b or u == a or u == b :\n", + " print(\"gagné 1 000 €\")\n", + "else :\n", + " print(\"perdu\")\n" ] }, { From ceb2569d23bd31df77e6ab0730bf1f179a8cf701 Mon Sep 17 00:00:00 2001 From: Divya SELVARAJU Date: Wed, 19 Oct 2022 11:08:17 +0200 Subject: [PATCH 10/23] oui --- .../02_structures_controle.ipynb | 27 +++++++++++++------ 1 file changed, 19 insertions(+), 8 deletions(-) diff --git a/exercises/TD02_structures_controle/02_structures_controle.ipynb b/exercises/TD02_structures_controle/02_structures_controle.ipynb index ffd6c02b7..3b456db58 100644 --- a/exercises/TD02_structures_controle/02_structures_controle.ipynb +++ b/exercises/TD02_structures_controle/02_structures_controle.ipynb @@ -483,7 +483,7 @@ }, { "cell_type": "code", - "execution_count": 11, + "execution_count": 14, "metadata": { "slideshow": { "slide_type": "notes" @@ -494,8 +494,8 @@ "name": "stdout", "output_type": "stream", "text": [ - "7 2\n", - "gagné 1 000 €\n" + "perdu\n", + "le bon nombre était 15\n" ] } ], @@ -504,7 +504,6 @@ "\n", "d = random.randint(0, 9)\n", "u = random.randint(0, 9)\n", - "print(u, d)\n", "n = int(input(\"saisir un nombre à (au plus) deux chiffres\"))\n", "a = n // 10\n", "b = n % 10\n", @@ -516,7 +515,8 @@ "elif d == a or d == b or u == a or u == b :\n", " print(\"gagné 1 000 €\")\n", "else :\n", - " print(\"perdu\")\n" + " print(\"perdu\")\n", + "print(\"le bon nombre était\", d*10 + u)" ] }, { @@ -530,10 +530,21 @@ }, { "cell_type": "code", - "execution_count": null, + "execution_count": 13, "metadata": {}, - "outputs": [], - "source": [] + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "7\n" + ] + } + ], + "source": [ + "n = 16\n", + "print(n//10 + n%10)" + ] }, { "cell_type": "markdown", From d5152994e18ccdabae852482be6f1785292389cb Mon Sep 17 00:00:00 2001 From: Divya SELVARAJU Date: Wed, 19 Oct 2022 11:57:50 +0200 Subject: [PATCH 11/23] oui --- .../02_structures_controle.ipynb | 40 ++++++++++++++----- 1 file changed, 31 insertions(+), 9 deletions(-) diff --git a/exercises/TD02_structures_controle/02_structures_controle.ipynb b/exercises/TD02_structures_controle/02_structures_controle.ipynb index 3b456db58..d7970368f 100644 --- a/exercises/TD02_structures_controle/02_structures_controle.ipynb +++ b/exercises/TD02_structures_controle/02_structures_controle.ipynb @@ -483,7 +483,7 @@ }, { "cell_type": "code", - "execution_count": 14, + "execution_count": 17, "metadata": { "slideshow": { "slide_type": "notes" @@ -495,7 +495,7 @@ "output_type": "stream", "text": [ "perdu\n", - "le bon nombre était 15\n" + "le bon nombre était 46\n" ] } ], @@ -530,20 +530,24 @@ }, { "cell_type": "code", - "execution_count": 13, + "execution_count": 18, "metadata": {}, "outputs": [ { "name": "stdout", "output_type": "stream", "text": [ - "7\n" + "46\n" ] } ], "source": [ - "n = 16\n", - "print(n//10 + n%10)" + "n = 2457467542 \n", + "s = 0\n", + "while n != 0 :\n", + " s = s + n % 10\n", + " n = n // 10\n", + "print(s)" ] }, { @@ -558,12 +562,30 @@ }, { "cell_type": "code", - "execution_count": null, + "execution_count": 20, "metadata": { "tags": [] }, - "outputs": [], - "source": [] + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "gagné, l'écart était 0 avec les nombres 9 9\n" + ] + } + ], + "source": [ + "import random\n", + "\n", + "x = random.randint(0, 9)\n", + "y = random.randint(0, 9)\n", + "ecart = abs(x - y)\n", + "reponse = None\n", + "while reponse != ecart :\n", + " reponse = int(input(\"proposer un écart\"))\n", + "print(\"gagné, l'écart était\", ecart, \"avec les nombres\", x, y)\n" + ] }, { "cell_type": "code", From 5b726c48124ac27fc1d607a102267127e46f9da3 Mon Sep 17 00:00:00 2001 From: Divya SELVARAJU Date: Wed, 19 Oct 2022 12:37:59 +0200 Subject: [PATCH 12/23] oui --- .../02_structures_controle.ipynb | 53 ++++++++++++++++--- 1 file changed, 47 insertions(+), 6 deletions(-) diff --git a/exercises/TD02_structures_controle/02_structures_controle.ipynb b/exercises/TD02_structures_controle/02_structures_controle.ipynb index d7970368f..8769018ca 100644 --- a/exercises/TD02_structures_controle/02_structures_controle.ipynb +++ b/exercises/TD02_structures_controle/02_structures_controle.ipynb @@ -589,13 +589,38 @@ }, { "cell_type": "code", - "execution_count": null, + "execution_count": 24, "metadata": { "tags": [] }, - "outputs": [], + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "gagné en 7 coup(s) l'écart était 6 avec les nombres 2 8\n", + "gagné en 5 coup(s) l'écart était 1 avec les nombres 2 1\n", + "gagné en 9 coup(s) l'écart était 0 avec les nombres 2 2\n", + "gagné en 4 coup(s) l'écart était 4 avec les nombres 9 5\n", + "gagné en 6 coup(s) l'écart était 0 avec les nombres 7 7\n", + "6.2\n" + ] + } + ], "source": [ - "\n" + "s = 0\n", + "for tour in range(5) :\n", + " x = random.randint(0, 9)\n", + " y = random.randint(0, 9)\n", + " ecart = abs(x - y)\n", + " reponse = None\n", + " tentatives = 0\n", + " while reponse != ecart :\n", + " reponse = int(input(\"proposer un écart\"))\n", + " tentatives = tentatives + 1\n", + " print(\"gagné en\", tentatives, \"coup(s) l'écart était\", ecart, \"avec les nombres\", x, y)\n", + " s = s + tentatives\n", + "print(s / 5)\n" ] }, { @@ -609,13 +634,29 @@ }, { "cell_type": "code", - "execution_count": null, + "execution_count": 35, "metadata": { "tags": [] }, - "outputs": [], + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "nombre de mots: 4\n" + ] + } + ], "source": [ - " " + "# on compte le nombre d'espaces et on ajoute 1\n", + "\n", + "phrase = input('saisir une phrase')\n", + "nb_espaces = 0\n", + "for caractère in phrase :\n", + " if caractère == ' ':\n", + " nb_espaces = nb_espaces + 1\n", + "\n", + "print('nombre de mots:', nb_espaces + 1)" ] }, { From 2d70671edb60cec2e8e7fbe1d86fc4b781c915bd Mon Sep 17 00:00:00 2001 From: Divya SELVARAJU Date: Mon, 7 Nov 2022 11:19:10 +0100 Subject: [PATCH 13/23] oui --- .../02_structures_controle.ipynb | 22 ++- .../exercices kholle.ipynb | 155 ++++++++++++++++++ .../TD02_structures_controle/kholle.ipynb | 0 3 files changed, 174 insertions(+), 3 deletions(-) create mode 100644 exercises/TD02_structures_controle/exercices kholle.ipynb create mode 100644 exercises/TD02_structures_controle/kholle.ipynb diff --git a/exercises/TD02_structures_controle/02_structures_controle.ipynb b/exercises/TD02_structures_controle/02_structures_controle.ipynb index 8769018ca..e0490268e 100644 --- a/exercises/TD02_structures_controle/02_structures_controle.ipynb +++ b/exercises/TD02_structures_controle/02_structures_controle.ipynb @@ -792,12 +792,28 @@ }, { "cell_type": "code", - "execution_count": null, + "execution_count": 36, "metadata": { "tags": [] }, - "outputs": [], - "source": [] + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "*\n", + "**\n", + "***\n", + "****\n", + "*****\n", + "******\n" + ] + } + ], + "source": [ + "for i in range(1, 7) :\n", + " print(i* \"*\")" + ] }, { "cell_type": "markdown", diff --git a/exercises/TD02_structures_controle/exercices kholle.ipynb b/exercises/TD02_structures_controle/exercices kholle.ipynb new file mode 100644 index 000000000..8d0240266 --- /dev/null +++ b/exercises/TD02_structures_controle/exercices kholle.ipynb @@ -0,0 +1,155 @@ +{ + "cells": [ + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [] + }, + { + "cell_type": "code", + "execution_count": 5, + "metadata": {}, + "outputs": [], + "source": [ + "#exercice 2\n", + "import random\n", + "\n", + "x = random.randint(10, 99)\n", + "y = int(input(\"saisissez un chiffre\"))\n", + "if y >= 1 and x % y == 0 :\n", + " print(\"Diviseur\")" + ] + }, + { + "cell_type": "code", + "execution_count": 7, + "metadata": {}, + "outputs": [], + "source": [ + "var1 = 34\n", + "var2 = 7\n", + "\n", + "if var1>0 and var2>0 or var1<0 and var2<0 :\n", + " var1, var2 = var2, var1\n", + "else :\n", + " x = var1**var2\n", + " var2 = var1*var2\n", + " var1 = x\n" + ] + }, + { + "cell_type": "code", + "execution_count": 9, + "metadata": {}, + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "6\n" + ] + } + ], + "source": [ + "#exercice 1\n", + "\n", + "a = 120\n", + "b = 54\n", + "\n", + "for x in range (a, 0, -1):\n", + " if a % x == 0 and b % x == 0 :\n", + " print(x)\n", + " break" + ] + }, + { + "cell_type": "code", + "execution_count": 11, + "metadata": {}, + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "1518\n" + ] + } + ], + "source": [ + "#exercice 2\n", + "\n", + "somme = 0\n", + "n = int(input(\"âge ?\"))\n", + "for i in range (1, n + 1):\n", + " somme = somme + 120 + 3*i\n", + "print(somme)\n" + ] + }, + { + "cell_type": "code", + "execution_count": 12, + "metadata": {}, + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "10\n", + "9\n", + "8\n", + "7\n", + "6\n", + "5\n", + "4\n", + "3\n", + "2\n", + "1\n" + ] + } + ], + "source": [ + "#exercice 3\n", + "\n", + "n = int(input(\"saisir un nombre\"))\n", + "for i in range(n-1, n-11, -1) :\n", + " print(i)" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [] + } + ], + "metadata": { + "kernelspec": { + "display_name": "Python 3.10.4 ('l1-python')", + "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.10.4" + }, + "orig_nbformat": 4, + "vscode": { + "interpreter": { + "hash": "c40ec1b8fe39daf00984f8ba30325fc08ad307055404f66b6babdfa1fdac6336" + } + } + }, + "nbformat": 4, + "nbformat_minor": 2 +} diff --git a/exercises/TD02_structures_controle/kholle.ipynb b/exercises/TD02_structures_controle/kholle.ipynb new file mode 100644 index 000000000..e69de29bb From 2e5649836563b1d6021e2e9a6ec68a0472f9960e Mon Sep 17 00:00:00 2001 From: Divya SELVARAJU Date: Wed, 16 Nov 2022 10:24:04 +0100 Subject: [PATCH 14/23] oui --- ...02_Structures_conditionnelles_slides.ipynb | 9 +- .../03_structures_iteratives.ipynb | 43 ++++++- cours/04_fonctions/04_fonctions.ipynb | 9 +- .../02_structures_controle.ipynb | 2 +- .../exercices kholle.ipynb | 111 +++++++++++++++++- exercises/TD04_listes/04_listes.ipynb | 89 +++++++++++--- 6 files changed, 234 insertions(+), 29 deletions(-) diff --git a/cours/02_structures_conditionnelles/02_Structures_conditionnelles_slides.ipynb b/cours/02_structures_conditionnelles/02_Structures_conditionnelles_slides.ipynb index 01f5ba421..7d67cbb28 100644 --- a/cours/02_structures_conditionnelles/02_Structures_conditionnelles_slides.ipynb +++ b/cours/02_structures_conditionnelles/02_Structures_conditionnelles_slides.ipynb @@ -1379,7 +1379,7 @@ "metadata": { "celltoolbar": "Diaporama", "kernelspec": { - "display_name": "Python 3", + "display_name": "Python 3.10.4 ('l1-python')", "language": "python", "name": "python3" }, @@ -1393,7 +1393,12 @@ "name": "python", "nbconvert_exporter": "python", "pygments_lexer": "ipython3", - "version": "3.7.6" + "version": "3.10.4" + }, + "vscode": { + "interpreter": { + "hash": "c40ec1b8fe39daf00984f8ba30325fc08ad307055404f66b6babdfa1fdac6336" + } } }, "nbformat": 4, diff --git a/cours/03_structures_iteratives/03_structures_iteratives.ipynb b/cours/03_structures_iteratives/03_structures_iteratives.ipynb index b9500d043..a6c08c41d 100644 --- a/cours/03_structures_iteratives/03_structures_iteratives.ipynb +++ b/cours/03_structures_iteratives/03_structures_iteratives.ipynb @@ -561,13 +561,30 @@ }, { "cell_type": "code", - "execution_count": null, + "execution_count": 2, "metadata": { "slideshow": { "slide_type": "fragment" } }, - "outputs": [], + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "i = 1\n", + "i = 2\n", + "i = 3\n", + "i = 4\n", + "i = 5\n", + "i = 6\n", + "i = 7\n", + "i = 8\n", + "i = 9\n", + "Terminé\n" + ] + } + ], "source": [ "i = 1\n", "while i < 10 : \n", @@ -819,13 +836,31 @@ }, { "cell_type": "code", - "execution_count": null, + "execution_count": 1, "metadata": { "slideshow": { "slide_type": "fragment" } }, - "outputs": [], + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "1 est impair\n", + "3 est impair\n", + "5 est impair\n", + "7 est impair\n", + "9 est impair\n", + "11 est impair\n", + "13 est impair\n", + "15 est impair\n", + "17 est impair\n", + "19 est impair\n", + "Terminé\n" + ] + } + ], "source": [ "for i in range(1, 21) :\n", " if i % 2 == 0 :\n", diff --git a/cours/04_fonctions/04_fonctions.ipynb b/cours/04_fonctions/04_fonctions.ipynb index 6edf1881c..43ea3c4fc 100644 --- a/cours/04_fonctions/04_fonctions.ipynb +++ b/cours/04_fonctions/04_fonctions.ipynb @@ -653,7 +653,7 @@ "metadata": { "celltoolbar": "Diaporama", "kernelspec": { - "display_name": "Python 3", + "display_name": "Python 3.10.4 ('l1-python')", "language": "python", "name": "python3" }, @@ -667,7 +667,12 @@ "name": "python", "nbconvert_exporter": "python", "pygments_lexer": "ipython3", - "version": "3.8.3" + "version": "3.10.4" + }, + "vscode": { + "interpreter": { + "hash": "c40ec1b8fe39daf00984f8ba30325fc08ad307055404f66b6babdfa1fdac6336" + } } }, "nbformat": 4, diff --git a/exercises/TD02_structures_controle/02_structures_controle.ipynb b/exercises/TD02_structures_controle/02_structures_controle.ipynb index e0490268e..71cf3fb62 100644 --- a/exercises/TD02_structures_controle/02_structures_controle.ipynb +++ b/exercises/TD02_structures_controle/02_structures_controle.ipynb @@ -259,7 +259,7 @@ }, { "cell_type": "code", - "execution_count": 7, + "execution_count": 1, "metadata": {}, "outputs": [ { diff --git a/exercises/TD02_structures_controle/exercices kholle.ipynb b/exercises/TD02_structures_controle/exercices kholle.ipynb index 8d0240266..7dc649617 100644 --- a/exercises/TD02_structures_controle/exercices kholle.ipynb +++ b/exercises/TD02_structures_controle/exercices kholle.ipynb @@ -2,10 +2,115 @@ "cells": [ { "cell_type": "code", - "execution_count": null, + "execution_count": 4, "metadata": {}, - "outputs": [], - "source": [] + "outputs": [ + { + "ename": "SyntaxError", + "evalue": "cannot assign to expression here. Maybe you meant '==' instead of '='? (870151810.py, line 3)", + "output_type": "error", + "traceback": [ + "\u001b[1;36m Input \u001b[1;32mIn [4]\u001b[1;36m\u001b[0m\n\u001b[1;33m if (i % 3) = 1:\u001b[0m\n\u001b[1;37m ^\u001b[0m\n\u001b[1;31mSyntaxError\u001b[0m\u001b[1;31m:\u001b[0m cannot assign to expression here. Maybe you meant '==' instead of '='?\n" + ] + } + ], + "source": [ + "\n" + ] + }, + { + "cell_type": "code", + "execution_count": 7, + "metadata": {}, + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "hello\n", + "hello\n" + ] + } + ], + "source": [ + "for i in range(5):\n", + " if (i % 3) == 1:\n", + " print(\"hello\")" + ] + }, + { + "cell_type": "code", + "execution_count": 8, + "metadata": {}, + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "False\n", + "True\n" + ] + } + ], + "source": [ + "a, b = 3, 2\n", + "\n", + "c, d = \"toto\", \"tata\"\n", + "\n", + "print(a > b and d > c)\n", + "\n", + "print(a != b or d == c)" + ] + }, + { + "cell_type": "code", + "execution_count": 2, + "metadata": {}, + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "5 4\n" + ] + } + ], + "source": [ + "i, j = 0, 9\n", + "\n", + "while i < j:\n", + "\n", + " i = i + 1\n", + "\n", + " j = j - 1\n", + "\n", + "print(i,j)" + ] + }, + { + "cell_type": "code", + "execution_count": 9, + "metadata": {}, + "outputs": [ + { + "ename": "SyntaxError", + "evalue": "'continue' not properly in loop (1477511495.py, line 6)", + "output_type": "error", + "traceback": [ + "\u001b[1;36m Input \u001b[1;32mIn [9]\u001b[1;36m\u001b[0m\n\u001b[1;33m continue\u001b[0m\n\u001b[1;37m ^\u001b[0m\n\u001b[1;31mSyntaxError\u001b[0m\u001b[1;31m:\u001b[0m 'continue' not properly in loop\n" + ] + } + ], + "source": [ + "a, b = 0, 1\n", + "\n", + "for i in range(0,5):\n", + " a += 1\n", + "if a % 3 != 0:\n", + " continue \n", + "b *= 2\n", + "print(a, b)" + ] }, { "cell_type": "code", diff --git a/exercises/TD04_listes/04_listes.ipynb b/exercises/TD04_listes/04_listes.ipynb index 5ef60e5fa..f074047df 100644 --- a/exercises/TD04_listes/04_listes.ipynb +++ b/exercises/TD04_listes/04_listes.ipynb @@ -22,10 +22,21 @@ }, { "cell_type": "code", - "execution_count": null, + "execution_count": 2, "metadata": {}, - "outputs": [], - "source": [] + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "[3, 5, 10]\n" + ] + } + ], + "source": [ + "liste = [3, 5, 10]\n", + "print(liste)" + ] }, { "cell_type": "markdown", @@ -36,10 +47,22 @@ }, { "cell_type": "code", - "execution_count": null, + "execution_count": 3, "metadata": {}, - "outputs": [], - "source": [] + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "[3, 5, 10, 12, 17]\n" + ] + } + ], + "source": [ + "liste.append(12)\n", + "liste.append(17)\n", + "print(liste)" + ] }, { "cell_type": "markdown", @@ -50,10 +73,21 @@ }, { "cell_type": "code", - "execution_count": null, + "execution_count": 5, "metadata": {}, - "outputs": [], - "source": [] + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "[3, 5, -7, 12, 17]\n" + ] + } + ], + "source": [ + "liste[2] = -7\n", + "print(liste)" + ] }, { "cell_type": "markdown", @@ -64,10 +98,23 @@ }, { "cell_type": "code", - "execution_count": null, - "metadata": {}, - "outputs": [], - "source": [] + "execution_count": 9, + "metadata": {}, + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "[6, 10, -14, 24, 34]\n" + ] + } + ], + "source": [ + "for i in range(5) :\n", + " liste[i] = liste[i] * 2\n", + "\n", + "print(liste)" + ] }, { "cell_type": "markdown", @@ -78,10 +125,13 @@ }, { "cell_type": "code", - "execution_count": null, + "execution_count": 10, "metadata": {}, "outputs": [], - "source": [] + "source": [ + "for i in range(5):\n", + " liste[i] = liste[i] * \n" + ] }, { "cell_type": "markdown", @@ -433,7 +483,7 @@ ], "metadata": { "kernelspec": { - "display_name": "Python 3", + "display_name": "Python 3.10.4 ('l1-python')", "language": "python", "name": "python3" }, @@ -447,7 +497,12 @@ "name": "python", "nbconvert_exporter": "python", "pygments_lexer": "ipython3", - "version": "3.7.6" + "version": "3.10.4" + }, + "vscode": { + "interpreter": { + "hash": "c40ec1b8fe39daf00984f8ba30325fc08ad307055404f66b6babdfa1fdac6336" + } } }, "nbformat": 4, From cf13442ab54d061c581614fe745ded1de454ad3a Mon Sep 17 00:00:00 2001 From: Divya SELVARAJU Date: Wed, 16 Nov 2022 11:06:17 +0100 Subject: [PATCH 15/23] oui --- exercises/TD04_listes/04_listes.ipynb | 112 ++++++++++++++++++++++---- 1 file changed, 96 insertions(+), 16 deletions(-) diff --git a/exercises/TD04_listes/04_listes.ipynb b/exercises/TD04_listes/04_listes.ipynb index f074047df..6febf5d90 100644 --- a/exercises/TD04_listes/04_listes.ipynb +++ b/exercises/TD04_listes/04_listes.ipynb @@ -125,12 +125,22 @@ }, { "cell_type": "code", - "execution_count": 10, + "execution_count": 11, "metadata": {}, - "outputs": [], + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "[24, 41, -54, 99, 140]\n" + ] + } + ], "source": [ "for i in range(5):\n", - " liste[i] = liste[i] * \n" + " liste[i] = liste[i] + i\n", + "\n", + "print(liste)\n" ] }, { @@ -142,10 +152,31 @@ }, { "cell_type": "code", - "execution_count": null, + "execution_count": 14, "metadata": {}, - "outputs": [], - "source": [] + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "[81, 56, 54, 16, 72, 83, 87, 27, 81, 90]\n", + "somme : 647\n", + "le plus grand : 90\n" + ] + } + ], + "source": [ + "import random\n", + "tirage = []\n", + "for i in range(10):\n", + " tirage.append(random.randint(10, 99))\n", + "\n", + "#ou : tirage = [random.randint(10, 99) for i in range (10)]\n", + "\n", + "print(tirage)\n", + "print(\"somme :\" , sum(tirage))\n", + "print(\"le plus grand :\" , max(tirage))" + ] }, { "cell_type": "markdown", @@ -156,10 +187,33 @@ }, { "cell_type": "code", - "execution_count": null, + "execution_count": 16, "metadata": {}, - "outputs": [], - "source": [] + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "pairs : [56, 54, 16, 72, 90]\n", + "imapirs : [81, 83, 87, 27, 81]\n" + ] + } + ], + "source": [ + "pairs = []\n", + "impairs = []\n", + "\n", + "for n in tirage:\n", + " if n % 2 == 0:\n", + " pairs.append(n)\n", + " else:\n", + " impairs.append(n)\n", + "\n", + "# ou : pairs = [n for n in tirage if n % 2 == 0]\n", + "# imapairs = [n for n in tirage if n % 2 == 1]\n", + "print(\"pairs :\" , pairs)\n", + "print(\"imapirs :\" , impairs)\n" + ] }, { "cell_type": "markdown", @@ -170,10 +224,21 @@ }, { "cell_type": "code", - "execution_count": null, + "execution_count": 20, "metadata": {}, - "outputs": [], - "source": [] + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "[54, 56, 72, 81, 81, 83]\n" + ] + } + ], + "source": [ + "tirage.sort()\n", + "print(tirage)" + ] }, { "cell_type": "markdown", @@ -184,10 +249,23 @@ }, { "cell_type": "code", - "execution_count": null, + "execution_count": 21, "metadata": {}, - "outputs": [], - "source": [] + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "[56, 72, 81, 81]\n" + ] + } + ], + "source": [ + "del tirage[0]\n", + "del tirage[-1]\n", + "\n", + "print(tirage)" + ] }, { "cell_type": "markdown", @@ -201,7 +279,9 @@ "execution_count": null, "metadata": {}, "outputs": [], - "source": [] + "source": [ + "liste()" + ] }, { "cell_type": "markdown", From ad8eb833253cae9b7ea05eb3bab5c5d474d7b619 Mon Sep 17 00:00:00 2001 From: Divya SELVARAJU Date: Wed, 16 Nov 2022 11:31:09 +0100 Subject: [PATCH 16/23] oui --- exercises/TD04_listes/04_listes.ipynb | 37 ++++++++++++++++++++++----- 1 file changed, 31 insertions(+), 6 deletions(-) diff --git a/exercises/TD04_listes/04_listes.ipynb b/exercises/TD04_listes/04_listes.ipynb index 6febf5d90..0aa7d34bb 100644 --- a/exercises/TD04_listes/04_listes.ipynb +++ b/exercises/TD04_listes/04_listes.ipynb @@ -276,11 +276,21 @@ }, { "cell_type": "code", - "execution_count": null, + "execution_count": 28, "metadata": {}, - "outputs": [], + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "[1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40, 41, 42, 43, 44, 45, 46, 47, 48, 49, 50, 51, 52]\n" + ] + } + ], "source": [ - "liste()" + "paquet = list(range(1, 53))\n", + "\n", + "print(paquet)" ] }, { @@ -292,10 +302,25 @@ }, { "cell_type": "code", - "execution_count": null, + "execution_count": 29, "metadata": {}, - "outputs": [], - "source": [] + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "[44, 45, 46, 47, 48, 49, 50, 51, 52, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40, 41, 42, 43]\n" + ] + } + ], + "source": [ + "i = random.randint(0, 51)\n", + "debut = paquet[:i]\n", + "fin = paquet[i:]\n", + "\n", + "paquet = fin + debut\n", + "print(paquet)" + ] }, { "cell_type": "markdown", From c2b47bdddd07676ee981be506405a368e95f0553 Mon Sep 17 00:00:00 2001 From: Divya SELVARAJU Date: Tue, 14 Feb 2023 11:33:55 +0100 Subject: [PATCH 17/23] Test1_P4 --- h | 0 1 file changed, 0 insertions(+), 0 deletions(-) create mode 100644 h diff --git a/h b/h new file mode 100644 index 000000000..e69de29bb From 1cce2e558f9ce0b0b0a4163977bb2fe2304dfdac Mon Sep 17 00:00:00 2001 From: Divya SELVARAJU Date: Tue, 14 Feb 2023 11:36:10 +0100 Subject: [PATCH 18/23] test2 --- ProjetP4/test.y | 0 1 file changed, 0 insertions(+), 0 deletions(-) create mode 100644 ProjetP4/test.y diff --git a/ProjetP4/test.y b/ProjetP4/test.y new file mode 100644 index 000000000..e69de29bb From b926eea890660b8a408a22c0fdd45c75fffe4550 Mon Sep 17 00:00:00 2001 From: Divya SELVARAJU Date: Tue, 14 Feb 2023 11:37:57 +0100 Subject: [PATCH 19/23] oui --- ProjetP4/puissance_4.py | 0 1 file changed, 0 insertions(+), 0 deletions(-) create mode 100644 ProjetP4/puissance_4.py diff --git a/ProjetP4/puissance_4.py b/ProjetP4/puissance_4.py new file mode 100644 index 000000000..e69de29bb From 9e29d1c858c0050277d98303e1e41455fdd9d644 Mon Sep 17 00:00:00 2001 From: Divya SELVARAJU Date: Tue, 14 Feb 2023 11:46:33 +0100 Subject: [PATCH 20/23] oui --- ProjetP4/puissance_4.py | 1 + 1 file changed, 1 insertion(+) diff --git a/ProjetP4/puissance_4.py b/ProjetP4/puissance_4.py index e69de29bb..85b66be34 100644 --- a/ProjetP4/puissance_4.py +++ b/ProjetP4/puissance_4.py @@ -0,0 +1 @@ +hfg \ No newline at end of file From 86e59a97716473af7569285d8fd6b7615df3c565 Mon Sep 17 00:00:00 2001 From: Divya SELVARAJU Date: Tue, 14 Feb 2023 11:46:45 +0100 Subject: [PATCH 21/23] oui --- ProjetP4/puissance_4.py | 1 - 1 file changed, 1 deletion(-) diff --git a/ProjetP4/puissance_4.py b/ProjetP4/puissance_4.py index 85b66be34..e69de29bb 100644 --- a/ProjetP4/puissance_4.py +++ b/ProjetP4/puissance_4.py @@ -1 +0,0 @@ -hfg \ No newline at end of file From a0354c622cc98bdc9606ffb687400a79c22dd010 Mon Sep 17 00:00:00 2001 From: Divya SELVARAJU Date: Tue, 14 Feb 2023 12:07:51 +0100 Subject: [PATCH 22/23] test2 --- ProjetP4/puissance_4.py | 1 + 1 file changed, 1 insertion(+) diff --git a/ProjetP4/puissance_4.py b/ProjetP4/puissance_4.py index e69de29bb..141b9c5ba 100644 --- a/ProjetP4/puissance_4.py +++ b/ProjetP4/puissance_4.py @@ -0,0 +1 @@ +fqqsdvqshd \ No newline at end of file From ff0aab3d37cc962015f084208f90fb9cac9deb3b Mon Sep 17 00:00:00 2001 From: Divya SELVARAJU Date: Tue, 21 Feb 2023 09:55:21 +0100 Subject: [PATCH 23/23] oui --- ProjetP4/TD_1.py | 0 1 file changed, 0 insertions(+), 0 deletions(-) create mode 100644 ProjetP4/TD_1.py diff --git a/ProjetP4/TD_1.py b/ProjetP4/TD_1.py new file mode 100644 index 000000000..e69de29bb