CertGrid CertGrid
Concepts·Certified Associate Python Programmer

Python Classes and Objects

PCAP objective 4.1 is understand the object-oriented approach, and it is the start of the 34% of that exam PCEP never mentions. A class is a template; an instance is a thing made from it. Both are objects, both have a `__dict__`, and attributes can be added to an instance from outside the class entirely - which is unusual, and which several later questions depend on.

Object-Oriented Python Guide 12 of 25 Intermediate

Written against the versions above. Every class in Python 3 is a new-style class inheriting from `object`, whether you say so or not - `class Dog:` and `class Dog(object):` are identical. Older material that distinguishes them is describing Python 2.

One machine, and any shell with Python 3 will do - these exams test the language, not a distribution.
Server NameIP AddressOSRolesCPURAMHDD
RUNNER01192.168.0.27Ubuntu 26.04 LTSPython 3.14.4 - the only machine this path needs2 Core4 GB50 GB

Before you start

  1. The smallest class

  2. Attributes can be added from outside

  3. Asking for an attribute that is not there

  4. What an object prints as by default

  5. __str__ and __repr__

  6. A class with data and behaviour

  7. What the exam does with this objective

Official sources