πŸ“Š Python
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'
πŸ’¬ Discuss
βœ… Correct Answer: (B) @property def name(self): return self._name

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

Explanation by: Mr. Dubey
The @property decorator is used to define getter methods as attributes.

πŸ’¬ Discussion


πŸ“Š Question Analytics

πŸ‘οΈ
61
Total Visits
πŸ“½οΈ
11 mo ago
Published
πŸŽ–οΈ
Mr. Dubey
Publisher
πŸ“ˆ
85%
Success Rate