Home / CSE MCQs / Python MCQs :: Discussion

Discussion :: Python MCQs

  1. What is setattr() used for?
  2. A.
    To access the attribute of the object
    B.
    To set an attribute
    C.
    To check if an attribute exists or not
    D.
    To delete an attribute

    View Answer

    Workspace

    Answer : Option B

    Explanation :

    setattr(obj,name,value) is used to set an attribute. If attribute doesn't exist, then it would be created.


Be The First To Comment