Help
Contact
For teachers and institutes
Search courses, problems, tests…
A
A
>_
StemPy Lab
Courses ▾
Problems ▾
Practice ▾
Mock Tests
Classes
Groups
Community ▾
A
A
Problems
/
Python Going Further
/
Inheritance and Special Methods
Inheritance and Special Methods
Python Programming
+ Upload a Problem
More in Python Going Further
Classes and Objects
Inheritance and Special Methods
Files and Data Formats
Comprehensions, Iterators and Generators
Data Structures
Testing and Debugging
All Levels
High School (9–10)
High School (11–12)
Undergraduate
General
All
Easy
Medium
Sort
Mixed
Newest first
Oldest first
A to Z
7 problems
Type:
Any
Conceptual
Python-Coded
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 Objects
StemPy 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 Objects
StemPy 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 Objects
StemPy 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 Objects
StemPy Lab
Medium
5.
Who says what?
High School (11–12), High School (9–10), Undergraduate, General · Inheritance and Special Methods, Classes and Objects
StemPy 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 Objects
StemPy 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 Objects
StemPy Lab
Easy