Pratique du Shadowing: List Comprehension || Python Tutorial || Learn Python Programming - Apprendre l'anglais à l'oral avec la vidéo

Choisissez un mode d'entraînement

Chaque mode ouvre une salle d'entraînement en plein écran.

97 phrases
Si les phrases sont trop courtes ou trop longues, cliquez sur Edit pour les ajuster.
1
When coding, you spend a lot of time making lists.
Quand vous codez, vous passez beaucoup de temps à faire des listes.
2
In many languages this can be tedious.
Dans de nombreuses langues, cela peut être fastidieux.
3
Create an empty list, set up a for loop, then add the items to the list one by one.
Créez une liste vide, configurez une boucle for, puis ajoutez les éléments à la liste un par un.
4
Python cares about your sanity and gives you a tool to simplify this process, list comprehensions.
Python se soucie de votre santé mentale et vous fournit un outil pour simplifier ce processus : les listes en compréhension.
5
In most cases, list comprehensions let you construct a list in a single line of code.
Dans la plupart des cas, les compréhensions de liste vous permettent de construire une liste en une seule ligne de code.
6
It's now time for Python to shine and save time with a single line.
Il est maintenant temps pour Python de briller et de gagner du temps avec une seule ligne.
7
We will cover many examples of list comprehensions, but first, let's talk about them generally.
Nous allons couvrir de nombreux exemples de comprehensions de liste, mais d'abord, parlons-en de manière générale.
8
In Python, lists are a collection of data surrounded by brackets, and the elements are separated by commas.
En Python, les listes sont des collections de données entourées de crochets, et les éléments sont séparés par des virgules.
9
A list comprehension is also surrounded by brackets, but instead of a list of data inside, you enter an expression followed by for loops and if clauses.
Une compréhension de liste est également entourée de crochets, mais au lieu d'une liste de données à l'intérieur, vous entrez une expression suivie de boucles for et de clauses if.
10
Here is the most basic form for a list comprehension.
Voici la forme la plus basique d'une compréhension de liste.
11
The first expression generates the elements in the list, in the list, and you follow this with a for loop over some collection of data.
La première expression génère les éléments de la liste, et vous la faites suivre d'une boucle for parcourant une collection de données.
12
This will evaluate the expression for every item in the collection.
Cela évaluera l'expression pour chaque élément de la collection.
13
If you only want to include the expression for certain pieces of data, you can add on an if clause after the for loop.
Si vous ne souhaitez inclure l'expression que pour certains éléments de données, vous pouvez ajouter une clause if après la boucle for.
14
The expression will be added to the list only if the if clause is true.
L'expression sera ajoutée à la liste uniquement si la condition du bloc if est vraie.
15
You can even have more than one if clause, and the expression is in the list only if all the if clauses are true.
Vous pouvez même avoir plus d'une clause if, et l'expression ne figure dans la liste que si toutes les clauses if sont vraies.
16
And you can even loop over more than one collection.
Et vous pouvez même boucler sur plusieurs collections à la fois.
17
Let's now see some examples.
Voyons maintenant quelques exemples.
18
For our first example, let's create a list of the squares of the first 100 positive integers.
19
Let's first do this without list comprehensions.
20
To begin, you might create an empty list called squares.
21
Next, you would loop over the first 100 positive integers.
22
You would then append the square of i to the list squares.
23
Don't forget that an exponent in Python is represented by double asterisks.
24
Why, oh why, do they not use the intergalactic mathematical notation for exponents?
25
To see that this works print the list squares Let's do this once more using list comprehensions.
26
We will call the list comprehension squares 2
27
Open with a bracket then first type the expression for each term in the list
28
Finally enter the desired for loop
29
if you print this you get the exact same list But we only needed one line of code instead of three
30
Let's now look at a slightly more complex example.
31
We'll create a list of remainders when you divide the first 100 squares by 5.
32
To find the remainder when you divide by 5, use the % operator.
33
In mathematics, this is the same as taking the square mod 5.
34
If you print the list, you'll see there are only 3 perfect squares mod 5, 0, 1, and 4.
35
Let's do this again but look at the remainders when you divide the squares by 11.
36
We see the perfect squares mod 11 are 0, 1, 3, 4, 5, 9.
37
This example shows you that the expressions in the list comprehension can be complex.
38
By the way, if you look at the remainders when you divide by a prime number p, you'll notice an interesting pattern.
39
The number of remainders is p plus 1 divided by 2.
40
The problem of finding which numbers appear in the list is a complex puzzle from number theory known as quadratic reciprocity, and was first proved by Gauss.
41
Next, let's create a list comprehension that has an if clause.
42
Suppose we have a list of movies and we want to find those movies that start with the letter G.
43
Let's see how to do this with and without list comprehensions.
44
If you were not using list comprehensions, you'd start by making an empty list.
45
Next, loop over the list of movies.
46
We can use the starts with method to see if the title starts with the letter G.
47
If it does, then append it to our list.
48
Print the list to make sure that it worked.
49
But this four-line routine can be done in a single line with a list comprehension.
50
The expression we want to appear in our list is simply the title.
51
Next, loop over the movies.
52
But also, check that the title starts with the letter G.
53
Print and observe.
54
We get the same answer with a single line of code.
55
Let's complicate this example a bit more.
56
Suppose our list of movies is a list of tuples
57
containing both the title of the movie and the year it was released.
58
What if we want a list of the titles of all movies that were released before the year 2000?
59
How would you do this using list comprehensions?
60
As before, we want our list to only contain the titles, but this time, when we write the for loop, each element is a tuple.
61
Next, we select the movies released before 2000 using an if clause on the year.
62
If you print the list, you can see that it worked.
63
In this example, the IF block used the year, but the year was not included in the list.
64
Only the title is included.
65
Let's see a mathematical example.
66
Suppose you use a list to represent a vector.
67
How would you perform scalar multiplication on this vector?
68
That is, what if we want to multiply each number by 4?
69
You might be tempted to try 4 times v, but look what happens.
70
This is unusual.
71
What happened here is 4 times v is the same as v plus v plus v plus v.
72
And in Python, if you add two lists, it concatenates them, rather than adding them component-wise.
73
For example, if you add 2, 4, 6 and 1, 3, you get the list 2, 4, 6, 1, 3.
74
So 4 times v is just a list containing four copies of v.
75
This is not what we want.
76
We can achieve scalar multiplication with a list comprehension.
77
Just make a list comprehension where you multiply each component by 4.
78
If you print this vector, you can see we get the desired result.
79
For our final example, let's use list comprehensions to compute the Cartesian product of sets.
80
The Cartesian product is named after the French scholar René Descartes.
81
Recall that if you have two sets A and B, then the Cartesian product is the set of pairs where the first component is in A
82
and the second component is from B.
83
You can write this mathematically like this.
84
For example, if A is the set and B is the set , then the Cartesian product is the set of pairs .
85
Let's use list comprehensions to compute the Cartesian product of two sets.
86
Let A be the list of odd integers 1, 3, 5, and 7.
87
Let B be the list of even integers .
88
To compute the Cartesian product, create a list comprehension where each term is the tuple a, b.
89
Next, write a for loop over the elements of a, and then a for loop over the elements of b.
90
If you print the product, you can see the list contains all 16 possible pairs.
91
Using this technique, you can even compute the Cartesian product of three or more sets.
92
With list comprehensions, you can build complex lists using a single line of code.
93
And with Socratica, you can learn complex topics in a single video.
94
So please, append yourself to our list of subscribers.
95
And if you are in a position to help financially, we would be honored to add you to our list of patrons.
96
Now go forth and code compactly.
97
you

