Classes can be very useful for storing complicated objects with their own methods and variables. Defining a class is much like defining a function, but we use the class keyword instead. We also use the word object in parentheses because we want our classes to inherit the object class. This means that our class has all the properties of an object, which is the simplest, most basic class. Later we’ll see that classes can inherit other, more complicated classes. An empty class would look like this:

class ClassName(object): # class statements go here



Define a new class named “Car”. For now, since we have to put something inside the class, use the pass keyword.

Take this course for free

Mini Info Outline Icon
By signing up for Codecademy, you agree to Codecademy's Terms of Service & Privacy Policy.

Or sign up using:

Already have an account?