Array Methods in Python
Naveen
- 0
Arrays are used to store multiple values in one single variable.
Array can be handled in Python by a module named array.
Type codes for different data types:
![](https://www.nomidl.com/wp-content/uploads/2022/09/type.png)
These codes are used while creating an array.
1 – Creating an Array
Array(data_type, value_list)
![](https://www.nomidl.com/wp-content/uploads/2022/09/image-83.png)
2 – Adding Element to Array
Insert() is used to insert one or more data element into an array.
![](https://www.nomidl.com/wp-content/uploads/2022/09/image-84.png)
3 – Accessing Element of Array
Use the index operator [ ] to access an item in a array.
![](https://www.nomidl.com/wp-content/uploads/2022/09/image-85.png)
4 – Removing Element of Array
Use the pop() to remove items from an array.
![](https://www.nomidl.com/wp-content/uploads/2022/09/image-86.png)
Popular Posts
Spread the knowledge