πŸ“Š Python
Q. Which of the following will make `attr` a read-only property?
  • (A) @readonly def attr(self): return self._attr
  • (B) @property def attr(self): return self._attr
  • (C) @setter def attr(self): return self._attr
  • (D) @getter def attr(self): return self._attr
πŸ’¬ Discuss
βœ… Correct Answer: (B) @property def attr(self): return self._attr

Explanation: Using `@property` allows defining read-only properties without a setter.

Explanation by: Mr. Dubey
Using `@property` allows defining read-only properties without a setter.

πŸ’¬ Discussion


πŸ“Š Question Analytics

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