![]() |
VOOZH | about |
Below are some more useful functions provided in Python for arrays:
This function returns the data type by which the array is initialized. In this example, we are using arr.typecode to find out the data type of array initialization.
The datatype of array is : i
This function returns the size in bytes of a single array element. In this example, we are using itemsize function to find out the size in byte of an array element.
The itemsize of array is : 4
Returns a tuple representing the address in which array is stored and number of elements in it. In this example, we are using buffer_info() to do the same.
The buffer info. of array is : (140491260368688, 6)
Python count() function counts the number of occurrences of argument mentioned in array.
This function appends a whole array mentioned in its arguments to the specified array. In this example, we are using extend() to append another array.
The modified array is : 1 2 3 1 2 5 1 2 3
This function is used to append a list mentioned in its argument to end of array. In this example, we are using fromlist() to append a list to end of array.
The modified array is : 1 2 3 1 2 5 1 2 3
This function is used to transform an array into a list. In this example, we are using tolist() to convert an array to list.
The new list created is : 1 2 3 1 2 5