Program - class to show implementation of static method


Topic: Program - class to show implementation of static method

Solution

class Mathematics:
    """
    This is the space to do documentation related to class.
    """
    def __init__(self, msg="Demo class of Mathematics"):
        self.msg = msg
    def __str__(self):
        return f' String representation of an object'
    def __repr__(self):
        return f' repr representation of an object with parameter {self.msg}'
    @staticmethod
    def addition(a: "Variable1", b: 'Variable2'):
        """
        @staticmethod makes the mtethod of class as static method.
        It is always recommended to metion it via decorator.
        """
        return a+b



List all Python Programs