Skip to content

Commit dc4b911

Browse files
author
pmb dev
committed
Merge remote-tracking branch 'upstream/master'
2 parents 4b377ce + de55787 commit dc4b911

11 files changed

Lines changed: 34 additions & 23 deletions

File tree

Notes/01_Introduction/02_Hello_world.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -58,7 +58,7 @@ interact with the interpreter.
5858
Let's take a closer look at the elements of the REPL:
5959

6060
- `>>>` is the interpreter prompt for starting a new statement.
61-
- `...` is the interpreter prompt for continuing a statements. Enter a blank line to finish typing and run the statements.
61+
- `...` is the interpreter prompt for continuing a statement. Enter a blank line to finish typing and run what you've entered.
6262

6363
The `...` prompt may or may not be shown depending on your environment. For this course,
6464
it is shown as blanks to make it easier to cut/paste code samples.

Notes/01_Introduction/03_Numbers.md

Lines changed: 9 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -106,8 +106,9 @@ x ** y Power
106106
abs(x) Absolute Value
107107
```
108108

109-
TYPO
110-
Theses are the same operators as Integers, except for the bit-wise operators.
109+
110+
These are the same operators as Integers, except for the bit-wise operators.
111+
111112
Additional math functions are found in the `math` module.
112113

113114

@@ -236,15 +237,16 @@ The output should look something like this:
236237
4 10736.44 497581.83
237238
5 13420.55 496970.98
238239
...
239-
308 875705.88 674.44
240-
309 878389.99 -2006.86
241-
Total paid 878389.99
242-
Months 309
240+
308 874705.88 2971.43
241+
309 877389.99 299.7
242+
310 880074.1 -2383.16
243+
Total paid 880074.1
244+
Months 310
243245
```
244246

245247
### Exercise 1.11: Bonus
246248

247-
While you’re at it, fix the program to correct the for overpayment that occurs in the last month.
249+
While you’re at it, fix the program to correct for the overpayment that occurs in the last month.
248250

249251
### Exercise 1.12: A Mystery
250252

Notes/01_Introduction/04_Strings.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22

33
# 1.4 Strings
44

5-
This section introduces way to work with text.
5+
This section introduces ways to work with text.
66

77
### Representing Literal Text
88

@@ -134,7 +134,7 @@ t = s.replace('Hello' , 'Hallo') # 'Hallo world'
134134
**More string methods:**
135135

136136
Strings have a wide variety of other methods for testing and manipulating the text data.
137-
This is small sample of methods:
137+
This is a small sample of methods:
138138

139139
```python
140140
s.endswith(suffix) # Check if string ends with suffix

Notes/01_Introduction/06_Files.md

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -220,14 +220,17 @@ Try it:
220220

221221
```python
222222
>>> import gzip
223-
>>> with gzip.open('Data/portfolio.csv.gz') as f:
223+
>>> with gzip.open('Data/portfolio.csv.gz', 'rt') as f:
224224
for line in f:
225225
print(line, end='')
226226

227227
... look at the output ...
228228
>>>
229229
```
230230

231+
Note: Including the file mode of `'rt'` is critical here. If you forget that,
232+
you'll get byte strings instead of normal text strings.
233+
231234
### Commentary: Shouldn't we being using Pandas for this?
232235

233236
Data scientists are quick to point out that libraries like

Notes/02_Working_with_data/01_Datatypes.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -58,7 +58,7 @@ Sometimes the `()` are omitted in the syntax.
5858
s = 'GOOG', 100, 490.1
5959
```
6060

61-
Special cases (0-tuple, 1-typle).
61+
Special cases (0-tuple, 1-tuple).
6262

6363
```python
6464
t = () # An empty tuple

Notes/02_Working_with_data/02_Containers.md

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -52,9 +52,10 @@ An example when reading records from a file.
5252
records = [] # Initial empty list
5353

5454
with open('Data/portfolio.csv', 'rt') as f:
55+
next(f) # Skip header
5556
for line in f:
5657
row = line.split(',')
57-
records.append((row[0], int(row[1])), float(row[2]))
58+
records.append((row[0], int(row[1]), float(row[2])))
5859
```
5960

