2022-2023/1NSI/Evaluations/DS_2023-02-27/DS3.ipynb

315 lines
6.5 KiB
Plaintext
Raw Normal View History

2023-02-27 08:49:43 +00:00
{
"cells": [
{
"cell_type": "markdown",
"id": "2e00e1dc",
"metadata": {},
"source": [
"# Evaluation NSI DS3\n",
"\n",
"## Exercices techniques\n",
"\n",
"Pour répondre aux questions suivantes vous avez le droit d'utiliser les outils de programmation que vous voulez.\n",
"\n",
"1. Ajouter les éléments 1 et \"a\" à la fin de la liste suivante"
]
},
{
"cell_type": "code",
"execution_count": null,
"id": "40c5d194",
"metadata": {},
"outputs": [],
"source": [
"une_liste = [2, 3, 'b']"
]
},
{
"cell_type": "code",
"execution_count": null,
"id": "8facf11e",
"metadata": {},
"outputs": [],
"source": []
},
{
"cell_type": "markdown",
"id": "122680c3",
"metadata": {},
"source": [
"2. Calculer le carré des nombres de la liste suivante"
]
},
{
"cell_type": "code",
"execution_count": null,
"id": "e2395fdc",
"metadata": {},
"outputs": [],
"source": [
"nombres = [10, 2, 4, 5, 2, 10, 7, 1, 6, 10, 8, 0, 0, 7, 7, 7, 9, 1, 9, 8, 10, 5, 5, 9, 7]"
]
},
{
"cell_type": "code",
"execution_count": null,
"id": "37124b5d",
"metadata": {},
"outputs": [],
"source": []
},
{
"cell_type": "markdown",
"id": "37154424",
"metadata": {},
"source": [
"3. On peut voir le caractère 128514 avec la fonction `chr`."
]
},
{
"cell_type": "code",
"execution_count": null,
"id": "ba8c5bbf",
"metadata": {},
"outputs": [],
"source": [
"chr(128514)"
]
},
{
"cell_type": "markdown",
"id": "518d856e",
"metadata": {},
"source": [
"Faire une tableau affichant les 60 caractères après le caractère 128514. Ce tableau aura 10 colonnes et 6 lignes"
]
},
{
"cell_type": "code",
"execution_count": null,
"id": "64e56429",
"metadata": {},
"outputs": [],
"source": []
},
{
"cell_type": "markdown",
"id": "a498c55f",
"metadata": {},
"source": [
"## Fonctions\n",
"\n",
"Dans les exercices suivants, vous devrez ajouter au moins deux tests et vous programmerez les fontions en prenant soin de les documenter."
]
},
{
"cell_type": "markdown",
"id": "6789674a",
"metadata": {},
"source": [
"### Moyenne\n",
"\n",
"Programmer une fonction, `moyenne` qui prend en argument une liste de nombres et qui renvoie la moyenne des valeurs"
]
},
{
"cell_type": "code",
"execution_count": null,
"id": "ad580877",
"metadata": {},
"outputs": [],
"source": [
"# Tests\n",
"assert moyenne([1, 2, 3, 4]) == 2.5"
]
},
{
"cell_type": "code",
"execution_count": null,
"id": "a4bbf728",
"metadata": {},
"outputs": [],
"source": [
"# Fonction"
]
},
{
"cell_type": "code",
"execution_count": null,
"id": "41aa5e85",
"metadata": {},
"outputs": [],
"source": []
},
{
"cell_type": "markdown",
"id": "614971b4",
"metadata": {},
"source": [
"### Doublons\n",
"\n",
"Programmer une fonction, `supprime_doublons` qui prend en argument une liste et qui renvoie la même liste mais où les doublons ont été enlevés (on gardera une seul élément)."
]
},
{
"cell_type": "code",
"execution_count": null,
"id": "d3748328",
"metadata": {},
"outputs": [],
"source": [
"# Tests\n",
"assert supprime_doublons([\"a\", 1, 3, \"a\", 5, 3]) == [\"a\", 1, 3, 5]"
]
},
{
"cell_type": "code",
"execution_count": null,
"id": "9f217ea5",
"metadata": {},
"outputs": [],
"source": [
"# Fonction"
]
},
{
"cell_type": "code",
"execution_count": null,
"id": "f9fa1ea8",
"metadata": {},
"outputs": [],
"source": []
},
{
"cell_type": "markdown",
"id": "bbc18709",
"metadata": {},
"source": [
"### Minimum\n",
"\n",
"Programmer une fonction, `minimum`, qui prend en argument une liste de nombre et qui renvoie le minimum de la liste (vous n'avez pas le droit d'utiliser la fonction `min`)."
]
},
{
"cell_type": "code",
"execution_count": null,
"id": "4d37d9d3",
"metadata": {},
"outputs": [],
"source": [
"# Tests\n",
"assert minimum([3, 6, 1, 9]) == 1"
]
},
{
"cell_type": "code",
"execution_count": null,
"id": "6cac9a01",
"metadata": {},
"outputs": [],
"source": [
"# Fonction"
]
},
{
"cell_type": "code",
"execution_count": null,
"id": "36245916",
"metadata": {},
"outputs": [],
"source": []
},
{
"cell_type": "markdown",
"id": "54c9099e",
"metadata": {},
"source": [
"### Compte le nombre de 'e'\n",
"\n",
"Programme une fonction, `compte_e` qui prend en argument une chaine de caractères et qui renvoie le nombre de fois que la lettre `e` apparait dedans (vous n'avez pas le droit d'utiliser la méthode `.count(...)`.)"
]
},
{
"cell_type": "code",
"execution_count": null,
"id": "7566970a",
"metadata": {},
"outputs": [],
"source": [
"# Tests\n",
"assert compte_e(\"bonjour je m'appelle bob!\") == 3"
]
},
{
"cell_type": "code",
"execution_count": null,
"id": "20c9a48c",
"metadata": {},
"outputs": [],
"source": [
"# Fonction"
]
},
{
"cell_type": "markdown",
"id": "a0c1f069",
"metadata": {},
"source": [
"### Enlève caractère\n",
"\n",
"Programmer une fonction, `enleve`, qui prend en arguement un caractère et une chaine de caractères et qui renvoie la chaine de caractères sans le caractère. (Vous n'anez pas le droit d'utiliser la méthode `.remplace(...)`)"
]
},
{
"cell_type": "code",
"execution_count": null,
"id": "ec8675c6",
"metadata": {},
"outputs": [],
"source": [
"# Tests\n",
"assert enleve(\"e\", \"bonjour je m'appelle bob!\") == \"bonjour j m'appll bob!\""
]
},
{
"cell_type": "code",
"execution_count": null,
"id": "f9570da4",
"metadata": {},
"outputs": [],
"source": [
"# Fonction"
]
},
{
"cell_type": "code",
"execution_count": null,
"id": "c6165ae8",
"metadata": {},
"outputs": [],
"source": []
}
],
"metadata": {
"kernelspec": {
"display_name": "Python 3 (ipykernel)",
"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.9"
}
},
"nbformat": 4,
"nbformat_minor": 5
}