Classes and objects
Not met yet
A class is a pattern for making objects: class Bike: describes what every bike keeps and can do, and Bike(7, 4) makes one. Each object made from a class keeps its own attributes. Name a class for one thing, in CapitalisedWords: Bike, not bikes.
Try it
main.pyOutput
Press Run and what your program prints shows up here.
Easy to get wrong
- Thinks objects made from the same class share their attributes, so changing one changes them all.
- Thinks the class itself is one of the things it describes, so Parcel.weight works without making a parcel.