Chapter 1 of 8: Before the lecture
Bell derives cat, person and rabbit subclasses from one animal class, then overloads + so rabbits can mate.
Inheritance in Python lets a subclass take the data and methods of a parent class, then override or extend them. Bell opens session 18 of MIT's introductory Python course by recapping getters and setters, then builds and debugs lists and dictionaries of objects. From an animal class she derives a cat subclass that overrides the string method and speaks, and a person subclass with a friend list. A class variable keeps a shared counter across rabbit instances, and the __add__ and __eq__ methods model mating and relationships. The material assumes basic Python syntax, including functions and dictionaries, and a first acquaintance with classes.
Inheritance in Python lets a subclass take the data and methods of a parent class, then override or extend them. Bell opens session 18 of MIT's introductory Python course by recapping getters and setters, then builds and debugs lists and dictionaries of objects. From an animal class she derives a cat subclass that overrides the string method and speaks, and a person subclass with a friend list. A class variable keeps a shared counter across rabbit instances, and the __add__ and __eq__ methods model mating and relationships. The material assumes basic Python syntax, including functions and dictionaries, and a first acquaintance with classes.

This lecture
Lecture 18 of 25 of Introduction to Computer Science and Programming using Python.
Choose a node to see how it connects to this lecture. What comes before is on the leftat the top. What comes after is on the rightat the bottom. The ring is what it teaches. People and places are above.
Press a chosen node again to open it.
Your comment is kept while you sign up.Sign in