Objects and classes One of Python’s most important features is that it is an object-oriented language (see p.25). This means that data in Python can be arranged in terms of classes and objects, which allows users to have one blueprint from which multiple objects can be created.
SELECT Class Programmers use classes to classify related things together. This is done using the keyword “class”, which is a grouping of object-oriented constructs. Here, the class Car defines the form the objects below should have.
Object An object is an instance of a class, just like a real car is an instance of the concept of a car. A car object’s fields and methods would contain data and code for a particular instance of the class Car. So the object named “sports” would have a higher “max_speed” than the “sedan” object.
CAR
BICYCLE
SEDAN
SPORTS
Fields Fields contain data about an object. In this example, fields are likely to include values that might feature in a car simulator program, such as current_speed, max_speed, and fuel_level.
current_speed
max_speed
fuel_level