Télécharger l'application

Tout pour parler couramment

Prononciation IAChaque phrase notée
Phonétique (IPA)Maîtrisez chaque son
VocabulaireEnrichissez votre lexique
Jeu de vocabulaireApprenez en jouant

Même chaîne

FOR YOU

Vidéo recommandée

Vocabulaire et conseils d’expression pour cette leçon

Cette leçon d’expression orale de niveau C1 s’appuie sur la vidéo « List Comprehension | ». Les mots qui reviennent le plus souvent : comprehension, loop, square, example, expression. Cette vidéo contient 97 phrases et 1239 mots à répéter en shadowing. La partie parlée dure 7:33. Le locuteur parle à un rythme naturel d’environ 164 mots par minute, proche d’une conversation courante. Seuls 81 % des mots font partie des 3 000 mots les plus courants en anglais, le vocabulaire est donc exigeant.

Vocabulaire clé de cette vidéo

Les 15 mots les plus avancés de la vidéo, avec leur prononciation et leur sens :

MotPrononciationSens
comprehension nom/ˌkɑmpɹɪˈhɛnʃn̩/compréhension, entendement
clause nom/klɔːz/proposition
remainder nom/ɹəˈmeɪndɚ/reste
compute verbe/kəmˈpjuːt/computer, calculer
integer nom/ˈɪn.tɪ.d͡ʒə(ɹ)/entier, nombre entier
append verbe/ʌˈpɛnd/appendre, suspendre
tuple nom/ˈtuːpəl/uplet, n-uplet
litter nom/ˈlɪt.ɚ/litière
vector nom/ˈvɛktɚ/vecteur
exponent nom/ɛkˈspəʊ.nənt/exposant
multiplication nom/ˌmʌltɪplɪˈkeɪʃən/multiplication
multiply verbe/ˈmʌltɪplaɪ/multiplier
scalar adjectif/ˈskeɪ.lə/scalaire
surround verbe/səˈɹaʊnd/entourer, cerner
mathematical adjectif/ˌmæθ(.ə)ˈmæt.ɪ.kəl/mathématique

