Python Classroom notes 30/Jun/2026

Inheritence (is-a)

  • This represents is-a relationship.
  • Here we have two classes
    • Parent/Super class
    • Child/Sub class
  • As part of inheritence the sub class gets access to capabilities and contents as well

Defining a class in Python

  • A class in python is defined by the following syntax
class <Name>:
    ...
    ...
    ...

  • The Name of Class should be pascal cased
  • In a Class
    • Capabilities will become methods which are functions
    • contents will become members/attributes which are variables
  • In python class we have 3 types of methods
    • Class methods
    • Instance Methods
    • Static methods
  • In python class we have 2 types of members

    • Class members
    • instance members
  • Lets focus on instance methods and instance members

  • Any object will be created from class and while creating it, it uses initialization

  • Note: in python whenever there is any function or variable with dunder (double underscore) around it, it has special purpose
  • Prompt:
Give me a tabular representation of all dunder members and methods with usage according to importance or frequency of usage
  • for initialization we use a function
def __init(self, <params>):
    # instance member
    self.<name> = param

  • A instance method is a python function with self that represent current object as its first argument
  • Refer Here for notebook

By continuous learner

enthusiastic technology learner

Leave a Reply

Discover more from Direct AI Powered By Quality Thought

Subscribe now to keep reading and get access to the full archive.

Continue reading