🎙 Free live masterclass · Sun, 29 Nov, 7:00 pm IST · Java Full Stack roadmap Register free →
Skills101
← 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)
  1. A.30
  2. B.An error, because f must be called as f()
  3. C.86.0
  4. 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 →