हिंदी

Give the statement to assign a value "Hello" to the attribute str of class Test and object T1.

Advertisements
Advertisements

प्रश्न

Give the statement to assign a value "Hello" to the attribute str of class Test and object T1.

अति संक्षिप्त उत्तर
Advertisements

उत्तर

setattr(T1, "str", "Hello")

To create/set str as a class attribute shared by all objects, use:

setattr(Test, "str", "Hello")
shaalaa.com
  क्या इस प्रश्न या उत्तर में कोई त्रुटि है?
अध्याय 3: Classes in Python - EXERCISE [पृष्ठ ६३]

APPEARS IN

सीबीएसई Computer Science with Python [English] Class 12
अध्याय 3 Classes in Python
EXERCISE | Q 16. b. | पृष्ठ ६३
Share
Notifications

Englishहिंदीमराठी


      Forgot password?
Use app×