You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: exercises/practice/grade-school/.docs/instructions.append.md
+1-2Lines changed: 1 addition & 2 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -3,7 +3,6 @@
3
3
## How this exercise is structured for the Python track
4
4
5
5
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.
8
7
9
8
[classes in python]: https://docs.python.org/3/tutorial/classes.html
Copy file name to clipboardExpand all lines: exercises/practice/relative-distance/.docs/instructions.append.md
+20-7Lines changed: 20 additions & 7 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -3,10 +3,10 @@
3
3
## How this exercise is structured for the Python track
4
4
5
5
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.
7
7
8
8
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.
10
10
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.
11
11
12
12
@@ -17,20 +17,33 @@ Then you can add your logic to the `degree_of_separation` method to calculate th
17
17
18
18
## Exception messages
19
19
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].
21
21
When you do this, you should always include a **meaningful error message** to indicate what the source of the error is.
22
22
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.
24
24
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.
26
26
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
+
raiseValueError("Person A not in family tree.")
31
+
```
32
+
27
33
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.
29
34
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
+
raiseValueError("No connection between person A and person B.")
38
+
```
31
39
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.
0 commit comments