What is the output of the following Python code snippet?
class C:
@property
def pi(self): return 3.14
print(C().pi)
@property
def pi(self): return 3.14
print(C().pi)
Correct answer
D. 3.14
5 views
D. 3.14
5 views
A property can be accessed without parentheses.
Asked in: Python Interview OOP
https://docs.python.org/3/tutorial/classes.htmlNot sure why the answer is D? Ask here and get an explanation.