From 1ef33f36af96e5b8963030995479e02ce9150236 Mon Sep 17 00:00:00 2001
From: Andy Palmer <25123779+ninezerozeronine@users.noreply.github.com>
Date: Sun, 9 Jun 2019 12:36:37 -0700
Subject: [PATCH 1/2] Fix list formatting
---
slides-en.html | 16 ++++++++--------
slides-fr.html | 14 +++++++-------
2 files changed, 15 insertions(+), 15 deletions(-)
diff --git a/slides-en.html b/slides-en.html
index affe01c..1f0c222 100644
--- a/slides-en.html
+++ b/slides-en.html
@@ -849,19 +849,19 @@
with Instructor name
To create a list, type a name for the list, then `=`, then put the items in square brackets.
```python
- the_name_of_the_list = ['items', 'separated', 'by','commas']
+ the_name_of_the_list = ['items', 'separated', 'by', 'commas']
```
#### Examples:
```python
- weather_conditions = ['rainy', 'snowing', 'cloudy','sunny','foggy']
+ weather_conditions = ['rainy', 'snowing', 'cloudy', 'sunny', 'foggy']
- provinces = ['BC', 'AB', 'SK','MB','ON','QC','NL,','NB','NS','PE','YT','NT','NU']
+ provinces = ['BC', 'AB', 'SK', 'MB', 'ON', 'QC', 'NL', 'NB', 'NS', 'PE', 'YT', 'NT', 'NU']
- to_do_list = ['Water plants','Clean bathroom','Buy shoes','Become Prime Minister', 'Solve climate change']
+ to_do_list = ['Water plants', 'Clean bathroom', 'Buy shoes', 'Become Prime Minister', 'Solve climate change']
- prime_numbers = [2,3,5,7,11,13]
+ prime_numbers = [2, 3, 5, 7, 11, 13]
```
Just like with variables we want to give our lists good, descriptive names.
@@ -877,7 +877,7 @@ with Instructor name
They are **indexed** (counted) starting at 0.
```python
- weather_conditions = ['rainy', 'snowing', 'cloudy','sunny','foggy']
+ weather_conditions = ['rainy', 'snowing', 'cloudy', 'sunny', 'foggy']
```
Try these in the python console:
@@ -930,7 +930,7 @@ with Instructor name
Suppose we have a list of types of weather.
```python
- weather_conditions = ['rainy', 'snowing', 'cloudy','sunny','foggy']
+ weather_conditions = ['rainy', 'snowing', 'cloudy', 'sunny', 'foggy']
```
What kinds of things could we want to do with this data?
@@ -1000,7 +1000,7 @@ with Instructor name
### Example
```python
- weather_conditions = ['rainy', 'snowing', 'cloudy','sunny','foggy']
+ weather_conditions = ['rainy', 'snowing', 'cloudy', 'sunny', 'foggy']
for type_of_weather in weather_conditions:
print(type_of_weather)
```
diff --git a/slides-fr.html b/slides-fr.html
index 01dcdab..eb5957c 100755
--- a/slides-fr.html
+++ b/slides-fr.html
@@ -843,13 +843,13 @@ avec Nom de la formatrice
#### Exemples :
```python
- conditions_météo = ['pluie', 'neige', 'nuages','soleil','brouillard']
+ conditions_météo = ['pluie', 'neige', 'nuages', 'soleil', 'brouillard']
- provinces = ['BC', 'AB', 'SK','MB','ON','QC','NL,','NB','NS','PE','YT','NT','NU']
+ provinces = ['BC', 'AB', 'SK', 'MB', 'ON', 'QC', 'NL', 'NB', 'NS', 'PE', 'YT', 'NT', 'NU']
- liste_de_tâches = ['Arroser les plantes','Ranger sa chambre','Acheter des chaussures','Devenir Premier ministre', 'Régler le problème des changements climatiques']
+ liste_de_tâches = ['Arroser les plantes', 'Ranger sa chambre', 'Acheter des chaussures', 'Devenir Premier ministre', 'Régler le problème des changements climatiques']
- nombres_premiers = [2,3,5,7,11,13]
+ nombres_premiers = [2, 3, 5, 7, 11, 13]
```
Comme pour les variables, nos listes devraient porter des noms évocateurs et descriptifs.
@@ -865,7 +865,7 @@ avec Nom de la formatrice
Ils sont **indexés** (comptés) à partir de 0.
```python
- conditions_météo = ['pluie', 'neige', 'nuages','soleil','brouillard']
+ conditions_météo = ['pluie', 'neige', 'nuages', 'soleil', 'brouillard']
```
Essayez ces exemples dans la console Python :
@@ -917,7 +917,7 @@ avec Nom de la formatrice
Supposons que nous avons une liste de types de conditions météo.
```python
- conditions_météo = ['pluie', 'neige', 'nuages','soleil','brouillard']
+ conditions_météo = ['pluie', 'neige', 'nuages', 'soleil', 'brouillard']
```
Que pourrions-nous faire avec ces données?
@@ -987,7 +987,7 @@ avec Nom de la formatrice
### Exemple
```python
- conditions_météo = ['pluie', 'neige', 'nuages','soleil','brouillard']
+ conditions_météo = ['pluie', 'neige', 'nuages', 'soleil', 'brouillard']
for type_de_météo in conditions_météo:
print(type_de_météo)
```
From 76bf231c3e7576ad89229dd087788165d480f097 Mon Sep 17 00:00:00 2001
From: Andy Palmer <25123779+ninezerozeronine@users.noreply.github.com>
Date: Sun, 9 Jun 2019 16:50:39 -0700
Subject: [PATCH 2/2] Fix Python indenttation and html section formatting.
---
slides-en.html | 919 ++++++++++++++++++++++++-------------------------
slides-fr.html | 881 +++++++++++++++++++++++------------------------
2 files changed, 893 insertions(+), 907 deletions(-)
diff --git a/slides-en.html b/slides-en.html
index 1f0c222..ba7e896 100644
--- a/slides-en.html
+++ b/slides-en.html
@@ -90,6 +90,7 @@ with Instructor name
+
+
+
-
-
-
-
+
-
+
+
+
-
-
-
+
+
+
+
+
+
-
-
-
-
+
+
+
@@ -427,30 +417,34 @@ with Instructor name
+
+
-
-
-
-
-
-
+
+ Now test it against other weather values.
+
+ The double equals symbol (`==`) will check if the value on the right matches the value stored in the variable.
+
+ ```python
+ >>> weather == "cold"
+ False
+ >>> weather == "snowing"
+ True
+ >>> weather == "Snowing"
+ False
+ ```
+
+
+
+
+
+ ```python
+ >>> x = 4
+ >>> y = 10
+ >>> x < y
+ True
+ >>> x > y
+ False
+ ```
+
+
-
+ The `else` block will run if none of the others are true.
-
- In python, indentation is important.
- This will not work:
- ```python
- weather = "snowing"
- if weather == "snowing":
- print("Wear snowpants")
+
-
-
+
+ * Copy this snippet into the file and change the value for the weather.
+ * Run it a few times with different values
+ * Add more `elif` blocks with other weather conditions
+ ```python
+ weather = "snowing"
+ if weather == "snowing":
+ print("Wear snowpants")
+ elif weather == "raining":
+ print("Bring an umbrella")
+ else:
+ print("Who knows?")
+ ```
+
+
@@ -715,13 +712,12 @@ with Instructor name
```python
weather = "snowing"
if weather == "snowing":
- print("Wear snowpants")
- print("Wear a touque")
+ print("Wear snowpants")
+ print("Wear a touque")
elif weather == "raining":
- print("Bring an umbrella")
+ print("Bring an umbrella")
else:
- print("Who knows?")
-
+ print("Who knows?")
```
If the indentation is wrong you'll see an error:
@@ -729,13 +725,12 @@ with Instructor name
```python
weather = "snowing"
if weather == "snowing":
- print("Wear snowpants")
+ print("Wear snowpants")
print("Wear a touque")
elif weather == "raining":
- print("Bring an umbrella")
+ print("Bring an umbrella")
else:
print("Who knows?")
-
```
```python
@@ -744,14 +739,10 @@ with Instructor name
^
SyntaxError: invalid syntax
```
-
-
-
-
-
+
@@ -810,7 +798,8 @@ with Instructor name
-
+
+
+
+
-
+
@@ -910,18 +897,19 @@ with Instructor name
* Use the function by calling it by name with parentheses
* Inputs to the function go in the parentheses
- * Functions can
- * do work and return nothing (like `print()`)
- * take **inputs** and can **return** values (like math functions)
+ ### Functions can
+
+ * Do work and return nothing (like `print()`)
+ * Take **inputs** and can **return** values (like math functions)

### Mini Exercise
What are some examples of functions in other software (such as [excel](https://support.office.com/en-us/article/excel-functions-alphabetical-b3944572-255d-4efb-bb96-c6d90033e188)) that you might be familliar with?
-
+
+
-
-
-
+
+
+
-
+ * Create a new file in the exercices folder called `weather_loops.py`
+ * Create a list with each type of weather in it
+ * Add a loop to to **loop through** each type of weather
+ * Add an if/elif/else block inside the loop to print out how to dress for each type of weather
+ * You should get one print statement for each type of weather in the list.
+ * Bonus: If you finish early, use concatenation to prepend the type of weather to the print statement along with the advice (example: "Snowing : Wear snowpants")
+
+
-
+
+
+
-
-
-
-
-
-
+
+
+
+ ```python
+ OrderedDict([('Year', '2016'), ('Month', '9'), ('Day', '16'), ('Location', 'Iqaluit'), ('Province', 'NU')])
+ ```
+
+
-
-
-
-
-
-
- ufo_data_file.close()
- ```
-
-
+
- Use what you learned about conditionals to check if the sighting is in 'MB' (or your province)
- ```python
- import csv
+
+ for sighting in ufo_data_dictionary_reader:
+ print(sighting['Location'])
+ ufo_data_file.close()
+ ```
+
+
-
-
-
+
+ Use the `len()` function you learned about earlier to print how many you have:
-
- What we have now:
- * Open a file
- * Read the contents into a python DictReader
- * Convert each row to a dictionary
- * Check each row to see if it's in Manitoba
- * Add it to a list
+
+ `ufo_data_file = open('ufo-data.csv', 'r')`
-
- * What is programming
- * How to write and run python programs
- * Basic programming concepts
- * How to work with files
- * How to programmatically search for data in a file
+
+ What we have now:
+
+ * Open a file
+ * Read the contents into a python DictReader
+ * Convert each row to a dictionary
+ * Check each row to see if it's in Manitoba
+ * Add it to a list
+
+ Now what?
+
+ * Add more criteria!
+ * Look for sightings in Gimli (or some other place)
+ * See how many sightings were in a specific year
+ * anything else you can think of?
+
+
+
+
diff --git a/slides-fr.html b/slides-fr.html
index eb5957c..d47e991 100755
--- a/slides-fr.html
+++ b/slides-fr.html
@@ -79,6 +79,7 @@ avec Nom de la formatrice
+
+
+
-
+
+
+
+
-
+
+
+
-
-
-
+
+
+
+
+
+
-
-
-
-
+
+
+
+
+
+
-
-
-
-
- 
+
+ Est-ce qu'il neige? La réponse est soit `True` ou `False`.
-
- Les deux symboles égal (`==`) vérifient si la valeur à droite correspond à la valeur stockée dans la variable.
- ```
- >>> météo == "froid"
- False
- >>> météo == "neige"
- True
- >>> météo == "Neige"
- False
- ```
-
-
+
+ ```python
+ >>> x = 4
+ >>> y = 10
+ >>> x < y
+ True
+ >>> x > y
+ False
+ ```
+
+
-
+ Le bloc `else` s'exécutera si aucun autre bloc n'est vrai.
-
- Dans le code Python, l'indentation est importante.
- Ce code ne fonctionnera pas :
- ```python
- météo = "neige"
- if météo == "neige":
- print("Porter un pantalon de neige")
+
-
-
+
+ * Copiez cet extrait de code dans le fichier et modifiez la valeur pour la météo.
+ * Exécutez-le quelques fois avec des valeurs différentes.
+ * Ajoutez d'autres blocs `elif` avec d'autres conditions météo.
+ ```python
+ météo = "neige"
+ if météo == "neige":
+ print("Porter un pantalon de neige")
+ elif météo == "pluie":
+ print("Apporter un parapluie")
+ else:
+ print("Qui sait?")
+ ```
+
+
@@ -703,13 +702,12 @@ avec Nom de la formatrice
```python
météo = "neige"
if météo == "neige":
- print("Porter un pantalon de neige")
- print("Porter une tuque")
+ print("Porter un pantalon de neige")
+ print("Porter une tuque")
elif météo == "pluie":
- print("Apporter un parapluie")
+ print("Apporter un parapluie")
else:
- print("Qui sait?")
-
+ print("Qui sait?")
```
Si l'indentation est mauvaise, vous verrez une erreur :
@@ -717,13 +715,12 @@ avec Nom de la formatrice
```python
météo = "neige"
if météo == "neige":
- print("Porter un pantalon de neige")
+ print("Porter un pantalon de neige")
print("Porter une tuque")
elif météo == "pluie":
- print("Apporter un parapluie")
+ print("Apporter un parapluie")
else:
- print("Qui sait?")
-
+ print("Qui sait?")
```
```python
@@ -732,14 +729,10 @@ avec Nom de la formatrice
^
SyntaxError: invalid syntax
```
-
-
-
-
+
-
-
-
+
+
+
+
-
+
@@ -905,10 +895,10 @@ avec Nom de la formatrice
### Miniexercice
Connaissez-vous des exemples de fonctions dans d'autres logiciels, comme [Excel](https://support.office.com/fr-fr/article/fonctions-excel-par-ordre-alphab%C3%A9tique-b3944572-255d-4efb-bb96-c6d90033e188?omkt=fr-CA&ui=fr-FR&rs=fr-CA&ad=CA)?
-
+
+
-
-
-
+
+
+
-
+ * Créez un nouveau fichier dans le dossier exercices appelé `boucles-météo.py`.
+ * Créez une liste comprenant chaque type de condition météo.
+ * Ajoutez une boucle pour **lire en boucle** chaque type de météo.
+ * Ajoutez un bloc if/elif/else à l'intérieur de la boucle pour imprimer (print) une recommandation vestimentaire en fonction du type de condition météo.
+ * Vous devriez avoir un énoncé à imprimer pour chaque type de condition météo dans la liste.
+ * Bonus : si vous terminez plus tôt, faites une concaténation pour ajouter le type de condition météo au début de l'énoncé print avec le conseil météo (exemple : "neige : Porter un pantalon de neige").
+
+
-
+
+
+
-
-
-
-
-
-
+
+
+
+ Qu'est-ce que c'est?
+ ```python
+ OrderedDict([('Année', '2016'), ('Mois', '9'), ('Jour', '16'), ('Lieu', 'Iqaluit'), ('Province', 'NU')])
+ ```
+
+
-
-
- ```python
- import csv
- fichier_données_ovni = open('sousensemble-ovni.csv', 'r')
- lecteur_dictionnaire_données_ovni = csv.DictReader(fichier_données_ovni)
- signalement = next(lecteur_dictionnaire_données_ovni)
- print(signalement)
- signalement = next(lecteur_dictionnaire_données_ovni)
- print(signalement)
- signalement = next(lecteur_dictionnaire_données_ovni)
- print(signalement)
+
+ Pour consulter plus de rangées, vous pouvez utiliser la fonction `next()` plus d'une fois.
-
+ fichier_données_ovni.close()
+ ```
+
+
-
- fichier_données_ovni = open('sousensemble-ovni.csv', 'r')
- lecteur_dictionnaire_données_ovni = csv.DictReader(fichier_données_ovni)
- for signalement in lecteur_dictionnaire_données_ovni:
- print(signalement['Lieu'])
+
+ ```python
+ import csv
-
- fichier_données_ovni = open('sousensemble-ovni.csv', 'r')
- lecteur_dictionnaire_données_ovni = csv.DictReader(fichier_données_ovni)
- for signalement in lecteur_dictionnaire_données_ovni:
- if signalement['Province'] == 'MB':
- print(signalement['Lieu'])
+
+
+
+ ```python
+ import csv
+ fichier_données_ovni = open('sousensemble-ovni.csv', 'r')
+ lecteur_dictionnaire_données_ovni = csv.DictReader(fichier_données_ovni)
-
- ```python
- import csv
- signalements_au_MB = [] # Ceci est une liste vide.
- fichier_données_ovni = open('sousensemble-ovni.csv', 'r')
- lecteur_dictionnaire_données_ovni = csv.DictReader(fichier_données_ovni)
+
+ for signalement in lecteur_dictionnaire_données_ovni:
+ if signalement['Province'] == 'MB':
+ signalements_au_MB.append(signalement)
+ fichier_données_ovni.close()
+ ```
-
- Le temps est venu de passer à un grand ensemble de données.
- Remplacez `fichier_données_ovni = open('sousensemble-ovni.csv', 'r')` par
+
+ Ce fichier csv contient plus de 15 000 éléments, mais croyez-le ou non, il s'agit d'un sous-ensemble de l'ensemble de données complet!
-
- Ce que nous pouvons faire en ce moment :
- * Ouvrir un fichier
- * Lire le contenu du fichier dans un DictReader Python
- * Convertir chaque ligne en dictionnaire
- * Vérifier chaque ligne pour voir si le signalement a été fait au Manitoba
- * Ajouter le signalement à une liste
+
+ Que pouvons-nous faire d'autre?
-
- Voici ce que nous avons appris aujourd'hui :
- * Définition de la programmation
- * Comment écrire et exécuter des programmes en Python
- * Concepts de programmation de base
- * Comment travailler avec des fichiers
- * Comment chercher des données dans un fichier en programmant
+
+ * Définition de la programmation
+ * Comment écrire et exécuter des programmes en Python
+ * Concepts de programmation de base
+ * Comment travailler avec des fichiers
+ * Comment chercher des données dans un fichier en programmant
+
+
@@ -1420,6 +1412,7 @@ avec Nom de la formatrice
+