Can we use python built-in Fraction class in order to convert "3.14" to 157/50 ?
Can you define exactly what should int() method return? Is it supposed round towards zero? What about negatives?
Should we assume that the input is valid in terms of non-zero denominator, or should we check it?
Technically - both would work.
Logically, what do you think is more appropriate? Other students are of course welcome to comment as well.
IMO, it depends on the purpose of the method.
If it will be used only in Rational class then it should be within it.
Since that in this HW we are not writing lots of code that will be used by other developers, all methods should be part of the class.
Usually, to follow good design and readable code, all methods that change the state of the Class object, or/and operate on its internal( public or private ) should be inside the class.
In 1.d. can someone enter "3" or should we assume that it would be "3.0"?
in section 4 - it says that the object to the right of the operator can be both Rational or Int, should I assume that the object to the left has to be Rational?
In 4, the left operand will always be Rational, that's how these methods are defined. ( Left operand - Rational , Right operand - Rational or int). The case of the left operand not being a Rational is handled in section 5.
in 5, there is no point in specifying that the left operand can be a Rational, because if it is, the add function of that Rational will be called and the operation will be valid anyway. Therefore all the 'r…' methods should just handle int.