Skip to content

Commit

Permalink
Fix miscellaneous typos and spelling mistakes
Browse files Browse the repository at this point in the history
  • Loading branch information
olegresearcher committed May 1, 2024
1 parent f221fd6 commit ff0b177
Show file tree
Hide file tree
Showing 26 changed files with 41 additions and 41 deletions.
2 changes: 1 addition & 1 deletion data/part-10/1-class-hierarchies.md
Original file line number Diff line number Diff line change
Expand Up @@ -307,7 +307,7 @@ class PlatinumCard(BonusCard):
return bonus
```

So, the bonus for a PlatinumCard is calculated by calling the overriden method in the base class, and then adding an extra 5 percent to the base result. An example of how these classes are used:
So, the bonus for a PlatinumCard is calculated by calling the overridden method in the base class, and then adding an extra 5 percent to the base result. An example of how these classes are used:

```python
if __name__ == "__main__":
Expand Down
6 changes: 3 additions & 3 deletions data/part-10/4-application-development.md
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ Objects and classes are by no means necessary in every programming context. For

When programs grow in complexity, the amount of details quickly becomes unmanageable, unless the program is organised in some systematic way. Even some of the more complicated exercises on this course so far would have benefited from the examples set in this part of the material.

Fo decades the concept of [separation of concerns](https://en.wikipedia.org/wiki/Separation_of_concerns) has been one of the central principles in programming, and the larger field of computer science. Quoting from Wikipedia:
For decades the concept of [separation of concerns](https://en.wikipedia.org/wiki/Separation_of_concerns) has been one of the central principles in programming, and the larger field of computer science. Quoting from Wikipedia:

_Separation of concerns is a design principle for separating a computer program into distinct sections such that each section addresses a separate concern. A concern is a set of information that affects the code of a computer program._

Expand Down Expand Up @@ -147,7 +147,7 @@ application = PhoneBookApplication()
application.execute()
```

This program doesn't do very much yet, but let's go through the contents. The constructor method creates a new PhoneBook, which is stored in a private attribute. The method `execute(self)` starts the program's text-based user interface, the core of which is the `while` loop, which keeps asking the user for commands until they type in the command for exiting. There is also a method for intructions, `help(self)`, which is called before entering the loop, so that the instructions are printed out.
This program doesn't do very much yet, but let's go through the contents. The constructor method creates a new PhoneBook, which is stored in a private attribute. The method `execute(self)` starts the program's text-based user interface, the core of which is the `while` loop, which keeps asking the user for commands until they type in the command for exiting. There is also a method for instructions, `help(self)`, which is called before entering the loop, so that the instructions are printed out.

Now, let's add some actual functionality. First, we implement adding new data to the phone book:

Expand Down Expand Up @@ -680,7 +680,7 @@ The file handling process in the PhoneBook application proceeds as follows: the
There are many good guidebooks for learning about good programming practices. One such is [Clean Code](https://www.amazon.com/Clean-Code-Handbook-Software-Craftsmanship/dp/0132350882) by Robert Martin. The code examples in the book are implemented in Java, however, so working through the examples can be quite cumbersome at this point in your programming career, although the book itself is much recommended by the course staff. The themes of easily maintained, expandable, good quality code will be further explored on the courses
[Software Development Methods](https://studies.helsinki.fi/courses/cu/hy-CU-118024742-2020-08-01) and [Software Engineering](https://studies.helsinki.fi/courses/cu/hy-CU-118024909-2020-08-01).

Writing code according to established object oriented programming principles comes at a price. You will likely end up writing more code than you would, were you to write your implementation in one continuous bout of spaghetti code. One of the key skills of a porgrammer is to decide the best approach for each situation. Sometimes it is necessary to just hack something together quickly for immediate use. On the other hand, if in the foreseeable future it can be expected that the code will be reused, maintained or futher developed, either by you or, more critically, by someone else entirely, the readability and logical modularity of the program code become essential. More often than not, if it is worth doing, it is worth doing well, even in the very early stages of development.
Writing code according to established object oriented programming principles comes at a price. You will likely end up writing more code than you would, were you to write your implementation in one continuous bout of spaghetti code. One of the key skills of a programmer is to decide the best approach for each situation. Sometimes it is necessary to just hack something together quickly for immediate use. On the other hand, if in the foreseeable future it can be expected that the code will be reused, maintained or further developed, either by you or, more critically, by someone else entirely, the readability and logical modularity of the program code become essential. More often than not, if it is worth doing, it is worth doing well, even in the very early stages of development.

To finish off this part of the material you will implement one more larger application.

Expand Down
4 changes: 2 additions & 2 deletions data/part-11/1-list-comprehensions.md
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ numbers = [1, 2, 3, 6, 5, 4, 7]
strings = [str(number) for number in numbers]
```

The second line above contains many of the same elements as the more traditional iterative apporach, but the syntax is different. One way of generalising a list comprehension statement would be
The second line above contains many of the same elements as the more traditional iterative approach, but the syntax is different. One way of generalising a list comprehension statement would be

`[<expression> for <item> in <series>]`

Expand Down Expand Up @@ -107,7 +107,7 @@ if __name__ == "__main__":
print(factorials)
```

List comprehensions allow us to express the same functionality more consisely, usually without losing any of the readability.
List comprehensions allow us to express the same functionality more concisely, usually without losing any of the readability.

We can also return a list comprehension statement from a function directly. If we needed a function for producing factorials for lists of numbers, we could achieve it very concisely:

Expand Down
2 changes: 1 addition & 1 deletion data/part-11/2-more-comprehensions.md
Original file line number Diff line number Diff line change
Expand Up @@ -443,7 +443,7 @@ When the function is called with the arguments `most_common_words("comprehension

</sample-output>

NB: the case of letters affects the results, and all inflected forms are unique words in this exercise. That is, the words `List`, `lists` and `list` are each separate words here, and only `list` has enough occurrences to make it to the returned list. All punctutation should be removed before counting up the occurrences.
NB: the case of letters affects the results, and all inflected forms are unique words in this exercise. That is, the words `List`, `lists` and `list` are each separate words here, and only `list` has enough occurrences to make it to the returned list. All punctuation should be removed before counting up the occurrences.

It is up to you to decide how to implement this. The easiest way would likely be to make use of list and dictionary comprehensions.

Expand Down
2 changes: 1 addition & 1 deletion data/part-11/3-recursion.md
Original file line number Diff line number Diff line change
Expand Up @@ -146,7 +146,7 @@ The factorial of 6 is 720

If the parameter of the recursive factorial function is 0 or 1, the function returns 1, because this is how the factorial operation is defined. In any other case the function returns the value `n * factorial(n - 1)`, which is the value of its parameter `n` multiplied by the return value of the function call `factorial(n - 1)`.

The crucial part here is that the function definition contains a stop condition. If this is met, the recursion ends. In this case that condition is `n < 2`. We know it will be reached eventually, beacuse the value passed as the argument to the function is decreased by one on each level of the recursion.
The crucial part here is that the function definition contains a stop condition. If this is met, the recursion ends. In this case that condition is `n < 2`. We know it will be reached eventually, because the value passed as the argument to the function is decreased by one on each level of the recursion.

The [visualisation tool](http://www.pythontutor.com/visualize.html#mode=edit) can be a great help in making sense of recursive programs.

Expand Down
2 changes: 1 addition & 1 deletion data/part-11/4-more-recursion-examples.md
Original file line number Diff line number Diff line change
Expand Up @@ -459,7 +459,7 @@ The first exercise point is granted for a working application when all user inpu

## Handling errors in user input

To gain the second exercise point for this exercise your application is expected to recover from erroneus user input. Any input which does not follow the specified format should produce an error message _erroneous input_, and result in yet another repeat of the loop asking for a new command:
To gain the second exercise point for this exercise your application is expected to recover from erroneous user input. Any input which does not follow the specified format should produce an error message _erroneous input_, and result in yet another repeat of the loop asking for a new command:

<sample-output>

Expand Down
2 changes: 1 addition & 1 deletion data/part-12/2-generators.md
Original file line number Diff line number Diff line change
Expand Up @@ -249,7 +249,7 @@ jkl

Please write a function named `word_generator(characters: str, length: int, amount: int)` which returns a new generator for generating random words based on the parameters given.

A random word is generated by selecting from the string named `characters` as many characters as is indicated by the argument `length`. The same character can appear many times in a random word.
A random word is generated by selecting from the string named `characters` as many characters as indicated by the argument `length`. The same character can appear many times in a random word.

The generator returns as many words as specified by the argument `amount` before terminating.

Expand Down
4 changes: 2 additions & 2 deletions data/part-12/3-functional-programming.md
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ As mentioned above, functional programming is a programming paradigm, or a style
* procedural programming, where the program is grouped into procedures or sub-programs
* object-oriented programming, where the program and its state is stored in objects defined in classes.

There are differing opinions on the divisions between the different paradigms; for example, some maintain that imperative and procedural programming mean the same thing, while others place imperative programming as an umbrella term which covers both procedural and object-oriented programming. Th terminology and divisions are not that important, and neither is strictly sticking to one or the other paradigm, but it is important to understand that such different approaches exist, as they affect the choices programmers make.
There are differing opinions on the divisions between the different paradigms; for example, some maintain that imperative and procedural programming mean the same thing, while others place imperative programming as an umbrella term which covers both procedural and object-oriented programming. The terminology and divisions are not that important, and neither is strictly sticking to one or the other paradigm, but it is important to understand that such different approaches exist, as they affect the choices programmers make.

Many programming languages are designed with one or the other programming paradigm in mind, but Python is a rather versatile programming language, and allows for following several different programming paradigms, even within a single program. This lets us choose the most efficient and clear method for solving each problem.

Expand Down Expand Up @@ -650,7 +650,7 @@ If the initial value is left out, `reduce` takes the first item in the list as t

</text-box>

**NB:** if the items in the series are of a different type than the intended reduced result, the thrd argument is mandatory. The example with the bank accounts would not work without the initial value. That is, trying this
**NB:** if the items in the series are of a different type than the intended reduced result, the third argument is mandatory. The example with the bank accounts would not work without the initial value. That is, trying this

```python
balances_total = reduce(balance_sum_helper, accounts)
Expand Down
2 changes: 1 addition & 1 deletion data/part-13/3-events.md
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ Let's assume the program was left running for a while, and then the exit button
<Event(12-Quit {})>
```

The first few events concern mouse usage, ten there are some events from the keyboard, and finally the last event closes the program. Each event has at least a type, but they may also offer some other identifying info, such as the location of the mouse cursor or the key that was pressed.
The first few events concern mouse usage, then there are some events from the keyboard, and finally the last event closes the program. Each event has at least a type, but they may also offer some other identifying info, such as the location of the mouse cursor or the key that was pressed.

You can look for event descriptions in the [pygame documentation](https://www.pygame.org/docs/ref/event.html), but it can sometimes be easier to print out events with the code above, and look for the event that occurs when something you want to react to happens.

Expand Down
2 changes: 1 addition & 1 deletion data/part-13/4-more-pygame-techniques.md
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,7 @@ Running the above code should look like this:

<img src="pygame_text.gif">

Here the method `pygame.font.SysFont` creates a font object, which uses the system font Arial in size 24. The the method `render` creates an image of the specified text in the given colour. This image is drawn on the window with the `blit` method, just as before.
Here the method `pygame.font.SysFont` creates a font object, which uses the system font Arial in size 24. Then the method `render` creates an image of the specified text in the given colour. This image is drawn on the window with the `blit` method, just as before.

NB: different systems will have different fonts available. If the system this program is exeuted on doesn't have the Arial font, even though Arial is a very common font available on most systems, the default system font is used instead. If you need to have a specific font available for your game, you can include the font file in the game directory and specify its location for the `pygame.font.Font` method.

Expand Down
2 changes: 1 addition & 1 deletion data/part-4/4-definite-iteration.md
Original file line number Diff line number Diff line change
Expand Up @@ -176,7 +176,7 @@ for i in range(1, 9, 2):

</sample-output>

A step can also be negative. Then the range will be in reversed orded. Notice the first two arguments are also flipped here:
A step can also be negative. Then the range will be in reversed order. Notice the first two arguments are also flipped here:

```python
for i in range(6, 2, -1):
Expand Down
4 changes: 2 additions & 2 deletions data/part-5/1-more-lists.md
Original file line number Diff line number Diff line change
Expand Up @@ -300,7 +300,7 @@ Alan: age 39 years, height 1.78 meters

The `for` loop goes through the items in the outer list one by one. That is, each list containing information about a single person is, in turn, assigned to the variable `person`.

Lists arent always the best way to present data, such as information about a person. We will soon come across Python _dictionaries_, which are often better suited to such situations.
Lists aren't always the best way to present data, such as information about a person. We will soon come across Python _dictionaries_, which are often better suited to such situations.

## Matrices

Expand Down Expand Up @@ -333,7 +333,7 @@ print(my_matrix)

</sample-output>

Like any other list, the rows of the matrix can be traversed wth a `for` loop. The following code prints out each row of the matrix on a separate line:
Like any other list, the rows of the matrix can be traversed with a `for` loop. The following code prints out each row of the matrix on a separate line:

```python
my_matrix = [[1, 2, 3], [4, 5, 6], [7, 8, 9]]
Expand Down
2 changes: 1 addition & 1 deletion data/part-5/3-dictionary.md
Original file line number Diff line number Diff line change
Expand Up @@ -411,7 +411,7 @@ quitting...

## Removing keys and values from a dictionary

It is naturally possible to also remove key-value paris from the dictionary. There are two ways to accomplish this. The first is the command `del`:
It is naturally possible to also remove key-value pairs from the dictionary. There are two ways to accomplish this. The first is the command `del`:

```python
staff = {"Alan": "lecturer", "Emily": "professor", "David": "lecturer"}
Expand Down
2 changes: 1 addition & 1 deletion data/part-5/4-tuple.md
Original file line number Diff line number Diff line change
Expand Up @@ -189,7 +189,7 @@ numbers = (1, 2, 3)
numbers = 1, 2, 3
```

This means we can also easily return multiple values using tuples. Let's have alook at he following example:
This means we can also easily return multiple values using tuples. Let's have a look at he following example:

```python
def minmax(my_list):
Expand Down
6 changes: 3 additions & 3 deletions data/part-6/1-reading-files.md
Original file line number Diff line number Diff line change
Expand Up @@ -296,7 +296,7 @@ Traceback (most recent call last):
UnboundLocalError: local variable 'oldest' referenced before assignment
```

The reason this happens is that the latter `for` loop is not executed at all, beacuse the file can only be processed once. Once the last line is read, the file handle rests at the end of the file, and the data in the file can no longer be accessed.
The reason this happens is that the latter `for` loop is not executed at all, because the file can only be processed once. Once the last line is read, the file handle rests at the end of the file, and the data in the file can no longer be accessed.

If we want to access the contents in the second `for` loop, we will have to `open` the file a second time:

Expand Down Expand Up @@ -426,7 +426,7 @@ with open("people.csv") as new_file:
print(last_names)
```

Exectuing this would print out
Executing this would print out

<sample-output>

Expand Down Expand Up @@ -662,7 +662,7 @@ liisa virtanen 3

</sample-output>

Each completed exercise is counted towards _exercise points_, so that completing at least 10 % of the total exercices awards 1 point, completing at least 20 % awards 2 points, etc. Completing all 40 exercises awards 10 points. The number of points awarded is always an integer number.
Each completed exercise is counted towards _exercise points_, so that completing at least 10 % of the total exercises awards 1 point, completing at least 20 % awards 2 points, etc. Completing all 40 exercises awards 10 points. The number of points awarded is always an integer number.

The final grade for the course is determined based on the sum of exam and exercise points according to the following table:

Expand Down
6 changes: 3 additions & 3 deletions data/part-6/2-writing-files.md
Original file line number Diff line number Diff line change
Expand Up @@ -107,7 +107,7 @@ Hi Ada, we hope you enjoy learning Python with us! Best, Mooc.fi Team

If you want to append data to the end of a file, instead of overwriting the entire file, you should open the file in append mode with the argument `a`.

If the file doesn't yet exist, append mode works exatly like write mode.
If the file doesn't yet exist, append mode works exactly like write mode.

The following program opens the file `new_file.txt` and appends a couple of lines of text to the end:

Expand Down Expand Up @@ -421,7 +421,7 @@ Emily;41;5

</sample-data>

Notice how each function defined above is relatively simple, and they all have a single responsibility. This is a common and advisable approach when programming larger wholes. The single reponsibility principle makes verifying functionality easier. It also makes it easier to make changes to the program later, and to add new features.
Notice how each function defined above is relatively simple, and they all have a single responsibility. This is a common and advisable approach when programming larger wholes. The single responsibility principle makes verifying functionality easier. It also makes it easier to make changes to the program later, and to add new features.

Say we wanted to add a function for printing out the grade for a single student. We already have a function which determines the student's grade, so we can use this in our new function:

Expand Down Expand Up @@ -449,7 +449,7 @@ If we determine a certain functionality in the program needs fixing, in a well d

Let's revisit the course grading project from the previous section.

As we left if last time, the program read and processed files containing student information, completed exercises and exam results. We'll add a file containing information about the course. An example of the format of the file:
As we left it last time, the program read and processed files containing student information, completed exercises and exam results. We'll add a file containing information about the course. An example of the format of the file:

<sample-data>

Expand Down
Loading

0 comments on commit ff0b177

Please sign in to comment.