Skip to content

Commit 54d480d

Browse files
committed
CoursYoutube
1 parent 69c4dcb commit 54d480d

8 files changed

+2048
-0
lines changed
Lines changed: 135 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,135 @@
1+
{
2+
"cells": [
3+
{
4+
"cell_type": "markdown",
5+
"id": "fb22bc11",
6+
"metadata": {},
7+
"source": [
8+
"# Démarrer la formation\n",
9+
"Bienvenue dans ce cours d'initiation à Python."
10+
]
11+
},
12+
{
13+
"cell_type": "markdown",
14+
"id": "4c3f6dfe",
15+
"metadata": {},
16+
"source": [
17+
"## Objectifs pédagogiques\n",
18+
"- Comprendre ce qu'est Python et ses cas d'usage\n",
19+
"- Installer un environnement Python avec Anaconda\n",
20+
"- Lancer et tester ses premiers scripts dans Jupyter Notebook"
21+
]
22+
},
23+
{
24+
"cell_type": "markdown",
25+
"id": "bfe1a59a",
26+
"metadata": {},
27+
"source": [
28+
"## Pourquoi apprendre Python ?\n",
29+
"Python est un langage polyvalent, lisible, utilisé dans :\n",
30+
"- la **data science** (NumPy, Pandas, scikit-learn)\n",
31+
"- le **web** (Django, Flask)\n",
32+
"- l’**IA** (TensorFlow, PyTorch)\n",
33+
"- l’**automatisation** (scripts, bots)\n",
34+
"- les **jeux**, l’**IoT**, la **cybersécurité** et plus encore."
35+
]
36+
},
37+
{
38+
"cell_type": "markdown",
39+
"id": "7f1348e0",
40+
"metadata": {},
41+
"source": [
42+
"## Installation de Python avec Anaconda\n",
43+
"1. Rendez-vous sur [anaconda.com](https://www.anaconda.com/products/distribution)\n",
44+
"2. Téléchargez la version pour votre système (Windows, macOS, Linux)\n",
45+
"3. Installez en suivant les instructions par défaut\n",
46+
"\n",
47+
"Une fois installé :\n",
48+
"- Lancez **Anaconda Navigator** ou ouvrez un terminal et tapez `jupyter notebook`\n"
49+
]
50+
},
51+
{
52+
"cell_type": "markdown",
53+
"id": "f32f89ce",
54+
"metadata": {},
55+
"source": [
56+
"## Premiers pas avec Jupyter Notebook\n",
57+
"Dans une cellule de type Code, tapez ceci puis exécutez-la avec **Shift + Entrée** :"
58+
]
59+
},
60+
{
61+
"cell_type": "code",
62+
"execution_count": null,
63+
"id": "e214bcea",
64+
"metadata": {},
65+
"outputs": [],
66+
"source": [
67+
"print(\"Bienvenue dans Python !\")"
68+
]
69+
},
70+
{
71+
"cell_type": "markdown",
72+
"id": "1d1daef5",
73+
"metadata": {},
74+
"source": [
75+
"## Exercice : écrire un message personnalisé\n",
76+
"Demandez à l’utilisateur son prénom, puis affichez un message personnalisé."
77+
]
78+
},
79+
{
80+
"cell_type": "code",
81+
"execution_count": null,
82+
"id": "4e072407",
83+
"metadata": {},
84+
"outputs": [],
85+
"source": [
86+
"prenom = input(\"Quel est ton prénom ? \")\n",
87+
"print(f\"Heureux de te rencontrer, {prenom} !\")"
88+
]
89+
},
90+
{
91+
"cell_type": "markdown",
92+
"id": "29f2a146",
93+
"metadata": {},
94+
"source": [
95+
"## Quiz : Python & installation\n",
96+
"**1. Quel outil permet de lancer Jupyter Notebook ?**\n",
97+
"- a) Chrome\n",
98+
"- b) Anaconda \n",
99+
"- c) VSCode\n",
100+
"- d) Git\n",
101+
"\n",
102+
"**2. Que fait la commande `print(\"Hello\")` ?**\n",
103+
"- a) Elle stocke une variable\n",
104+
"- b) Elle affiche un message \n",
105+
"- c) Elle importe un module\n",
106+
"- d) Elle crée un fichier\n",
107+
"\n",
108+
"**3. Quelle extension ont les fichiers Jupyter ?**\n",
109+
"- a) `.py`\n",
110+
"- b) `.txt`\n",
111+
"- c) `.ipynb` \n",
112+
"- d) `.csv`\n",
113+
"\n",
114+
"**4. Quel est l'avantage principal de Python ?**\n",
115+
"- a) C'est un langage peu utilisé\n",
116+
"- b) Il est complexe mais rapide\n",
117+
"- c) Il est facile à lire \n",
118+
"- d) Il remplace Excel\n",
119+
"\n",
120+
"**5. Que signifie `input()` ?**\n",
121+
"- a) Lancer un programme\n",
122+
"- b) Afficher une variable\n",
123+
"- c) Demander une saisie utilisateur \n",
124+
"- d) Lire un fichier"
125+
]
126+
}
127+
],
128+
"metadata": {
129+
"language_info": {
130+
"name": "python"
131+
}
132+
},
133+
"nbformat": 4,
134+
"nbformat_minor": 5
135+
}
Lines changed: 263 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,263 @@
1+
{
2+
"cells": [
3+
{
4+
"cell_type": "markdown",
5+
"id": "92e9f569",
6+
"metadata": {},
7+
"source": [
8+
"# Chapitre 2 – Premiers scripts et variables"
9+
]
10+
},
11+
{
12+
"cell_type": "markdown",
13+
"id": "2b6ceda8",
14+
"metadata": {},
15+
"source": [
16+
"Dans ce chapitre, vous allez apprendre les bases de la programmation avec Python :\n",
17+
"- les types de données fondamentaux\n",
18+
"- la création et conversion de variables\n",
19+
"- les opérations arithmétiques simples\n",
20+
"- la manipulation de texte (concaténation et f-strings)\n",
21+
"- un exercice pratique : mini-calculatrice\n",
22+
"- un quiz de validation des acquis"
23+
]
24+
},
25+
{
26+
"cell_type": "markdown",
27+
"id": "a09d78fa",
28+
"metadata": {},
29+
"source": [
30+
"## Comprendre les types de données de base"
31+
]
32+
},
33+
{
34+
"cell_type": "markdown",
35+
"id": "43f5c9f8",
36+
"metadata": {},
37+
"source": [
38+
"Python propose plusieurs types standards :\n",
39+
"- `int` : nombres entiers (ex. `10`)\n",
40+
"- `float` : nombres décimaux (ex. `3.14`)\n",
41+
"- `str` : chaînes de caractères (ex. `'bonjour'`)\n",
42+
"- `bool` : booléens (`True`, `False`)"
43+
]
44+
},
45+
{
46+
"cell_type": "code",
47+
"execution_count": null,
48+
"id": "bb61bf30",
49+
"metadata": {},
50+
"outputs": [],
51+
"source": [
52+
"a = 10\n",
53+
"b = 3.5\n",
54+
"c = 'Bonjour'\n",
55+
"d = True\n",
56+
"print(type(a), type(b), type(c), type(d))"
57+
]
58+
},
59+
{
60+
"cell_type": "markdown",
61+
"id": "f59131ef",
62+
"metadata": {},
63+
"source": [
64+
"## Créer et convertir des variables"
65+
]
66+
},
67+
{
68+
"cell_type": "code",
69+
"execution_count": null,
70+
"id": "9561a401",
71+
"metadata": {},
72+
"outputs": [],
73+
"source": [
74+
"x = 7.9\n",
75+
"print(x)\n",
76+
"\n",
77+
"# Conversion float -> int\n",
78+
"y = int(x)\n",
79+
"print(y)\n",
80+
"\n",
81+
"# Conversion int -> string\n",
82+
"z = str(y)\n",
83+
"print(z, type(z))"
84+
]
85+
},
86+
{
87+
"cell_type": "markdown",
88+
"id": "5049d035",
89+
"metadata": {},
90+
"source": [
91+
"## Effectuer des opérations arithmétiques simples"
92+
]
93+
},
94+
{
95+
"cell_type": "code",
96+
"execution_count": null,
97+
"id": "99cc5e49",
98+
"metadata": {},
99+
"outputs": [],
100+
"source": [
101+
"a = 15\n",
102+
"b = 4\n",
103+
"print(\"Addition:\", a + b)\n",
104+
"print(\"Soustraction:\", a - b)\n",
105+
"print(\"Multiplication:\", a * b)\n",
106+
"print(\"Division:\", a / b)\n",
107+
"print(\"Puissance:\", a ** b)\n",
108+
"print(\"Modulo:\", a % b)"
109+
]
110+
},
111+
{
112+
"cell_type": "markdown",
113+
"id": "683e417f",
114+
"metadata": {},
115+
"source": [
116+
"## Formater et concaténer des chaînes de caractères"
117+
]
118+
},
119+
{
120+
"cell_type": "markdown",
121+
"id": "bf3ad448",
122+
"metadata": {},
123+
"source": [
124+
"### Méthode 1 : Concaténation avec `+`"
125+
]
126+
},
127+
{
128+
"cell_type": "code",
129+
"execution_count": null,
130+
"id": "877b2587",
131+
"metadata": {},
132+
"outputs": [],
133+
"source": [
134+
"prenom = \"Alice\"\n",
135+
"age = 28\n",
136+
"message = \"Bonjour, je m'appelle \" + prenom + \" et j'ai \" + str(age) + \" ans.\"\n",
137+
"print(message)"
138+
]
139+
},
140+
{
141+
"cell_type": "markdown",
142+
"id": "d9bd5dba",
143+
"metadata": {},
144+
"source": [
145+
"### Méthode 2 : Utiliser les f-strings (recommandé)"
146+
]
147+
},
148+
{
149+
"cell_type": "code",
150+
"execution_count": null,
151+
"id": "d315ddb5",
152+
"metadata": {},
153+
"outputs": [],
154+
"source": [
155+
"prenom = \"Alice\"\n",
156+
"age = 28\n",
157+
"print(f\"Bonjour, je m'appelle {prenom} et j'ai {age} ans.\")"
158+
]
159+
},
160+
{
161+
"cell_type": "markdown",
162+
"id": "ea117b52",
163+
"metadata": {},
164+
"source": [
165+
"### Formater les nombres avec les f-strings"
166+
]
167+
},
168+
{
169+
"cell_type": "code",
170+
"execution_count": null,
171+
"id": "f4ab4d7f",
172+
"metadata": {},
173+
"outputs": [],
174+
"source": [
175+
"prix = 12.3456\n",
176+
"print(f\"Prix : {prix:.2f} euros\") # 2 chiffres après la virgule\n",
177+
"print(f\"Prix arrondi : {round(prix)} euros\")"
178+
]
179+
},
180+
{
181+
"cell_type": "markdown",
182+
"id": "431fb431",
183+
"metadata": {},
184+
"source": [
185+
"## Exercice : Créer une mini-calculatrice simple"
186+
]
187+
},
188+
{
189+
"cell_type": "code",
190+
"execution_count": null,
191+
"id": "3edb155f",
192+
"metadata": {},
193+
"outputs": [],
194+
"source": [
195+
"nb1 = float(input(\"Entrez un premier nombre : \"))\n",
196+
"nb2 = float(input(\"Entrez un deuxième nombre : \"))\n",
197+
"\n",
198+
"somme = nb1 + nb2\n",
199+
"produit = nb1 * nb2\n",
200+
"division = nb1 / nb2\n",
201+
"\n",
202+
"print(f\"La somme est : {somme:.2f}\")\n",
203+
"print(f\"Le produit est : {produit:.2f}\")\n",
204+
"print(f\"La division est : {division:.2f}\")"
205+
]
206+
},
207+
{
208+
"cell_type": "markdown",
209+
"id": "54a385ac",
210+
"metadata": {},
211+
"source": [
212+
"## Quiz : Vérifier les acquis sur les variables"
213+
]
214+
},
215+
{
216+
"cell_type": "markdown",
217+
"id": "ec0874d3",
218+
"metadata": {},
219+
"source": [
220+
"**1. Quel type correspond à `True` ?**\n",
221+
"- a) int\n",
222+
"- b) str\n",
223+
"- c) bool \n",
224+
"- d) float\n",
225+
"\n",
226+
"**2. Quel opérateur donne le reste d’une division ?**\n",
227+
"- a) `//`\n",
228+
"- b) `/`\n",
229+
"- c) `%` \n",
230+
"- d) `**`\n",
231+
"\n",
232+
"**3. Quelle fonction permet de convertir un texte en entier ?**\n",
233+
"- a) `float()`\n",
234+
"- b) `int()` \n",
235+
"- c) `str()`\n",
236+
"- d) `bool()`\n",
237+
"\n",
238+
"**4. Quelle syntaxe est correcte avec un f-string ?**\n",
239+
"- a) `'Bonjour ' + {nom}`\n",
240+
"- b) `\"Bonjour {nom}\"`\n",
241+
"- c) `f\"Bonjour {nom}\"` \n",
242+
"- d) `\"Bonjour\" + nom {}`"
243+
]
244+
},
245+
{
246+
"cell_type": "markdown",
247+
"id": "be849a84",
248+
"metadata": {},
249+
"source": [
250+
"## Pour aller plus loin\n",
251+
"Retrouvez la version vidéo de ce chapitre sur la chaîne YouTube Le Coin Stat :\n",
252+
"https://www.youtube.com/@LeCoinStat"
253+
]
254+
}
255+
],
256+
"metadata": {
257+
"language_info": {
258+
"name": "python"
259+
}
260+
},
261+
"nbformat": 4,
262+
"nbformat_minor": 5
263+
}

0 commit comments

Comments
 (0)