Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 1 addition & 2 deletions exercises/practice/grade-school/.docs/instructions.append.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@
## How this exercise is structured for the Python track

The tests for this exercise expect your solution to be implemented as a School `class` in Python.
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.

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.

[classes in python]: https://docs.python.org/3/tutorial/classes.html
27 changes: 20 additions & 7 deletions exercises/practice/relative-distance/.docs/instructions.append.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,10 @@
## How this exercise is structured for the Python track

The tests for this exercise expect your solution to be implemented as a RelativeDistance `class` in Python.
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.
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.


`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.
`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.
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.


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

## Exception messages

Sometimes it is necessary to [raise an exception](https://docs.python.org/3/tutorial/errors.html#raising-exceptions).
Sometimes it is necessary to [raise an exception][raising-exceptions].
When you do this, you should always include a **meaningful error message** to indicate what the source of the error is.
This makes your code more readable and helps significantly with debugging.
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.
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.

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.
This particular exercise requires that you use the [raise statement][raise-statement] to "throw" multiple `ValueError`s.
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.

```python
# Example when Person A is not in the tree.
raise ValueError("Person A not in family tree.")
```

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.
The tests will only pass if you both `raise` the expected `exception` type and include the expected message with it.

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

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

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