🎙 Free live masterclass · Sun, 29 Nov, 7:00 pm IST · Java Full Stack roadmap Register free →
Skills101
← Quiz: Python OOP: all 15 questions

Quiz: Python OOP · Question 10 of 15

What does this print? (code)

What does this print?

class C:
    def __len__(self):
        return 7
print(len(C()))
  1. A.7
  2. B.0
  3. C.An error
  4. D.None
Answer & explanation

Correct answer: 7

len() calls the object's len method.

Can you get the rest right without peeking?

Take the timed Quiz: Python OOP quiz free. Pass it to earn XP and count towards your certificate.

Start the quiz →