This notebook contains an excerpt from the Python Programming and Numerical Methods - A Guide for Engineers and Scientists, the content is also available at Berkeley Python Numerical Methods.

The copyright of the book belongs to Elsevier. We also have this interactive book online for a better learning experience. The code is released under the MIT license. If you find this content useful, please consider supporting the work on Elsevier or Amazon!

# Chapter 7. Object Oriented Programming (OOP)¶

## Motivation¶

As demonstrated earlier, often we need to use other packages, such as scipy, numpy, or other domain specified packages. When you check the source code of these packages, you may see new keywords in the code, such as class. What are classes and why do we use them? This is a new programming paradigm - Object-Oriented Programming (OOP) that is commonly used in writing large programs or packages. When writing a large program, OOP has a number of pluses: it simplifies the code for better readability, better describes the end goal of the project, is reusable, and reduces the number of potential bugs in the code. Given these features, you will see OOP in most of the standard packages in the field. Understanding its basics will help you write better code. This chapter introduces the basics of OOP, with emphasis on the core components: object, class, and inheritance, . Python is a highly object-oriented programming language and understanding these concepts will help you program with a minimum amount of headaches.