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
The tests for this exercise expect your school roster will be implemented via a School `class` in Python.
4
-
If you are unfamiliar with classes in Python, [classes][classes in python] from the Python docs is a good place to start.
3
+
## How this exercise is structured for the Python track
4
+
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
+
5
8
6
9
[classes in python]: https://docs.python.org/3/tutorial/classes.html
## How this exercise is structured for the Python track
4
4
5
-
The tests for this exercise expect your solution to be implemented as a `RelativeDistance` class in Python.
6
-
Your `RelativeDistance` class should be initialized using `family_tree`, a dictionary where the keys are individuals and the values are lists of that individual's children.
7
-
You will also need to implement a `degree_of_separation` method which will return the degree of separation between `person_a` and `person_b` who are individuals in the family tree.
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.
8
7
9
-
If you are unfamiliar with classes in Python, here is a brief overview of how to implement the `RelativeDistance` class:
10
8
11
-
A class is a blueprint for creating objects, bundling attributes (data) and methods (functionality) together.
12
-
In this exercise, you are given stubbed implementations for the `__init__` special method used to create an instance of the `RelativeDistance` class as well as the `degree_of_separation` method.
13
-
To access the `family_tree` data from within the `degree_of_separation` method, you will need to first assign it within the `__init__` method to an appropriate attribute on `self`, which represents the current instance of the `RelativeDistance` class.
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
+
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
+
12
+
13
+
You are given a stubbed implementation for the `__init__`[special method][special-methods] used to create an instance of the `RelativeDistance` class, as well as a stub of the `degree_of_separation` method.
14
+
First, you will need to customize the `__init__` with an appropriate attribute on `self` (_the instance_) to represent the `family_tree` data.
14
15
Then you can add your logic to the `degree_of_separation` method to calculate the degree of separation between `person_a` and `person_b`.
15
16
17
+
16
18
## Exception messages
17
19
18
20
Sometimes it is necessary to [raise an exception](https://docs.python.org/3/tutorial/errors.html#raising-exceptions).
@@ -25,4 +27,10 @@ In the first scenario, you will need to raise a `ValueError` when either one or
25
27
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.
26
28
The tests will only pass if you both `raise` the expected `exception` type and include the expected message with it.
27
29
28
-
Please check the tests and their expected results carefully.
30
+
Please check the tests and their expected results carefully, as these instructions are not exhaustive.
31
+
32
+
33
+
[classes in python]: https://docs.python.org/3/tutorial/classes.html
0 commit comments