Using OOP
OOP is a way to structure data into objects. The Python program is an object-oriented program in that it structures algorithms as objects in order to bundle them based on properties and behaviors. To learn about OOP, we will need to know how to do the following:
- Create classes
- Use classes to create objects
- Use class inheritance to model systems
In Python, we use classes to bundle data. To understand classes, let’s create one:
class Books:pass
Before we begin, let’s address pass and why we use it. If we had a Python file with this code and no pass statement, we would receive the following error:
unexpected EOF while parsing
That’s because we created a class with no content inside of it. Sometimes, we want to create our class and add the content later, but we want to be able to run our code. Adding pass allows us to do that without causing an error and breaking our program. In essence, it tells the program that it should...