An interactive guide to Python object oriented programming

By Cedric Kim

Introduction

Let's say we want to create digital profiles for some people. For that, we can use Python and Python object-oriented programming.

Classes and Objects

To identify a person as, well, a person, we can create a class. In computer science, a class is a blueprint for an object. An object in computer science is an instance of a class. Here's an example:

ScienceTextbook = Book("Science Textbook", "Sciency stuff goes here");

Attributes

So, what are attributes? Let's say we have the class Fruit(). Apples and oranges are both fruits, but an apple is not the same as an orange. Attributes make the difference. For example, apple = Fruit(insert details about apples here).

Defining a class

Here's an example:


Click 'View App' to see the output. Get creative and make your own version by remixing this project on Glitch.com.

Copyright (c) Cedric Kim. Licensed under Creative Commons Attribution 4.0.