Skip to content

A2a - Introduction to Objects

An object in computer science is similar to a real life object. They can have:

  • Attributes - Characteristics that describe the object
  • Methods - Things the object can do
  • More objects

The naming conventions for each of these are the same as for variables (all lowercase letters, can have numbers and underscores, descriptive). Method names are usually verbs (action words), and we put a set of parentheses after them: ()

If I consider myself as an object:

  • Some of my attributes are last_name, hair_color
  • Some of my methods are eat(), run()
  • Some of my objects are car, microwave

My attributes can be treated like regular Python variables, but since they belong to me, I use the following dot notation:

self.last_name = "Stewart"
self.hair_color = "brown"

I use a similar dot notation to call my methods:

self.eat()
self.run()

Now, let's consider one of my objects: car. Suppose it has an attribute called color and a method called turn_right(). I can use the following dot notation to access these:

self.car.color = "white"
self.car.turn_right()

Your Task

This is not a programming assignment. You will complete it in a Google Doc.

  • Click here to make a copy of the assignment template in your Google Drive.
  • Click here to see a completed sample of the assignment, which should help clarify most confusion

When you are done, please move your completed Google Doc into the Remote folder within the Google Drive folder you're using for this course.