The definition of a class is made by a block command with the keyword class, the name of the class, and some statements in the block (see Figure 8.1):
class RationalNumber: pass
An instance of this class (or in other words, an object of the type RationalNumber) is created by r = RationalNumber() and the query type(r) returns the answer, <class'__main__.RationalNumber'>. If we want to investigate whether an object is an instance of this class, we can use the following lines:
if isinstance(r, RationalNumber): print('Indeed, it belongs to the class RationalNumber')
So far, we have generated an object of the type RationalNumber that has no data yet. Furthermore, there are no methods defined to perform operations with these objects. This is the subject of the next sections.