Select true statements about class attributes and instance attributes. (select two)

Questions & AnswersCategory: PythonSelect true statements about class attributes and instance attributes. (select two)
Lokesh Kumar Staff asked 2 years ago

Select true statements about class attributes and instance attributes. (select two)
a. A class attribute is a variable that is defined in the __init__() constructor using self and belongs to one and only one instance. This variable is only available in the scope of this instance.
b. A class attribute is a variable that is defined directly in the class and belongs to the class, not to a specific instance. A class attribute is shared by all instances of that class.
c. An instance attribute is a variable that is defined in the __init__() constructor using self and belongs to one and only one instance. This variable is only available in the scope of this instance.
d. An instance attribute is a variable that is defined directly in the class and belongs to the class, not to a specific instance. A class attribute is shared by all instances of that class.

1 Answers
Lokesh Kumar Staff answered 2 years ago

b. A class attribute is a variable that is defined directly in the class and belongs to the class, not to a specific instance. A class attribute is shared by all instances of that class.
c. An instance attribute is a variable that is defined in the __init__() constructor using self and belongs to one and only one instance. This variable is only available in the scope of this instance.