...

/

Classes and Inheritance

Classes and Inheritance

In this lesson, you'll learn about the concepts of classes and inheritance in Python.

Class definition

A class describes a new type of object and bundles together the methods needed to work with objects of that type. Here is an analogy: a class is like a cake recipe, while objects are the cakes you can make by following the recipe.

Defining a class

The syntax for defining a class is

class ClassName(superclass):
 variable and method definitions

Introduction to inheritance

Every class (except the object class) has a superclasssuperclass, and it inherits variables and methods from that superclass. That is, all variables and methods defined in ...