HelpContactFor teachers and institutes
>_StemPy Lab
Mock TestsClasses

>_StemPy Lab

Learn. Solve. Code the solutions. Test yourself.

Live examsFree mock exams, timed and rankedEveryone starts together, and your score and rank come the moment it ends.See the exams →
Live examsInternational live exams are comingTell us which exam you want first. Timed practice papers are open now.See what is coming →

Learn

  • Physics
  • Chemistry
  • Mathematics
  • Biology
  • Python Programming
  • Statistics & Data Science
  • Computer Science
  • Space Science and Astronomy
  • Earth and Environmental Science
  • Classes
  • Groups

Practice

  • Problems
  • Quizzes
  • Mock Tests
  • Prepare for an Exam
  • Question Sets
  • Exams
  • Certificates
  • Python Labs
  • AI Practice Generator
  • Student-Created Tests

Community

  • Discussions
  • Resources
  • Notes
  • Glossary
  • Blog

Account

  • Log in
© 2026 senLearn. All rights reserved.HelpFor SchoolsAboutContactPrivacy PolicyTerms of UseRefund Policy
  1. Quizzes
  2. /A class defines __len__, and its objects are then used as True or False. What does the program print?
Python ProgrammingHardHigh School (11–12)Python Going Further › Inheritance and Special MethodsPCAP (Python Institute)
+2 more exams
A-LevelIB
A-LevelIBPCAP (Python Institute)
StemPy LabCreated by StemPy Lab

A class defines __len__, and its objects are then used as True or False. class Queue: def __init__(self, *items): self.items = list(items) def __len__(self): return len(self.items) q1, q2 = Queue(), Queue(0) print(bool(q1), bool(q2), len(q2) and "busy" or "idle") What does the program print?

Log in to save
← All Quizzes
← Prices are kept in cents. The class gives __lt__ and __repr__, but not __eq__. What does the program print?A list holds a Shape, a Circle and a number. The program counts its objects in two different ways. What does the program print? →
More onPython Going Further › Inheritance and Special Methods

Discussion (0)

Log in to join the discussion.

Loading…

More questions on this topic

  1. Three classes form a chain. Each one sets its own rate, and Premium extends the cost method with…Hard
  2. A class defines __add__ but not __iadd__. A second name points to the first object before += is…Hard
  3. A thermometer reading should turn into text through its own special method. The method gives back…Hard
  4. The class Plane has two base classes, Wing and Tail. Both set the class variable mark, and only…Hard
  5. A list holds a Shape, a Circle and a number. The program counts its objects in two different ways.…Hard
All questions on this topic →

Problems on this topic

  1. For each pair, say whether you would use inheritance (is a) or composition (has a), and why…Easy
  2. A class Note has an attribute rupees. Write __lt__ and __str__ so that sorted puts a list of notes…Medium
  3. For each line of code, name the special method that Python calls…Easy
  4. The loop below works for any animal. Add a class Bird that says Tweet, and a class Parrot built on…Medium
All problems on this topic →