-
Book Overview & Buying
-
Table Of Contents
AI Crash Course
By :
Classes, like functions, are another part of code that sits outside of the main code, executed only when called in the main flow of code. Objects are instances of a corresponding class, existing within the main flow of our code. To better understand it, think of a class as a plan of something, for example, a plan of a car. It contains information on how certain components look and work with each other. A class in Python is a general plan of something.
You can think of objects as real-life constructions based on the plan. For example, a real, working, and self-driving car would be an example of an object. You create a plan of a car (which is a class) and then you build a car based on this plan (which is an object). And of course, when you have a plan of something, you can create as many copies as you want; for example, you can run a production line to produce cars.
To give you more insight into classes, we will create a simple bot....