ARRAY IN PYTHON PROGRAMMING

in #code4 years ago

Everyone must have known about the definition of array which is basically a data structure used to store the data of the same type. For example: you can store array of integer data type or array of string data type. To work with array in the python you need to import the array module into your program. The code for this is from array import * so that you can work with all the array functionalities.

Syntax for Array declaration:

Array_name= array(typecode,[Array_Value]). Typecode means the data type the array is used to store. A simple exam would be like this:

value=array('i',[4,65,23,66]). Here I am storing the data of only integer type and I have specified it with typecode 'i'.

Here's the simple program working with the array, eventhough there are many more operations you can perform with array like reversing, appending, removing and so on.

from array import *
value=array('i',[4,65,23,66])

print(value)


# Printing the address and array size
print(value.buffer_info())

#Printing values of the array 

for i in range(4):
    print(value[i])
   

The output is:

Screenshot_3.png

Sort:  

Upvoted by GITPLAIT!

We have a curation trial on Hive.vote. you can earn a passive income by delegating to @gitplait
We share 80 % of the curation rewards with the delegators.


To delegate, use the links or adjust 10HIVE, 20HIVE, 50HIVE, 100HIVE, 200HIVE, 500HIVE, 1,000HIVE, 10,000HIVE, 100,000HIVE


Join the Community and chat with us on Discord let’s solve problems & build together.