HelpContactFor teachers and institutes
>_StemPy Lab
Mock TestsClassesGroups

>_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 →

Learn

  • Physics
  • Chemistry
  • Mathematics
  • Biology
  • Python Programming
  • Statistics & Data Science
  • Classes
  • Groups

Practice

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

Community

  • Discussions
  • Resources
  • Notes
  • Blog

Account

  • Dashboard
  • My Content
  • Profile
  • Log in
© 2026 senLearn. All rights reserved.HelpAboutContactPrivacy PolicyTerms of UseRefund Policy
  1. Problems
  2. /Python Going Further
  3. /Inheritance and Special Methods

Inheritance and Special Methods

Python Programming
+ Upload a Problem
More in Python Going FurtherClasses and ObjectsInheritance and Special MethodsFiles and Data FormatsComprehensions, Iterators and GeneratorsData StructuresTesting and Debugging
7 problems
Type:
1.
For each pair, say whether you would use inheritance (is a) or composition (has a), and why.
High School (11–12), High School (9–10), Undergraduate, General · Inheritance and Special Methods, Classes and ObjectsStemPy LabStemPy Lab
Easy
2.
A class Note has an attribute rupees. Write __lt__ and __str__ so that sorted puts a list of notes…
High School (11–12), High School (9–10), Undergraduate, General · Inheritance and Special Methods, Classes and ObjectsStemPy LabStemPy Lab
Medium
3.
For each line of code, name the special method that Python calls.
High School (11–12), High School (9–10), Undergraduate, General · Inheritance and Special Methods, Classes and ObjectsStemPy LabStemPy Lab
Easy
4.
The loop below works for any animal. Add a class Bird that says Tweet, and a class Parrot built on…
High School (11–12), High School (9–10), Undergraduate, General · Inheritance and Special Methods, Classes and ObjectsStemPy LabStemPy Lab
Medium
5.
Who says what?
High School (11–12), High School (9–10), Undergraduate, General · Inheritance and Special Methods, Classes and ObjectsStemPy LabStemPy Lab
Easy
6.
A Dog object has no name. Find the reason and fix the class.
High School (11–12), High School (9–10), Undergraduate, General · Inheritance and Special Methods, Classes and ObjectsStemPy LabStemPy Lab
Medium
7.
Given these classes, say what each line shows.
High School (11–12), High School (9–10), Undergraduate, General · Inheritance and Special Methods, Classes and ObjectsStemPy LabStemPy Lab
Easy