Python Reading
- Read the chapter entitled Classes and Objects - Digging Deeper: from section "Sameness" to section "Arithmetic Methods"
- Class Lecture
- Shallow Equality occurs when two variables refer to the same object in the computer's memory. The python keyword is tests for shallow equality.
- Deep Equality occurs when either there is shallow equality OR two variables refer to objects that contain the same underlying (significant) values.
- The method __add__(self, other) can be defined so that the operator + can be used.
- Consider dungeons.py.
- Draw a picture that demonstrates shallow equality of two Humans.
- Modify the program above to demonstrate your understanding of shallow equality using the Python keyword is.
- Draw a picture that demonstrates deep equality of two Humans.
- Modify the program above to add a function that illustrates your understanding of deep equality.
- Modify fraction.py to use method __add__(self, other_fraction) instead of method add(self, other_fraction) as shown in class lecture.
- Modify fraction.py to use method __mul__ method and the __truediv__ method and add an option to print the answer (instead of overriding the value in fraction 1 or fraction 2.