LinkedIn Python Skill Assessment Quiz Answers

What is the purpose of the self keyword when defining or calling methods on an instance of an object?

Latest Update on 25th January, 2022 by Certification Course Answers

What is the purpose of the self keyword when defining or calling methods on an instance of an object?

  1.  self refers to the class that was inherited from to create the object using self.
  2.  There is no real purpose for the self method. It’s just legacy computer science jargon that Python keeps to stay consistent with other programming languages.
  3.  self means that no other arguments are required to be passed into the method.
  4.  self refers to the instance whose method was called.

Correct Answer:

  •  self refers to the instance whose method was called.

Explanation: – Try running the example of the Q45 without passing self argument inside the __init__, you’ll understand the reason. You’ll get the error like this __init__() takes 0 positional arguments but 1 was given, this means that something is going inside even if haven’t specified, which is instance itself.

Latest Updates

No posts found in this category.