How do `a * b`, `a.__mul__(b)` and `Fraction.__mul__(a, b)` all run the same code, and why is only the last handed `self` by hand?
Short drills on what this video just taught. Write the code, run the checks, and reveal the answer only if you are stuck.
Fraction what the star meansThe Fraction class below can build itself and print itself, but a * b currently fails — nothing in the class says what a star between two fractions should mean.
Add __mul__, the method Python runs behind the * shorthand, so that multiplying two fractions multiplies the numerators, multiplies the denominators, and hands back a new Fraction object rather than a float. Then multiply a, which is 2/5, by b, which is 3/7, and assign the result to product.