Python Reading
- Read the chapter entitled Classes and Objects - Digging Deeper: from section "Fractions" to section "Objects are Mutable".
- Class Lecture
- A fraction can be implemented as a class. A fraction consists of two integers: a numerator and a denominator.
- An instance of a class is mutable.
- A mutator method is a method of a class that changes the values of one or more instance variables.
- Take a look at fraction.py.
- In the Fraction class, identify the instance variables.
- In the Fraction class, identify the constructor.
- For each method in the Fraction class, identify whether or not it is a mutator method.
- Trace what happens when the simplify method is called when the numerator value is 36 and the denominator value is 48.
- Explain why the add method is correct.
- Make sure you fully understand the fraction.py file.
- Add a multiply method to the program and test that it works properly.