1. array (data type, list of values) : — This function is used to create an array with the data type and list of values specified in its arguments. Some of the data types are mentioned in the table below.
|Type Code||C Type||Python Type||Minimum size in Bytes|
|'B' td>||unsigned char||int||1|
|'u'||unicode character||2 >||'h'||signed short||2|
|unsigned short||= "amp-wp-inline-2f0158eb062d1ac553a7edcb8a744628"> 2|
|'i'-wp- inline-f74fb0de8d71e0cc53e95b25025d2853 "> signed int||int|
|'I'||unsigned intd intd = "amp-wp-inline-2f0158eb062d1ac553a7edcb8a744628"> int||2|
|'Q'||unsigned long long-wp-inline-2f0158eb062d1ac553a7edcb8a744628 "> int||8|
|'d' = " amp-wp-inline-2f 0158eb062d1ac553a7edcb8a744628 "> double||float|
2. append () : — This function is used to add the value specified in its arguments to the end of an array.
3. insert (i, x) : — This function is used to add a value to the position specified in its argument.
The new created array is: 1 2 3 The appended array is: 1 2 3 4 The array after insertion is: 1 2 5 3 4
4. pop () : — This function removes the element at the position specified in its argument and returns it.
5. remove () : — This function is used to remove the first occurrence of the value specified in its arguments.
The new created array is: 1 2 3 1 5 The popped element is: 3 The array after popping is: 1 2 1 5 The array after removing is: 2 1 5
6. index () : — This function returns the index of the first occurrence of the value specified in the arguments.
7. reverse () : — This function flips the array.
The new created array is: 1 2 3 1 2 5 The index of 1st occurrence of 2 is: 1 The array after reversing is: 5 2 1 3 2 1
This article courtesy of Manjit Singh .If you are as Python.Engineering and would like to contribute, you can also write an article using contribute.python.engineering or by posting an article contribute @ python.engineering. See my article appearing on the Python.Engineering homepage and help other geeks.
Please post comments if you find anything wrong or if you would like to share more information on the topic discussed above.