ARRAY IN PYTHON PROGRAMMING
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:
Leave ARRAY IN PYTHON PROGRAMMING to:
Read more #code posts
Best Posts From Leo Umesh
We have not curated any of leoumesh's posts yet. But you can encourage our curation team to review posts by visiting them regularly and by referring other readers. Because we give priority to frequently read content.
More Posts From Leo Umesh
- The Tattoo of My Newborn Baby Girl Forever Inked on My Skin
- Long Weekend Food Feast With Wife
- String Manipulation in C#: Part 2
- String Manipulation in C#
- Introduction to C# and .NET
- Weekend Escape To Falls
- Evening Barbecue With Favourite Beer 🍺 🍻
- NumPy Broadcasting
- Summer BBQ
- Review of "The Day of The Jackal" Series