An object is the value of, i.e., an instance of, a custom type. Yes, we get to create our own types beyond what is built-in in Python! Before you learn to create a custom type however, first you need to understand objects. We will look at how to create an object, how to access its attributes , and how to visualize it.
shapes
created specifically for this lecture
. Download this file
shapes.py
. Whenever the video mentions
introcs, as you follow along you should use
shapes
instead. For example, instead of typing
import introcs, you should type
import shapes
.
shapes
, not
introcs
from the video.)
shapes
, not
introcs
from the video.)
shapes
, not
introcs
from the video.)
Optionally, Read: 15.3 - 15.8
Slides: individual slides for viewing , 6-up layout for printing
Examples:
shapes.py
(same file as above posted with the lesson videos),
demoPoint3.py
To download the above files, right-click (Windows) or command-click (Macs) on the filename and then select "Save link as". This way you choose where the files will be saved, instead of having your computer save to the default folder (from which you will later have to move your files for organization).
Questions and Answers: check the answers — after you try them on your own!