object-oriented programming
A style of programming that bundles data and the functions that work on it into objects built from classes.
In more detail
A class is the blueprint, an object one instance of it, a property the data an object holds and a method a function that belongs to the class. Encapsulation keeps data behind methods, and inheritance lets a subclass reuse and extend its superclass. It carries 34% of the PCAP-31-03 score.
Example
class Stack:
def __init__(self):
self.items = []
def push(self, v):
self.items.append(v)Related terms
- class — A blueprint in code that bundles data and the functions that work on it, from which objects are made.
- inheritance — Declaring one class or type as a specialised version of another, so it receives the parent's members and can be used wherever the parent is expected.
- encapsulation — Keeping a component's internal data and details behind a small public interface.
Taught in
- The Class That Shared One List — PCAP Certified Associate in Python Programming (PCAP-31-03) Exam Prep
- Sixty Five Minutes, Forty Items: How PCAP Is Run — PCAP Certified Associate in Python Programming (PCAP-31-03) Exam Prep
- Strings Sprint — PCAP Certified Associate in Python Programming (PCAP-31-03) Exam Prep
- Classes, Objects And Two Stacks — PCAP Certified Associate in Python Programming (PCAP-31-03) Exam Prep
- Special Methods: __str__, __eq__ And Friends — PCAP Certified Associate in Python Programming (PCAP-31-03) Exam Prep
- Object-Oriented Sprint — PCAP Certified Associate in Python Programming (PCAP-31-03) Exam Prep