Skip to content

Commit 45e3d60

Browse files
committed
Corrected and modified instruction appends per forum post 59962.
1 parent d8886ca commit 45e3d60

2 files changed

Lines changed: 21 additions & 9 deletions

File tree

exercises/practice/grade-school/.docs/instructions.append.md

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,6 @@
33
## How this exercise is structured for the Python track
44

55
The tests for this exercise expect your solution to be implemented as a School `class` in Python.
6-
If you are unfamiliar with `class`es in Python, [concept:python/classes]() and [classes][classes in python] (_from the Python docs_) are good places to start.
7-
6+
If you are unfamiliar with `class`es in Python, [concept:python/classes]() and [`classes` in the official Python documentation][classes in python] are good places to start.
87

98
[classes in python]: https://docs.python.org/3/tutorial/classes.html

exercises/practice/relative-distance/.docs/instructions.append.md

Lines changed: 20 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -3,10 +3,10 @@
33
## How this exercise is structured for the Python track
44

55
The tests for this exercise expect your solution to be implemented as a RelativeDistance `class` in Python.
6-
If you are unfamiliar with `class`es in Python, [concept:python/classes]() and [classes][classes in python] (_from the Python docs_) are good places to start.
6+
If you are unfamiliar with `class`es in Python, [concept:python/classes]() and [`classe`s in the official Python documentation][classes in python] are good places to start.
77

88

9-
`RelativeDistance` should be initialized (_see [__init__()][init] for more information_)_ using `family_tree`, a dictionary where the `keys` are individuals and `values` are `list`s of that individual's children.
9+
`RelativeDistance` should be initialized (_see [`__init__()`][init] for more information_)_ using `family_tree`, a dictionary where the `keys` are individuals and `values` are `list`s of that individual's children.
1010
You will also need to implement a `degree_of_separation` [method][methods] which will return the degree of separation between `person_a` and `person_b` who are individuals in the passed-in family tree.
1111

1212

@@ -17,20 +17,33 @@ Then you can add your logic to the `degree_of_separation` method to calculate th
1717

1818
## Exception messages
1919

20-
Sometimes it is necessary to [raise an exception](https://docs.python.org/3/tutorial/errors.html#raising-exceptions).
20+
Sometimes it is necessary to [raise an exception][raising-exceptions].
2121
When you do this, you should always include a **meaningful error message** to indicate what the source of the error is.
2222
This makes your code more readable and helps significantly with debugging.
23-
For situations where you know that the error source will be a certain type, you can choose to raise one of the [built in error types](https://docs.python.org/3/library/exceptions.html#base-classes), but should still include a meaningful message.
23+
For situations where you know that the error source will be a certain type, you can choose to raise one of the [built in error types][base-error-classes], but should still include a meaningful message.
2424

25-
This particular exercise requires that you use the [raise statement](https://docs.python.org/3/reference/simple_stmts.html#the-raise-statement) to "throw" multiple `ValueError`s.
25+
This particular exercise requires that you use the [raise statement][raise-statement] to "throw" multiple `ValueError`s.
2626
In the first scenario, you will need to raise a `ValueError` when either one or both of the people passed to the `RelativeDistance.degree_of_separation` method are not present in the family tree.
27+
28+
```python
29+
# Example when Person A is not in the tree.
30+
raise ValueError("Person A not in family tree.")
31+
```
32+
2733
If both people are present in the family tree, you will need to raise a `ValueError` when there is no valid connection between them as defined by the rules.
28-
The tests will only pass if you both `raise` the expected `exception` type and include the expected message with it.
2934

30-
Please check the tests and their expected results carefully, as these instructions are not exhaustive.
35+
```python
36+
# Example when there are no valid connections.
37+
raise ValueError("No connection between person A and person B.")
38+
```
3139

40+
The tests will only pass if you both `raise` the expected `exception` type and include the expected message with it.
41+
Please check the tests and their expected results carefully, as these instructions are not exhaustive.
3242

43+
[base-error-classes]: https://docs.python.org/3/library/exceptions.html#base-classes
3344
[classes in python]: https://docs.python.org/3/tutorial/classes.html
3445
[init]: https://docs.python.org/3/reference/datamodel.html#object.__init__
3546
[methods]: https://docs.python.org/3/tutorial/classes.html#class-definition-syntax
47+
[raising-exceptions]: https://docs.python.org/3/tutorial/errors.html#raising-exceptions
48+
[raise-statement]: https://docs.python.org/3/reference/simple_stmts.html#the-raise-statement
3649
[special-methods]: https://docs.python.org/3.11/reference/datamodel.html#special-method-names

0 commit comments

Comments
 (0)