← 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()))
- A.7
- B.0
- C.An error
- 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 →