Skip to content

Commit 4c4c681

Browse files
Fix prose typos in functions and OOP lectures
1 parent b0b0b56 commit 4c4c681

3 files changed

Lines changed: 13 additions & 13 deletions

File tree

‎lectures/functions.md‎

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ kernelspec:
2525

2626
## Overview
2727

28-
Functions are an extremely useful construct provided by almost all programming.
28+
Functions are an extremely useful construct provided by almost all programming languages.
2929

3030
We have already met several functions, such as
3131

@@ -35,7 +35,7 @@ We have already met several functions, such as
3535
In this lecture we'll
3636

3737
1. treat functions systematically and cover syntax and use-cases, and
38-
2. learn to do is build our own user-defined functions.
38+
2. learn how to build our own user-defined functions.
3939

4040
We will use the following imports.
4141

@@ -360,7 +360,7 @@ Notes
360360

361361
Now, there are several ways that we can simplify the code above.
362362

363-
For example, we can get rid of the conditionals all together by just passing the desired generator type as a function, method, or other [callable](https://typing.python.org/en/latest/spec/callables.html) object.
363+
For example, we can get rid of the conditionals altogether by just passing the desired generator type as a function, method, or other [callable](https://typing.python.org/en/latest/spec/callables.html) object.
364364

365365
To understand this, consider the following version.
366366

@@ -417,7 +417,7 @@ your programming career.
417417

418418
Basically, a recursive function is a function that calls itself.
419419

420-
For example, consider the problem of computing $x_t$ for some t when
420+
For example, consider the problem of computing $x_t$ for some $t$ when
421421

422422
```{math}
423423
:label: xseqdoub
@@ -669,7 +669,7 @@ print([x(i) for i in range(10)])
669669
:label: func_ex5
670670
```
671671

672-
Rewrite the function `factorial()` in from [Exercise 1](factorial_exercise) using recursion.
672+
Rewrite the function `factorial()` from [Exercise 1](factorial_exercise) using recursion.
673673

674674
```{exercise-end}
675675
```

‎lectures/oop_intro.md‎

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -192,7 +192,7 @@ When Python creates this integer object, it stores with it various auxiliary inf
192192

193193
Any name following a dot is called an *attribute* of the object to the left of the dot.
194194

195-
* e.g.,``imag`` and `__class__` are attributes of `x`.
195+
* e.g., `imag` and `__class__` are attributes of `x`.
196196

197197
We see from this example that objects have attributes that contain auxiliary information.
198198

@@ -299,7 +299,7 @@ The answer is related to the fact that Python aims for readability and consisten
299299
In Python, it is common for users to build custom objects --- we discuss how to
300300
do this {doc}`later <python_oop>`.
301301

302-
It's quite common for users to add methods to their that measure the length of
302+
It's quite common for users to add methods to their objects that measure the length of
303303
the object, suitably defined.
304304

305305
When naming such a method, natural choices are `len()` and `length()`.
@@ -343,7 +343,7 @@ This includes not just lists, strings, etc., but also less obvious things, such
343343
* files opened for reading or writing
344344
* integers, etc.
345345

346-
Remember that everything is an object will help you interact with your programs
346+
Remembering that everything is an object will help you interact with your programs
347347
and write clear Pythonic code.
348348

349349
## Exercises

‎lectures/python_oop.md‎

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -155,7 +155,7 @@ Before we do so, in order to indicate some of the power of Classes, we'll define
155155

156156
```{code-cell} python3
157157
def earn(w,y):
158-
"Consumer with inital wealth w earns y"
158+
"Consumer with initial wealth w earns y"
159159
return w+y
160160
161161
def spend(w,x):
@@ -186,7 +186,7 @@ print("w0,w1,w2,w3,w4 = ", w0,w1,w2,w3,w4)
186186

187187
A *Class* bundles a set of data tied to a particular *instance* together with a collection of functions that operate on the data.
188188

189-
In our example, an *instance* will be the name of particular *person* whose *instance data* consist solely of its wealth.
189+
In our example, an *instance* will be the name of a particular *person* whose *instance data* consist solely of its wealth.
190190

191191
(In other examples *instance data* will consist of a vector of data.)
192192

@@ -206,7 +206,7 @@ We'll build a `Consumer` class with
206206

207207
Admittedly a little contrived, this example of a class helps us internalize some peculiar syntax.
208208

209-
Here how we set up our Consumer class.
209+
Here's how we set up our Consumer class.
210210

211211
```{code-cell} python3
212212
class Consumer:
@@ -223,7 +223,7 @@ class Consumer:
223223
"The consumer spends x dollars if feasible"
224224
new_wealth = self.wealth - x
225225
if new_wealth < 0:
226-
print("Insufficent funds")
226+
print("Insufficient funds")
227227
else:
228228
self.wealth = new_wealth
229229
```
@@ -240,7 +240,7 @@ The `earn` and `spend` methods deploy the functions we described earlier and tha
240240

241241
The `__init__` method is a *constructor method*.
242242

243-
Whenever we create an instance of the class, the `__init_` method will be called automatically.
243+
Whenever we create an instance of the class, the `__init__` method will be called automatically.
244244

245245
Calling `__init__` sets up a "namespace" to hold the instance data --- more on this soon.
246246

0 commit comments

Comments
 (0)