Free Trial

Safari Books Online is a digital library providing on-demand subscription access to thousands of learning resources.

  • Create BookmarkCreate Bookmark
  • Create Note or TagCreate Note or Tag
  • PrintPrint
Share this Page URL
Help

I. Learning to Program > 8. How to Use Classes and Objects

Chapter 8. How to Use Classes and Objects

Why is a giraffe like a sidewalk? Because both a giraffe and a sidewalk are things, known in the English language as nouns and in Python as objects.

The idea of objects is an important one in the world of computers. Objects are a way of organizing code in a program and breaking things down to make it easier to think about complex ideas. (We used an object in Chapter 4 when we worked with the turtle—Pen.)

To really understand how objects work in Python, we need to think about types of objects. Let’s start with giraffes and sidewalks.

A giraffe is a type of mammal, which is a type of animal. A giraffe is also an animate object—it’s alive.

image with no caption

Now consider a sidewalk. There’s not much to say about a sidewalk other than it’s not a living thing. Let’s call it an inani mate object (in other words, it’s not alive). The terms mammal, animal, animate, and inanimate are all ways of classifying things.


  

You are currently reading a PREVIEW of this book.

                                                                                                                    

Get instant access to over $1 million worth of books and videos.

  

Start a Free Trial


  
  • Safari Books Online
  • Create BookmarkCreate Bookmark
  • Create Note or TagCreate Note or Tag
  • PrintPrint