6061
### Dicts as a Container
@@ -105,6 +106,11 @@ with open('Data/prices.csv', 'rt') as f:
105106
prices[row[0]] = float(row[1])
106107
```
107108

109+
Note: If you try this on the `Data/prices.csv` file, you'll find that
110+
it almost works--there's a blank line at the end that causes it to
111+
crash. You'll need to figure out some way to modify the code to
112+
account for that (see Exercise 2.6).
113+
108114
### Dictionary Lookups
109115

110116
You can test the existence of a key.
@@ -335,7 +341,7 @@ accessed by key names instead of numeric column numbers. This is
335341
often preferred because the resulting code is easier to read later.
336342

337343
Viewing large dictionaries and lists can be messy. To clean up the
338-
output for debugging, considering using the `pprint` function.
344+
output for debugging, consider using the `pprint` function.
339345

340346
```python
341347
>>> from pprint import pprint
@@ -437,9 +443,9 @@ interactively to make sure it works:
437443
### Exercise 2.7: Finding out if you can retire
438444

439445
Tie all of this work together by adding a few additional statements to
440-
your `report.py` program that compute gain/loss. These statements
446+
your `report.py` program that computes gain/loss. These statements
441447
should take the list of stocks in Exercise 2.5 and the dictionary of
442-
prices in Exercise 2.6 and computes the current value of the portfolio
448+
prices in Exercise 2.6 and compute the current value of the portfolio
443449
along with the gain/loss.
444450

445451
[Contents](../Contents.md) \| [Previous (2.1 Datatypes)](01_Datatypes.md) \| [Next (2.3 Formatting)](03_Formatting.md)

Notes/02_Working_with_data/06_List_comprehension.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -80,7 +80,7 @@ for variable_name in sequence:
8080

8181
### Historical Digression
8282

83-
List comprehension come from math (set-builder notation).
83+
List comprehensions come from math (set-builder notation).
8484

8585
```code
8686
a = [ x * x for x in s if x > 0 ] # Python

Notes/03_Program_organization/06_Design_discussion.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -110,7 +110,7 @@ with any file-like/iterable object. For example:
110110
>>> with gzip.open('Data/portfolio.csv.gz', 'rt') as file:
111111
... port = fileparse.parse_csv(file, types=[str,int,float])
112112
...
113-
>>> lines = ['name,shares,price', 'AA,34.23,100', 'IBM,50,91.1', 'HPE,75,45.1']
113+
>>> lines = ['name,shares,price', 'AA,100,34.23', 'IBM,50,91.1', 'HPE,75,45.1']
114114
>>> port = fileparse.parse_csv(lines, types=[str,int,float])
115115
>>>
116116
```

Notes/04_Classes_objects/01_Class.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -143,7 +143,7 @@ If you want to operate on an instance, you always refer to it explicitly (e.g.,
143143
## Exercises
144144

145145
Starting with this set of exercises, we start to make a series of
146-
changes to existing code from previous sctions. It is critical that
146+
changes to existing code from previous sections. It is critical that
147147
you have a working version of Exercise 3.18 to start. If you don't
148148
have that, please work from the solution code found in the
149149
`Solutions/3_18` directory. It's fine to copy it.

Notes/05_Object_model/01_Dicts_revisited.md

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ involving dictionaries. This section discusses that.
77

88
### Dictionaries, Revisited
99

10-
Remember that a dictionary is a collection of names values.
10+
Remember that a dictionary is a collection of named values.
1111

1212
```python
1313
stock = {
@@ -58,7 +58,7 @@ A dictionary holds the instance data, `__dict__`.
5858
```python
5959
>>> s = Stock('GOOG', 100, 490.1)
6060
>>> s.__dict__
61-
{'name' : 'GOOG','shares' : 100, 'price': 490.1 }
61+
{'name' : 'GOOG', 'shares' : 100, 'price': 490.1 }
6262
```
6363

6464
You populate this dict (and instance) when assigning to `self`.
@@ -271,7 +271,7 @@ e = E()
271271
e.attr
272272
```
273273

274-
A attribute search process is carried out, but what is the order? That's a problem.
274+
An attribute search process is carried out, but what is the order? That's a problem.
275275

276276
Python uses *cooperative multiple inheritance* which obeys some rules
277277
about class ordering.

0 commit comments

Comments
 (0)