+1 vote
in Class 11 by kratos

Answer the questions (i) and (ii) after going through the following class definition:

class Toy :

tid =0;

tcat = “ “

def init(self):// Function1

..................................... // Blank 2

(i) Explain relevance of Function 1.

(ii) (a) Fill in the blank 2 with a statement to create object of the class TOY.

(b) Write statement to check whether tprice is an attribute of class TOY.

1 Answer

+6 votes
by kratos
 
Best answer

(i) init function is used to initialize the members of a class. It is automatically invoked when the object of the class is created.

(ii) (a) T=Toy()

(b) hasattr(T,tprice)

...