Class-Docstring

Wed 12 November 2025
#  created : 20250113
#  https://www.scientecheasy.com/2022/09/docstring-in-python.html/
#  class docstring
class Rectangle:
    """
    This is a class for calculating the area of a rectangle.

        Parameters:
        l (int) : The length of rectangle.
        b (int) : The breadth of rectangle.
    """
print(Rectangle.__doc__)
    This is a class for calculating the area of a rectangle.

        Parameters:
        l (int) : The length of rectangle.
        b (int) : The breadth of rectangle.
# We can also read docstring using the syntax help()
def get_square(x):
    "This is a method for calculating the square of a number."
    return x * x # It will calculate the square of a number and return the output.
help(get_square)
Help on function get_square in module __main__:

get_square(x)
    This is a method for calculating the square of a number.
get_square(5)
25
def num(a,b):
    return a*b
num(10,90)
900
help(num)
Help on function num in module __main__:

num(a, b)


Score: 10

Category: python-basics