Learn
Classes
Class basics
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
Instructions
1.
Define a new class named “Car”. For now, since we have to put something inside the class, use the pass
keyword.