Skip to content

Commit 1c238df

Browse files
maxim-belkinldko
andauthored
05-loop.md: Apply Lauren's suggestions
Co-authored-by: Lauren Ko <[email protected]>
1 parent 05342df commit 1c238df

File tree

1 file changed

+8
-7
lines changed

1 file changed

+8
-7
lines changed

_episodes/05-loop.md

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,8 @@ keypoints:
1515
- "Use `len(thing)` to determine the length of something that contains other values."
1616
---
1717

18-
In the first episode, we wrote Python code that plots values of interest from our first
18+
In the episode about visualizing data,
19+
we wrote Python code that plots values of interest from our first
1920
inflammation dataset (`inflammation-01.csv`), which revealed some suspicious features in it.
2021

2122
![Line graphs showing average, maximum and minimum inflammation across all patients over a 40-day period.](../fig/03-loop_2_0.png)
@@ -34,7 +35,7 @@ odds = [1, 3, 5, 7]
3435
{: .language-python}
3536

3637
In Python, a list is basically an ordered collection of elements, and every
37-
element has a unique number associated with it -- its index. This means that
38+
element has a unique number associated with it --- its index. This means that
3839
we can access elements in a list using their indices.
3940
For example, we can get the first number in the list `odds`,
4041
by using `odds[0]`. One way to print each number is to use four `print` statements:
@@ -68,7 +69,7 @@ This is a bad approach for three reasons:
6869
3. **Fragile**. If we use it with a list that has more elements than what we initially
6970
envisioned, it will only display part of the list's elements. A shorter list, on
7071
the other hand, will cause an error because it will be trying to display elements of the
71-
list that don't exist.
72+
list that do not exist.
7273

7374
~~~
7475
odds = [1, 3, 5]
@@ -116,7 +117,7 @@ for num in odds:
116117
{: .output}
117118

118119
This is shorter --- certainly shorter than something that prints every number in a
119-
hundred-letter list --- and more robust as well:
120+
hundred-number list --- and more robust as well:
120121

121122
~~~
122123
odds = [1, 3, 5, 7, 9, 11]
@@ -145,7 +146,7 @@ for variable in collection:
145146
~~~
146147
{: .language-python}
147148

148-
Using the example example above, the loop might look like this:
149+
Using the odds example above, the loop might look like this:
149150

150151
![Loop variable 'num' being assigned the value of each element in the list `odds` in turn and then being printed](../fig/05-loops_image_num.png)
151152

@@ -215,15 +216,15 @@ The statement adds 1 to the old value of `length`,
215216
producing 1,
216217
and updates `length` to refer to that new value.
217218
The next time around,
218-
+`value` is `Darwin` and `length` is 1,
219+
`value` is `Darwin` and `length` is 1,
219220
so `length` is updated to be 2.
220221
After one more update,
221222
`length` is 3;
222223
since there is nothing left in `names` for Python to process,
223224
the loop finishes
224225
and the `print` function on line 5 tells us our final answer.
225226
226-
Note that a loop variable is a variable that's being used to record progress in a loop.
227+
Note that a loop variable is a variable that is being used to record progress in a loop.
227228
It still exists after the loop is over,
228229
and we can re-use variables previously defined as loop variables as well:
229230

0 commit comments

Comments
 (0)