Now, first, let’s create a custom class named Array which implements all the above functionalities in it.
So now let’s define a constructor using init method in Python which accepts 2 arguments along with the self-object that is the size and the default value for Array elements.
Here, size is defined which is the static size of the array and the default value means the value assigned to elements while creating a new array.
Now what we need is that if the size is only initialized then we must initialize all elements to default Value that is None.
Otherwise, if both parameters are initialized, then initialize the list with these values the user passed as an argument.
If the length of the default value list is less than size, then initialize other elements to “None”.
If the length of the list passed is greater than size user passed then simply return the program with the error message “Elements are more than the size specified”.
This function is used to return the length of the Array that means the elements we initialized excluding None values from it.
This function is used to insert or add the element to the beginning of the array.
This function is used to insert or add an element at a particular index or position which the user passed along with the element to insert.
This function is used to insert or add an element after a particular index or position which the user passed along with the element to insert.
This function is used to insert or add an element before a particular index or position which the user passed along with the element to insert.
This function is used to remove or delete a particular element from our array or if not present then simply print the error that the element is not found in this array.
This function is used to search or find the element which is passed by the user to return the index or position.
Now, we have implemented all the functions of our custom Array class.
So, now what we need is to check whether the functionality of these methods are working or not.
For that, create an instance of the Array Class and initialize it with array size and the values it needs to insert at the beginning.
Then, just use the object to call all the functions one by one.