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 Apr 17, 2024
1 parent f221fd6 commit e8e5846
Show file tree
Hide file tree
Showing 10 changed files with 20 additions and 20 deletions.
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-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
8 changes: 4 additions & 4 deletions data/part-6/3-errors.md
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ After this section

</text-box>

The are two basic categories of errors that come up in programming contexts:
There are two basic categories of errors that come up in programming contexts:

1. Syntax errors, which prevent the execution of the program
2. Runtime errors, which halt the execution
Expand Down Expand Up @@ -74,7 +74,7 @@ The `int` function is unable to parse the input string `twenty-three` as a valid

Errors that occur while the program is already running are called _exceptions_. It is possible to prepare for exceptions, and handle them so that the execution continues despite them occurring.

Exception handling in Python is accomplished with `try` and `except` statements. The idea is that if something within a `try` block causes an exception, Python checks if there is a corresponding `except` block. If such a block exists, it is executed and the program themn continues as if nothing happened.
Exception handling in Python is accomplished with `try` and `except` statements. The idea is that if something within a `try` block causes an exception, Python checks if there is a corresponding `except` block. If such a block exists, it is executed and the program then continues as if nothing happened.

Let's change the above example so that the program is prepared for the `ValueError` exception:

Expand All @@ -99,7 +99,7 @@ This is not a valid age

We can use the `try` block to flag that the code within the block may cause an error. In the `except` statement directly after the block the relevant error is mentioned. In the above example we covered only a `ValueError` exception. If the exception had some other cause, the execution would still have halted, despite the `try` and `except` blocks.

In the above example, if the error is caught, the value of `age` is set to -1. This is an invalid input value which we have already programmed behaviour for, as the program excpects the age of the user to be greater than 0.
In the above example, if the error is caught, the value of `age` is set to -1. This is an invalid input value which we have already programmed behaviour for, as the program expects the age of the user to be greater than 0.

In the following example we have a function `read_integer`, which asks the user to type in an integer value, but the function is also prepared for invalid input. The function keeps asking for integers until the user types in a valid input value.

Expand Down Expand Up @@ -333,7 +333,7 @@ Invalid parameters in this case include:

<programming-exercise name='Incorrect lottery numbers' tmcname='part06-19_incorrect_lottery_numbers'>

The file `lottery_numbers.csv` containts winning lottery numbers in the following format:
The file `lottery_numbers.csv` contains winning lottery numbers in the following format:

<sample-data>

Expand Down
6 changes: 3 additions & 3 deletions data/part-7/4-data-processing.md
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ After this section

## Reading CSV files

CSV is such a simple format that so far we have accessed the with hand-written code. There is, however, a ready-made module in the Python standard library for working with CSV files: [csv](https://docs.python.org/3/library/csv.html). It works like this:
CSV is such a simple format that so far we have accessed with the hand-written code. There is, however, a ready-made module in the Python standard library for working with CSV files: [csv](https://docs.python.org/3/library/csv.html). It works like this:

```python
import csv
Expand Down Expand Up @@ -308,7 +308,7 @@ timo;18:42
kalle;13:23
```
Additionally, the file `submissions.csv` contains points and handin times for individual exercises. The format here is `name;task;points;hh:mm`. An example:
Additionally, the file `submissions.csv` contains points and handing times for individual exercises. The format here is `name;task;points;hh:mm`. An example:
```csv
jarmo;1;8;16:05
Expand All @@ -332,7 +332,7 @@ You have the CSV files from the previous exercise at your disposal again. Please
The tasks are numbered 1 to 8, and each submission is graded with 0 to 6 points.
In the dicionary returned the key should be the name of the student, and the value the total points received by the student.
In the dictionary returned the key should be the name of the student, and the value the total points received by the student.
Hint: nested dictionaries might be a good approach when processing the tasks and submission times of each student.
Expand Down
2 changes: 1 addition & 1 deletion data/part-7/6-more-features.md
Original file line number Diff line number Diff line change
Expand Up @@ -171,7 +171,7 @@ Please write a function named `run(program)`, which takes a list containing the

You may assume the function will only be given programs which are entirely in the correct format. You do not have to implement any input validation or error handling.

This exercise is worth two points. You will receive one point if the commands `PRINT`, `MOV`, `ADD`, `SUB`, `MUL` and `END` are working correctly. You will receice another point if the rest of the commands, which are used to implement loops, also work.
This exercise is worth two points. You will receive one point if the commands `PRINT`, `MOV`, `ADD`, `SUB`, `MUL` and `END` are working correctly. You will receive another point if the rest of the commands, which are used to implement loops, also work.

Below are some examples, which you may also use for testing. Example 1:

Expand Down

0 comments on commit e8e5846

Please sign in to comment.