Object-Oriented Programming in Python

Object-Oriented Programming (OOP) is a programming paradigm based on the concept of “objects,” which can contain data in the form of fields, also known as attributes, as well as code in the form of functions or procedures, referred to as methods. Python has been an object-oriented language since its inception.

Class

A class is a prototype, blueprint, or design that defines the variables and methods for specific objects. A class serves to encapsulate the contents of the program that will be executed, containing attributes (data types) and methods to run the program. In Python, a class is defined using the keyword class, followed by the class name, like this: class class_name. Calling a class is similar to calling a function/method in a program, by using the class name along with its parameters. Typically, a class contains many methods/functions that derive characteristics from that class.

Classes can take many forms in different programming languages, such as abstract classes, data classes, and so on. A class can also have relationships with other classes, referred to as derived classes or inheritance. Inheritance represents a relationship between a Parent Class (Super Class) and a Child Class (Sub Class), where the Child Class inherits properties and variables from the Parent Class.

MODULE

Download Module 11