मराठी

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×