Les verbes à particule que vous entendrez

MotPrononciationSens
set up verbe/ˌsɛt ˈʌp/mettre en place, installer

Des phrases à répéter

Des phrases courtes et complètes de la vidéo, à réutiliser dans la conversation de tous les jours :

  • Let's now see some examples.
  • Let's first do this without list comprehensions.
  • Let's now look at a slightly more complex example.
  • How would you do this using list comprehensions?
  • How would you perform scalar multiplication on this vector?

La grammaire de cette vidéo

Les structures que le locuteur utilise le plus, avec les mots exacts de la vidéo :

StructureDans la vidéo
Phrases conditionnelles if + proposition, will/would + verbe — une condition et son résultatIf you print the list, you'll see
Voix passive be + participe passé — l’accent est mis sur ce qui arrive, pas sur qui le faitare separated · is also surrounded · will be added

Prononciation à surveiller

Le locuteur utilise 5 contractions et formes réduites, comme you'll, don't, we'll. Prononcez-les sous leur forme courte, telles que vous les entendez.

  • Les sons « sh » et « zh »: comprehension /ˌkɑmpɹɪˈhɛnʃn̩/, multiplication /ˌmʌltɪplɪˈkeɪʃən/, notation /noʊˈteɪʃən/
  • Mots longs — placez bien l’accent: multiplication /ˌmʌltɪplɪˈkeɪʃən/, mathematical /ˌmæθ(.ə)ˈmæt.ɪ.kəl/, concatenate /kənˈkæ.tə.neɪt/, reciprocity /ˌrɛsəˈprɑsəti/

Les sons difficiles pour les francophones :

  • /r/ anglais — langue recourbée, sans frotter la gorge: comprehension /ˌkɑmpɹɪˈhɛnʃn̩/, remainder /ɹəˈmeɪndɚ/, integer /ˈɪn.tɪ.d͡ʒə(ɹ)/, bracket /ˈbɹækɪt/, surround /səˈɹaʊnd/

Comment s’entraîner avec cette vidéo

  1. Écoutez la vidéo en entier une fois sans parler et notez les mots que vous ne connaissez pas.
  2. Commencez à la vitesse 0,75×, répétez phrase par phrase, puis revenez à la vitesse normale quand cela devient facile.
  3. Enregistrez-vous et comparez avec l’original, en faisant attention à des mots comme comprehension, clause, remainder.

Qu'est-ce que la technique du Shadowing ?

Le Shadowing est une technique d'apprentissage des langues fondée sur la science, développée à l'origine pour la formation des interprètes professionnels. Le principe est simple mais puissant : vous écoutez de l'anglais natif et le répétez immédiatement à voix haute — comme une ombre suivant le locuteur avec un décalage de 1 à 2 secondes. Les recherches montrent une amélioration significative de la précision de la prononciation, de l'intonation, du rythme, des liaisons, de la compréhension orale et de la fluidité.

Technique du shadowing : lire le guide complet étape par étape →