मराठी

Is an object of a class mutable? Why/why not?

Advertisements
Advertisements

प्रश्न

Is an object of a class mutable? Why/why not?

लघु उत्तर
Advertisements

उत्तर

Yes. A class object (instance) is generally mutable because its attributes can be added, modified or deleted after the object is created.

student.name = "Aman"   # Add/modify an attribute
del student.name         # Delete an attribute

The object's namespace changes; therefore, the object is mutable.

shaalaa.com
  या प्रश्नात किंवा उत्तरात काही त्रुटी आहे का?
पाठ 3: Classes in Python - EXERCISE [पृष्ठ ६२]

APPEARS IN

सीबीएसई Computer Science with Python [English] Class 12
पाठ 3 Classes in Python
EXERCISE | Q 5. | पृष्ठ ६२
Share
Notifications

Englishहिंदीमराठी


      Forgot password?
Use app×