What makes `print(c)` show `<3,4>` instead of `<__main__.Coordinate object at 0x7f9c...>`?
Short drills on what this video just taught. Write the code, run the checks, and reveal the answer only if you are stuck.
Coordinate below is the class from the video, except that its __str__ still hands back an empty string, so printing a coordinate shows nothing at all.
Fill that body in so a coordinate is represented as an opening angle bracket, its x value, a comma, its y value, and a closing angle bracket — with nothing else in between. Leave the rest of the class exactly as it is. Recall that self.x holds an int and that str() casts a value to a string; an f-string does the job just as well.
A printable representation for Coordinate
Write the body concatenating an angle bracket, str(self.x), a comma, str(self.y) and a closing angle bracket, note that it returns a string rather than printing one, and trace print(c) giving <3,4>.
The Fraction representation and the denominator of 1
Write the body as str(self.num), a slash and str(self.denom), trace Fraction(3, 4), Fraction(1, 4) and Fraction(5, 1) printing 3/4, 1/4 and 5/1, then add the branch returning str(self.num) when self.denom == 1.
Types as objects, and isinstance
Record type(c) giving <class '__main__.Coordinate'> and type(Coordinate) giving <class 'type'>, and set isinstance(c, Coordinate) beside isinstance(3, int) as the alternative type check.