Feat: ajout d'exercices sur le motifs

This commit is contained in:
Bertrand Benjamin 2022-03-07 08:31:25 +01:00
parent 805bc7aa62
commit 52ebba2e39

View File

@ -116,6 +116,165 @@
"outputs": [],
"source": []
},
{
"cell_type": "markdown",
"id": "331a2cbc",
"metadata": {},
"source": [
"## 2- Dessins ASCII\n",
"\n",
"Le but de cette partie est de réaliser des dessins avec des chaines de caractères.\n",
"\n",
"Quand on multiplie une chaine de caractères (par exemple \"#\") par un entier (par exemple 4), python va répéter la chaine de caractères.\n",
"\n",
"Quelques exemples:"
]
},
{
"cell_type": "code",
"execution_count": null,
"id": "f853763e",
"metadata": {},
"outputs": [],
"source": [
"print(\"#\"*4)\n",
"print(\"-\"*10)\n",
"print(\"_\"*3, \" \"*2, \"-\"*5)"
]
},
{
"cell_type": "markdown",
"id": "39c31073",
"metadata": {},
"source": [
"On peut utiliser des boucles pour faire ensuite des motifs"
]
},
{
"cell_type": "code",
"execution_count": null,
"id": "f27d70f7",
"metadata": {},
"outputs": [],
"source": [
"for i in range(5):\n",
" print(\"-\", \"#\"*i)"
]
},
{
"cell_type": "markdown",
"id": "1cb955ec",
"metadata": {},
"source": [
"1. Réaliser le motif suivant:\n",
"\n",
"\n",
" -\n",
" --\n",
" ---\n",
" ----\n",
" -----\n",
" ------\n",
" -------\n",
" --------\n",
" --------- "
]
},
{
"cell_type": "code",
"execution_count": null,
"id": "9722d016",
"metadata": {},
"outputs": [],
"source": []
},
{
"cell_type": "markdown",
"id": "f5b643e3",
"metadata": {},
"source": [
"2. Réaliser le motif suivant\n",
"\n",
" \n",
" ##\n",
" ####\n",
" ######\n",
" ########"
]
},
{
"cell_type": "code",
"execution_count": null,
"id": "500f4704",
"metadata": {},
"outputs": [],
"source": []
},
{
"cell_type": "markdown",
"id": "e3effd90",
"metadata": {},
"source": [
"3. Réaliser le motif suivant\n",
"\n",
" ######\n",
" #####\n",
" ####\n",
" ###\n",
" ##\n",
" #"
]
},
{
"cell_type": "code",
"execution_count": null,
"id": "95855d5a",
"metadata": {},
"outputs": [],
"source": []
},
{
"cell_type": "markdown",
"id": "7a8f1d02",
"metadata": {},
"source": [
"4. Réaliser le motif suivant\n",
"\n",
"\n",
" #\n",
" ##\n",
" ###\n",
" ####\n",
" #####\n",
" ######\n",
" #####\n",
" ####\n",
" ###\n",
" ##\n",
" #"
]
},
{
"cell_type": "markdown",
"id": "2593c488",
"metadata": {},
"source": [
"5. Réaliser le motif suivant\n",
"\n",
" # \n",
" ### \n",
" ##### \n",
" ####### "
]
},
{
"cell_type": "code",
"execution_count": null,
"id": "dee48acd",
"metadata": {},
"outputs": [],
"source": []
},
{
"cell_type": "markdown",
"id": "9880d494",