2 Modeling Physical Objects with Object-Oriented Programming

In this chapter, I’ll introduce the general concepts behind object-oriented programming. I’ll show a simple example program written using procedural programming, introduce classes as the basis of writing OOP code, and explain how the elements of a class work together. I’ll then rewrite the first procedural example as a class in the object-oriented style and show how you create an object from a class.

In the remainder of the chapter, I’ll go through some increasingly complex classes that represent physical objects to demonstrate how OOP fixes the problems of procedural programming ...

Get Object-Oriented Python now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.