Fruit make it easy to understand the concepts of classes and instances, but you probably won’t see many zebras or lemons in real-world programs.
However, classes and objects are often used to model real-world objects. The code in the editor is a more realistic demonstration of the kind of classes and objects you might find in commercial software. Here we have a basic
ShoppingCart class for creating shopping cart objects for website customers; though basic, it’s similar to what you’d see in a real program.
Create an instance of
my_cart. Initialize it with any values you like, then use the
add_item method to add an item to your cart.