Skip to content

Commit af854fc

Browse files
committed
resolving conflicts and removing suggestion to import both numpy and as np
2 parents bfc5fe9 + 1487fc9 commit af854fc

File tree

2 files changed

+39
-7
lines changed

2 files changed

+39
-7
lines changed

_episodes/01-numpy.md

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -808,7 +808,7 @@ the graphs will actually be squeezed together more closely.)
808808
> to make a shortcut like so: `import numpy as np`.
809809
> If you ever see Python code online using a NumPy function with `np`
810810
> (for example, `np.loadtxt(...)`), it's because they've used this shortcut.
811-
{: .callout}
811+
> When working with other people, it is important to agree on a convention of how common libraries are imported.
812812
813813
> ## Check Your Understanding
814814
>
@@ -1104,9 +1104,9 @@ the graphs will actually be squeezed together more closely.)
11041104
> > print(D)
11051105
> > ~~~
11061106
> > {: .python}
1107-
> >
1107+
> >
11081108
> > ~~~
1109-
> > D =
1109+
> > D =
11101110
> > [[1 3]
11111111
> > [4 6]
11121112
> > [7 9]]
@@ -1115,19 +1115,19 @@ the graphs will actually be squeezed together more closely.)
11151115
> {: .solution}
11161116
>
11171117
> > ## Solution
1118-
> >
1118+
> >
11191119
> > An alternative way to achieve the same result is to use Numpy's
11201120
> > delete function to remove the second column of A.
1121-
> >
1121+
> >
11221122
> > ~~~
11231123
> > D = numpy.delete(A, 1, 1)
11241124
> > print('D = ')
11251125
> > print(D)
11261126
> > ~~~
11271127
> > {: .python}
1128-
> >
1128+
> >
11291129
> > ~~~
1130-
> > D =
1130+
> > D =
11311131
> > [[1 3]
11321132
> > [4 6]
11331133
> > [7 9]]

_episodes/02-loop.md

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -154,6 +154,38 @@ but there must be a colon at the end of the line starting the loop,
154154
and we must indent anything we want to run inside the loop. Unlike many other languages, there is no
155155
command to signify the end of the loop body (e.g. end for); what is indented after the for statement belongs to the loop.
156156

157+
158+
> ## What's in a name? {.callout}
159+
> In the example above, the loop variable was given the name `char` as a mnemonic; it is short for 'character'. 'Char' is not a keyword in Python that pulls the characters from words or strings. In fact when a similar loop is run over a list rather than a word, the output would be each member of that list printed in order, rather than the characters.
160+
>~~~ {.python}
161+
>list = ['oxygen','nitrogen','argon']
162+
>for char in list:
163+
> print(char)
164+
>~~~
165+
>
166+
>~~~ {.output}
167+
>oxygen
168+
>nitrogen
169+
>argon
170+
>~~~
171+
> We can choose any name we want for variables. We might just as easily have chosen the name `banana` for the loop variable, as long as we use the same name when we invoke the variable inside the loop:
172+
>~~~ {.python}
173+
>word = 'oxygen'
174+
>for banana in word:
175+
> print(banana)
176+
>~~~
177+
>
178+
>~~~ {.output}
179+
>o
180+
>x
181+
>y
182+
>g
183+
>e
184+
>n
185+
>~~~
186+
> It is a good idea to choose variable names that are meaningful, otherwise it would be more difficult to understand what the loop is doing.
187+
188+
157189
Here's another loop that repeatedly updates a variable:
158190
159191
~~~

0 commit comments

Comments
 (0)