Skip to content

Commit 6e23e49

Browse files
committed
Simplify sentence and correct annotations
1 parent 9796fdb commit 6e23e49

File tree

1 file changed

+15
-18
lines changed

1 file changed

+15
-18
lines changed

lectures/python_by_example.md

Lines changed: 15 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -142,8 +142,6 @@ In fact, a package is just a directory containing
142142
In fact, you can find and explore the directory for NumPy on your computer
143143
easily enough if you look around.
144144

145-
The directory can be different based on the system of the machine and the version of python.
146-
147145
You can check the location of your `__init__.py` for NumPy in python by running the code:
148146

149147
```{code-block} ipython
@@ -154,15 +152,6 @@ import numpy as np
154152
print(np.__file__)
155153
```
156154

157-
For example, on this machine, it's located in
158-
159-
```{code-block} ipython
160-
:class: no-execute
161-
162-
anaconda3/lib/python3.9/site-packages/numpy/
163-
```
164-
165-
166155
#### Subpackages
167156

168157
```{index} single: Python; Subpackages
@@ -172,7 +161,9 @@ Consider the line `ϵ_values = np.random.randn(100)`.
172161

173162
Here `np` refers to the package NumPy, while `random` is a **subpackage** of NumPy.
174163

175-
Subpackages are just packages that are subdirectories of another package. For instance, you can find folder `random` under the directory of NumPy.
164+
Subpackages are just packages that are subdirectories of another package.
165+
166+
For instance, you can find folder `random` under the directory of NumPy.
176167

177168
### Importing Names Directly
178169

@@ -263,7 +254,9 @@ Let's study some parts of this program in more detail.
263254

264255
Consider the statement `ϵ_values = []`, which creates an empty list.
265256

266-
Lists are a *native Python data structure* used to group a collection of objects. Items in lists are ordered, and duplicates are allowed in lists.
257+
Lists are a *native Python data structure* used to group a collection of objects.
258+
259+
Items in lists are ordered, and duplicates are allowed in lists.
267260

268261
For example, try
269262

@@ -410,7 +403,9 @@ plt.plot(ϵ_values)
410403
plt.show()
411404
```
412405

413-
A while loop will keep executing the code block delimited by indentation until the condition (```i < ts_length```) is satisfied. It means that the programme will keep adding values to the list ```ϵ_values``` until ```i``` equals ```ts_length```:
406+
A while loop will keep executing the code block delimited by indentation until the condition (```i < ts_length```) is satisfied.
407+
408+
In this case, the program will keep adding values to the list ```ϵ_values``` until ```i``` equals ```ts_length```:
414409

415410
```{code-cell} python3
416411
i == ts_length #the ending condition for the while loop
@@ -465,7 +460,7 @@ operating system.
465460
Notice that we added a legend to the plot --- a feature you will be asked to
466461
use in the exercises.
467462

468-
## Exercises and Solutions
463+
## Exercises
469464

470465
Now we turn to exercises. It is important that you complete them before
471466
continuing, since they present new concepts we will need.
@@ -559,7 +554,9 @@ plt.legend()
559554
plt.show()
560555
```
561556

562-
Note:`f'$\\alpha = {α}$'` in the solution is an application of [f-String](https://docs.python.org/3/tutorial/inputoutput.html#tut-f-strings), which allows you to use `{}` to contain an expression. The contained expression will be evaluated, and the result will be placed into the string.
557+
Note: `f'$\\alpha = {α}$'` in the solution is an application of [f-String](https://docs.python.org/3/tutorial/inputoutput.html#tut-f-strings), which allows you to use `{}` to contain an expression.
558+
559+
The contained expression will be evaluated, and the result will be placed into the string.
563560

564561

565562
```{solution-end}
@@ -739,10 +736,10 @@ for i in range(n):
739736
u, v = np.random.uniform(), np.random.uniform()
740737
741738
# check whether the point falls within the boundary
742-
# of the semi-circle centred at (0.5,0.5)
739+
# of the unit circle centred at (0.5,0.5)
743740
d = np.sqrt((u - 0.5)**2 + (v - 0.5)**2)
744741
745-
# if it falls within the inscribed semi-circle,
742+
# if it falls within the inscribed circle,
746743
# add it to the count
747744
if d < 0.5:
748745
count += 1

0 commit comments

Comments
 (0)