← Quiz: Magic Methods and Properties: all 10 questions
Quiz: Magic Methods and Properties · Question 7 of 10
What does this print? (code)
What does this print?
class T:
def __init__(self):
self._c = 30
@property
def f(self):
return self._c * 9 / 5 + 32
print(T().f)
- A.30
- B.An error, because f must be called as f()
- C.86.0
- D.None
Answer & explanation
Correct answer: 86.0
A property is read like an attribute, without brackets.
Can you get the rest right without peeking?
Take the timed Quiz: Magic Methods and Properties quiz free. Pass it to earn XP and count towards your certificate.
Start the quiz →