From the course: Learning Python

Unlock the full course today

Join today to access over 23,200 courses taught by industry experts.

Classes

Classes

- Python is an object-oriented programming language. And this means that you can create and use your own classes. And classes are a really great way of encapsulating functionality that can be kept together and reused as complete modules in other projects. And this can be really helpful in keeping larger programs both maintainable and easier to understand. So let's open up the classes_start file. And let's imagine that we're building an application that manages vehicles, right, the cars and motorcycles and so on. So I'm going to start by defining a class that will hold some information about vehicles. So classes are defined using the class keyword, and then they're given a name. So I'll name my class vehicle. And then I'm going to use two empty parentheses, which are empty for now, but we'll see what those are used for in a moment and then a colon to begin the class scope. Now I need to add the method that gets called when…

Contents