A

Admin • 833.24K Points
Coach

Q. Which of the following defines a property in Python?

  • (A) def get_name(self): return self.name
  • (B) @property def name(self): return self._name
  • (C) name = get_name()
  • (D) self.name = 'abc'
  • Correct Answer - Option(B)
  • Views: 36
  • Filed under category Python
  • Hashtags:

Explanation by: Admin

The @property decorator is used to define getter methods as attributes.

You must be Logged in to update hint/solution

Discusssion

Login to discuss.

Be the first to start discuss.