Classes

What is a class?

A class is a structure that allows you to combine the functionality and data associated with a specific task. Many external libraries are written as classes, so learning to work with classes makes working with many existing projects easier.

What are attributes and methods?

Attributes are the variables of a class and methods are the functions of a class.

What is an instance?

An instance is an object of a class. You can make as many instances as you want from a single class.

What can you do with a class?

Classes can be used to represent abstract ideas or real-world objects. For example, you might use a class to represent a website user. The class would have attributes associated with the user's username, password, registration date, and more. Methods would define the actions the user could take, like authenticating, logging in and out, and registering. You could then make one instance for each user who registers on the site.