{"id":80723,"date":"2021-05-19T09:00:08","date_gmt":"2021-05-19T03:30:08","guid":{"rendered":"https:\/\/techvidvan.com\/tutorials\/?p=80723"},"modified":"2021-05-19T09:00:08","modified_gmt":"2021-05-19T03:30:08","slug":"python-array-module","status":"publish","type":"post","link":"https:\/\/techvidvan.com\/tutorials\/python-array-module\/","title":{"rendered":"Python Arrays | Python Array Module"},"content":{"rendered":"<p><span style=\"font-weight: 400\">Array is yet another interesting topic of python, which covers and requires a good knowledge of basics before actually applying it. But the article is of course, one more magic spell from fairy basket, so why would it be partial to any coder? <\/span><\/p>\n<p><span style=\"font-weight: 400\">This article takes you from basic to advanced knowledge of Python array modules. So, let&#8217;s get started.\u00a0<\/span><\/p>\n<h3>What is Array Module in Python?<\/h3>\n<p>The array module defines an object type that can compactly represent an array of some basic values as characters, integers, floating-point numbers.<\/p>\n<p>Arrays are sequence types and behave similarly as lists, except that the type of objects stored in them is constrained.<br \/>\nThe module defines the following type:<\/p>\n<p><b><i>class array.array(typecode[, initializer]):<\/i><\/b><span style=\"font-weight: 400\"> A new array whose items are restricted by the typecode, and initialized from the optional initializer value, which must be a list, a bytes-like object, or iterable over elements of the appropriate type.<\/span><\/p>\n<p>Here\u2019s a list of such type codes-<\/p>\n<table>\n<tbody>\n<tr>\n<td><b>Type Code<\/b><\/td>\n<td><b>C Type<\/b><\/td>\n<td><b>Python Type<\/b><\/td>\n<td><b>Minimum size (bytes)<\/b><\/td>\n<\/tr>\n<tr>\n<td><span style=\"font-weight: 400\">b<\/span><\/td>\n<td><span style=\"font-weight: 400\">signed char<\/span><\/td>\n<td><span style=\"font-weight: 400\">int<\/span><\/td>\n<td><span style=\"font-weight: 400\">1<\/span><\/td>\n<\/tr>\n<tr>\n<td><span style=\"font-weight: 400\">B<\/span><\/td>\n<td><span style=\"font-weight: 400\">unsigned char<\/span><\/td>\n<td><span style=\"font-weight: 400\">int<\/span><\/td>\n<td><span style=\"font-weight: 400\">1<\/span><\/td>\n<\/tr>\n<tr>\n<td><span style=\"font-weight: 400\">u<\/span><\/td>\n<td><span style=\"font-weight: 400\">Py_UNICODE<\/span><\/td>\n<td><span style=\"font-weight: 400\">Unicode character;<\/span><\/p>\n<p><span style=\"font-weight: 400\">deprecated since Python 3.3<\/span><\/td>\n<td><span style=\"font-weight: 400\">2<\/span><\/td>\n<\/tr>\n<tr>\n<td><span style=\"font-weight: 400\">h<\/span><\/td>\n<td><span style=\"font-weight: 400\">signed short<\/span><\/td>\n<td><span style=\"font-weight: 400\">int<\/span><\/td>\n<td><span style=\"font-weight: 400\">2<\/span><\/td>\n<\/tr>\n<tr>\n<td><span style=\"font-weight: 400\">H<\/span><\/td>\n<td><span style=\"font-weight: 400\">unsigned short<\/span><\/td>\n<td><span style=\"font-weight: 400\">int<\/span><\/td>\n<td><span style=\"font-weight: 400\">2<\/span><\/td>\n<\/tr>\n<tr>\n<td><span style=\"font-weight: 400\">i<\/span><\/td>\n<td><span style=\"font-weight: 400\">signed int<\/span><\/td>\n<td><span style=\"font-weight: 400\">int<\/span><\/td>\n<td><span style=\"font-weight: 400\">2<\/span><\/td>\n<\/tr>\n<tr>\n<td><span style=\"font-weight: 400\">I<\/span><\/td>\n<td><span style=\"font-weight: 400\">unsigned int<\/span><\/td>\n<td><span style=\"font-weight: 400\">int<\/span><\/td>\n<td><span style=\"font-weight: 400\">2<\/span><\/td>\n<\/tr>\n<tr>\n<td><span style=\"font-weight: 400\">l<\/span><\/td>\n<td><span style=\"font-weight: 400\">signed long<\/span><\/td>\n<td><span style=\"font-weight: 400\">int<\/span><\/td>\n<td><span style=\"font-weight: 400\">4<\/span><\/td>\n<\/tr>\n<tr>\n<td><span style=\"font-weight: 400\">L<\/span><\/td>\n<td><span style=\"font-weight: 400\">unsigned long<\/span><\/td>\n<td><span style=\"font-weight: 400\">int<\/span><\/td>\n<td><span style=\"font-weight: 400\">4<\/span><\/td>\n<\/tr>\n<tr>\n<td><span style=\"font-weight: 400\">q<\/span><\/td>\n<td><span style=\"font-weight: 400\">signed long long<\/span><\/td>\n<td><span style=\"font-weight: 400\">int<\/span><\/td>\n<td><span style=\"font-weight: 400\">8<\/span><\/td>\n<\/tr>\n<tr>\n<td><span style=\"font-weight: 400\">Q<\/span><\/td>\n<td><span style=\"font-weight: 400\">unsigned long long<\/span><\/td>\n<td><span style=\"font-weight: 400\">int<\/span><\/td>\n<td><span style=\"font-weight: 400\">8<\/span><\/td>\n<\/tr>\n<tr>\n<td><span style=\"font-weight: 400\">f<\/span><\/td>\n<td><span style=\"font-weight: 400\">float<\/span><\/td>\n<td><span style=\"font-weight: 400\">float<\/span><\/td>\n<td><span style=\"font-weight: 400\">4<\/span><\/td>\n<\/tr>\n<tr>\n<td><span style=\"font-weight: 400\">d<\/span><\/td>\n<td><span style=\"font-weight: 400\">double<\/span><\/td>\n<td><span style=\"font-weight: 400\">float<\/span><\/td>\n<td><span style=\"font-weight: 400\">8<\/span><\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n<h3>How to Import Python Arrays?<\/h3>\n<p><strong>syntax<\/strong><\/p>\n<p><span style=\"font-weight: 400\">&gt;&gt;&gt; import array<\/span><\/p>\n<h4>Indexing an Array in Python<\/h4>\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"generic\">&gt;&gt;&gt;\narray=[5,9,5,9]\n\nprint(array[1])\n<\/pre>\n<p><strong>Output<\/strong><\/p>\n<div class=\"code-output\">9<\/div>\n<h3 class=\"western fittexted_for_content_h3\">Python Array Class \u2013 Data Items<\/h3>\n<p>The class\u00a0<i>array<\/i>\u00a0has the following data items-<\/p>\n<p><b><i>1. Array.typecodes:<\/i><\/b><span style=\"font-weight: 400\"> A string with all type codes.<\/span><\/p>\n<p><b><i>2. Array.typecode:<\/i><\/b><span style=\"font-weight: 400\"> The typecode character used in creating the array.<\/span><\/p>\n<p><b><i>3. Array.itemsize: <\/i><\/b><span style=\"font-weight: 400\">The length of array\u00a0<\/span><\/p>\n<p><span style=\"font-weight: 400\">&gt;&gt;&gt;arr.itemsize<\/span><\/p>\n<p><b><i>4. array.append(x): <\/i><\/b><span style=\"font-weight: 400\">Append new item with value x to the end of the array.<\/span><\/p>\n<p><span style=\"font-weight: 400\">&gt;&gt;&gt;arr.append<\/span><\/p>\n<p><b><i>5. array.append(x):<\/i><\/b><span style=\"font-weight: 400\"> Append new item with value x to the end of the array.<\/span><\/p>\n<p><b><i>6. array.pop([i]):<\/i><\/b><span style=\"font-weight: 400\">removes the element\u00a0 \u201ci\u201dwhich is parsed.<\/span><\/p>\n<p><span style=\"font-weight: 400\">&gt;&gt;&gt;arr.pop<\/span><\/p>\n<p><b><i>7. array.remove(x): <\/i><\/b><span style=\"font-weight: 400\">Removes the first occurrence of x from the array.<\/span><\/p>\n<p><span style=\"font-weight: 400\">&gt;&gt;&gt;arr.remove<\/span><\/p>\n<p><b><i>8. array.reverse():<\/i><\/b> <span style=\"font-weight: 400\">Reverses the order of the items in the array.<\/span><\/p>\n<p><span style=\"font-weight: 400\">&gt;&gt;&gt;arr.reverse<\/span><\/p>\n<p><b><i>9. array.index(x):<\/i><\/b><span style=\"font-weight: 400\"> Returns the smallest i such that i is the index of the first occurrence of x in the array.<\/span><\/p>\n<p><span style=\"font-weight: 400\">&gt;&gt;&gt;arr.index<\/span><\/p>\n<p><b><i>10. array.insert(i, x): <\/i><\/b><span style=\"font-weight: 400\">Inserts a new item with value x in the array before position i.<\/span><\/p>\n<p><span style=\"font-weight: 400\">&gt;&gt;&gt;arr.insert<\/span><\/p>\n<p><b>11. array.buffer_info()<\/b><\/p>\n<p><span style=\"font-weight: 400\">This returns a tuple that holds the address in memory and the length of elements in the buffer that holds the contents of the array in the runtime.<\/span><\/p>\n<p><span style=\"font-weight: 400\">&gt;&gt;&gt; arr.buffer<\/span><\/p>\n<p><b>12. array.byteswap()<\/b><\/p>\n<p><span style=\"font-weight: 400\">This performs an operation of bytes wap on an array in the runtime.<\/span><\/p>\n<p><span style=\"font-weight: 400\">&gt;&gt;&gt; arr.byte<\/span><\/p>\n<p><b>13. array.count(x)<\/b><\/p>\n<p><span style=\"font-weight: 400\">\u00a0finds out how many 3s there are in our Python array in the runtime.<\/span><\/p>\n<p><span style=\"font-weight: 400\">&gt;&gt;&gt; arr.count<\/span><\/p>\n<p><b>14. array.extend(iterable)<\/b><\/p>\n<p><span style=\"font-weight: 400\">This attaches the iterable to the end of the array in Python in the runtime.<\/span><\/p>\n<p><span style=\"font-weight: 400\">&gt;&gt;&gt; arr.extend<\/span><\/p>\n<p><b>15. array.fromlist(list)<\/b><\/p>\n<p><span style=\"font-weight: 400\">This appends item from a list to the Python arrays in the runtime.<\/span><\/p>\n<p><span style=\"font-weight: 400\">&gt;&gt;&gt; arr.fromlist<\/span><\/p>\n<p><b>16. array.fromunicode(s)<\/b><\/p>\n<p><span style=\"font-weight: 400\">This appends the Unicode string in the runtime<\/span><\/p>\n<p><span style=\"font-weight: 400\">&gt;&gt;&gt; arr.unicode<\/span><\/p>\n<p><b>17. array.index(x)<\/b><\/p>\n<p><span style=\"font-weight: 400\">This returns the index for the first occurrence of x in the runtime.<\/span><\/p>\n<p><span style=\"font-weight: 400\">&gt;&gt;&gt; arr.index<\/span><\/p>\n<p><b>18. array.tobytes()<\/b><\/p>\n<p><span style=\"font-weight: 400\">returns a representation in bytes of the values of the array in the runtime<\/span><\/p>\n<p><span style=\"font-weight: 400\">&gt;&gt;&gt; arr.tobytes()<\/span><\/p>\n<p><b>19. array.tolist()<\/b><\/p>\n<p><span style=\"font-weight: 400\">converts the array into a list in the runtime.<\/span><\/p>\n<p><span style=\"font-weight: 400\">&gt;&gt;&gt; arr.tolist()<\/span><\/p>\n<p><b>\u00a020. array.tounicode()<\/b><\/p>\n<p><span style=\"font-weight: 400\">converts an array to a Unicode string in the runtime.\u00a0<\/span><\/p>\n<p><span style=\"font-weight: 400\">&gt;&gt;&gt; arr.tounicode<\/span><\/p>\n<h3>How does Array Work in Python?<\/h3>\n<p>The array is stored in contiguous memory locations, where the index is a sequence of numbers that represents the values stored at every particular index.<\/p>\n<p>To access or refer to the value at a particular index in an array we make use of a set of square brackets [ ],(as in lists) also we can use the for-in loop to iterate through the array. The array has indices and values.<\/p>\n<p><strong>Array Module Example in python<\/strong><\/p>\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"generic\">import array as arr\na=arr.array('I', [10 , 20 ,50] )\nprint(\"Element at 0th index: \" , a[0])\nprint(\"Element at 1st  index: \" , a[1])\nprint(\"Element at 2nd index: \" , a[2])\n<\/pre>\n<p><strong>Output<\/strong><\/p>\n<div class=\"code-output\">\n<p><span style=\"font-weight: 400\">Element at 0th index: 10<\/span><span style=\"font-weight: 400\">Element at 1st index: 20<\/span><\/p>\n<p><span style=\"font-weight: 400\">Element at 2nd index: 50<\/span><\/p>\n<\/div>\n<h3>Python Array Representation<\/h3>\n<p>Arrays can be declared in various ways and in different languages. The important points that should be considered are as follows:<\/p>\n<ul>\n<li style=\"font-weight: 400\"><span style=\"font-weight: 400\">Index always starts with 0.<\/span><\/li>\n<li style=\"font-weight: 400\"><span style=\"font-weight: 400\">We can access each element using its index.<\/span><\/li>\n<li style=\"font-weight: 400\"><span style=\"font-weight: 400\">The length of the array defines the capacity to store the elements.<\/span><\/li>\n<\/ul>\n<h3>Python Array Operations<\/h3>\n<p><span style=\"font-weight: 400\">Some of the basic operations supported by an array are:<\/span><\/p>\n<ul>\n<li style=\"font-weight: 400\"><b>Traverse<\/b><span style=\"font-weight: 400\"> &#8211; It prints all elements one by one.<\/span><\/li>\n<li style=\"font-weight: 400\"><b>Insertion<\/b><span style=\"font-weight: 400\"> &#8211; It adds an element at a given index.<\/span><\/li>\n<li style=\"font-weight: 400\"><b>Deletion<\/b><span style=\"font-weight: 400\"> &#8211; It deletes elements at the given index.<\/span><\/li>\n<li style=\"font-weight: 400\"><b>Search<\/b><span style=\"font-weight: 400\"> &#8211; It searches the element using the given index or by the value.<\/span><\/li>\n<li style=\"font-weight: 400\"><b>Update<\/b><span style=\"font-weight: 400\"> &#8211; It updates elements at the given index.<\/span><\/li>\n<\/ul>\n<p><strong>Searching Element in Python Array Example:<br \/>\n<\/strong><\/p>\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"generic\">from array import *\narray_techvidvan = array(\u2018i\u2019, [0,1,2,3,4,5])\nprint (array_techvidvan.index(3))\n<\/pre>\n<p><strong>Output:<\/strong><\/p>\n<div class=\"code-output\">1<\/div>\n<p><strong>Example of Traversing Array in Python<br \/>\n<\/strong><\/p>\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"generic\">from array import *\narray_TechVidvan = [0,1,2,3,4,5]\nfor x in array_TechVidvan:\n print (x)\n<\/pre>\n<p><strong>Output:<\/strong><\/p>\n<div class=\"code-output\">\n<p><span style=\"font-weight: 400\">0<\/span><span style=\"font-weight: 400\">1<\/span><\/p>\n<p><span style=\"font-weight: 400\">2<\/span><\/p>\n<p><span style=\"font-weight: 400\">3<\/span><\/p>\n<p><span style=\"font-weight: 400\">4<\/span><\/p>\n<p><span style=\"font-weight: 400\">5<\/span><\/p>\n<\/div>\n<h3>Creating Python Arrays<\/h3>\n<p>for creating an array of numeric values, the coder needs to import the array module in runtime.<\/p>\n<p><strong>Example to Create Array in Python<\/strong><\/p>\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"generic\">import array as arr\np = arr.array('q', [1,5])\nprint(p)\n<\/pre>\n<p><strong>Output:<\/strong><\/p>\n<div class=\"code-output\"><span style=\"font-weight: 400\">array(&#8216;q&#8217;, [1,5])<\/span><\/div>\n<h3>Accessing Python Array Elements<\/h3>\n<p><strong>Example to access Python Array Elements:<\/strong><\/p>\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"generic\">import array as arr\np = arr.array('j', [2,  80])\nprint(\"First element of list:\", p[0])\nprint(\"Second element of list:\", p[1])\n<\/pre>\n<p><strong>Output:<\/strong><\/p>\n<div class=\"code-output\">First element of list: 2<br \/>\nSecond element of list: 80<\/div>\n<h3>Changing and Adding Elements in Python Array<\/h3>\n<p><span style=\"font-weight: 400\">Arrays are mutable therefore their elements can be changed in a similar way as lists in the code.<\/span><\/p>\n<p><strong>Code<\/strong><\/p>\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"generic\">import array as arr\nnumb = arr.array('k', [1, 109])\nnumb[0] = 0    \nprint(numb)     \n<\/pre>\n<p><strong>Output:<\/strong><\/p>\n<div class=\"code-output\"><span style=\"font-weight: 400\">array(&#8216;k&#8217;, [0,109])<\/span><\/div>\n<p><span style=\"font-weight: 400\">adding elements in array<\/span><\/p>\n<p><b>extend()<\/b><span style=\"font-weight: 400\">: it appends iterable to the end of the array in any code.<\/span><\/p>\n<p><strong>Code<\/strong><\/p>\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"generic\">numb.extend([5])\nprint(numb)  \n<\/pre>\n<p><strong>Output:<\/strong><\/p>\n<div class=\"code-output\"><span style=\"font-weight: 400\">array(&#8216;i&#8217;, [1,30,5])<\/span><\/div>\n<h3>Removing Python Array Elements<\/h3>\n<p><strong>Code<\/strong><\/p>\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"generic\">import array as arr\nnumb = arr.array('k', [1, 2,3 ])\ndel numb[2]  \nprint(numb) \n<\/pre>\n<p><strong>Output:<\/strong><\/p>\n<div class=\"code-output\"><span style=\"font-weight: 400\">error<\/span><\/div>\n<p><strong>Code<\/strong><\/p>\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"generic\">del numb \nprint(numb)\n<\/pre>\n<p><strong>Output:<\/strong><\/p>\n<div class=\"code-output\">Traceback (most recent call last):<br \/>\nNameError: name &#8216;numb&#8217; is not defined<\/div>\n<h3>Searching an element in an Array<\/h3>\n<p><strong>Code<\/strong><\/p>\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"generic\">import array \n   \narr = array.array('k', [1, 2])  \n  \nprint (\"The new created array is : \", end =\"\") \nfor k in range (0, 2): \n    print (arr[k], end =\" \") \n<\/pre>\n<p><strong>Output:<br \/>\n<\/strong><\/p>\n<div class=\"code-output\">1<\/div>\n<h3>Updating Elements in an Array<\/h3>\n<p><strong>Code<\/strong><\/p>\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"generic\">import array\nprint (\"Array before\", end =\" \")\nfor k in range (0,2):\n    print ([k], end =\" \")\n<\/pre>\n<p><strong>Output:<\/strong><\/p>\n<div class=\"code-output\"><span style=\"font-weight: 400\">Array before [0] [1]\u00a0<\/span><\/div>\n<h3>Looping Array Elements in Python<\/h3>\n<p><strong>Code<\/strong><\/p>\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"generic\">list=[1,0]\nfor i in list:\n  print(i)\n<\/pre>\n<p><strong>Output:<\/strong><\/p>\n<div class=\"code-output\">\n<p>10<\/p>\n<\/div>\n<h3>Calculating Length of an Array in Python<\/h3>\n<p><strong>Code<\/strong><\/p>\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"generic\">l=[1,0]\ni = len(l)\nprint(i)\n<\/pre>\n<p><strong>Output:<\/strong><\/p>\n<div class=\"code-output\">2<\/div>\n<h3>Slicing Arrays in Python<\/h3>\n<p>By using the slicing operator (:), it\u2019s possible to access a range of elements present in the array in Python programming language. The following code snippet demonstrates using the slicing operator with an array :<\/p>\n<p><strong>Code<\/strong><\/p>\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"generic\">number_list = [2, 4, 22, 25, 24, 52, 46,10]\nfor i in range(1,5):\n    print(i)\nfor j in range(5,8):\n    print(j)\n<\/pre>\n<p><strong>Output:<\/strong><\/p>\n<div class=\"code-output\">\n<p><span style=\"font-weight: 400\">1<\/span><span style=\"font-weight: 400\">2<\/span><\/p>\n<p><span style=\"font-weight: 400\">3<\/span><\/p>\n<p><span style=\"font-weight: 400\">4<\/span><\/p>\n<p><span style=\"font-weight: 400\">5<\/span><\/p>\n<p><span style=\"font-weight: 400\">6<\/span><\/p>\n<p><span style=\"font-weight: 400\">7<\/span><\/p>\n<\/div>\n<p><span style=\"font-weight: 400\">Arrays are mutable. Hence, their elements can be changed similarly as lists.The <\/span><i><span style=\"font-weight: 400\">append()<\/span><\/i><span style=\"font-weight: 400\"> method is used for adding one element to an array while <\/span><i><span style=\"font-weight: 400\">extend()<\/span><\/i><span style=\"font-weight: 400\"> method allows adding multiple elements. These new elements are added at the end of the array. <\/span><\/p>\n<p><span style=\"font-weight: 400\">Although knowing how to deal with arrays isn\u2019t a compulsory part of learning Python, being able to do so is surely an added advantage.Typically, the array module is generally\u00a0 required for interfacing with C code.\u00a0<\/span><\/p>\n<h3>Python Lists Vs Arrays<\/h3>\n<p><strong>Code<\/strong><\/p>\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"generic\">a = [1, 3.5, \"TechVidvan\"] \nimport array as arr\n# Error\na = arr.array('d', [1, 3.5, \"TechVidvan\"])\n<\/pre>\n<p><strong>Output:<\/strong><\/p>\n<div class=\"code-output\">\n<p><span style=\"font-weight: 400\">Traceback (most recent call last):<\/span><span style=\"font-weight: 400\">\u00a0\u00a0File &#8220;&lt;string&gt;&#8221;, line 3, in &lt;module&gt;<\/span><\/p>\n<p><span style=\"font-weight: 400\">TypeError: must be real number, not str<\/span><\/p>\n<\/div>\n<h3>Summary<\/h3>\n<p>At the end of the article, we got an idea of how an array is similar to a list in many aspects, but surely there is a difference. The array is not very much recommended in Python as stated earlier but knowing it will add to your knowledge.<\/p>\n<p>A good coder is someone who knows every aspect of code, and practice is a definite key. Try and check out array() yourself. Happy Pythonning!<\/p>\n","protected":false},"excerpt":{"rendered":"<p>Array is yet another interesting topic of python, which covers and requires a good knowledge of basics before actually applying it. But the article is of course, one more magic spell from fairy basket,&#46;&#46;&#46;<\/p>\n","protected":false},"author":1,"featured_media":80774,"comment_status":"open","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[1053],"tags":[3430,3431,3432,3433,3434,3435,3436,3437],"class_list":["post-80723","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-python","tag-python-array","tag-python-array-class","tag-python-array-length","tag-python-array-module","tag-python-array-operations","tag-python-arrays","tag-python-arrays-examples","tag-python-arrays-indexing"],"yoast_head":"<!-- This site is optimized with the Yoast SEO plugin v27.7 - https:\/\/yoast.com\/product\/yoast-seo-wordpress\/ -->\n<title>Python Arrays | Python Array Module - TechVidvan<\/title>\n<meta name=\"robots\" content=\"index, follow, max-snippet:-1, max-image-preview:large, max-video-preview:-1\" \/>\n<link rel=\"canonical\" href=\"https:\/\/techvidvan.com\/tutorials\/python-array-module\/\" \/>\n<meta property=\"og:locale\" content=\"en_US\" \/>\n<meta property=\"og:type\" content=\"article\" \/>\n<meta property=\"og:title\" content=\"Python Arrays | Python Array Module - TechVidvan\" \/>\n<meta property=\"og:description\" content=\"Array is yet another interesting topic of python, which covers and requires a good knowledge of basics before actually applying it. But the article is of course, one more magic spell from fairy basket,&#046;&#046;&#046;\" \/>\n<meta property=\"og:url\" content=\"https:\/\/techvidvan.com\/tutorials\/python-array-module\/\" \/>\n<meta property=\"og:site_name\" content=\"TechVidvan\" \/>\n<meta property=\"article:publisher\" content=\"https:\/\/www.facebook.com\/TechVidvan\/\" \/>\n<meta property=\"article:published_time\" content=\"2021-05-19T03:30:08+00:00\" \/>\n<meta property=\"og:image\" content=\"https:\/\/techvidvan.com\/tutorials\/wp-content\/uploads\/2021\/05\/Arrays-in-Python.jpg\" \/>\n\t<meta property=\"og:image:width\" content=\"1200\" \/>\n\t<meta property=\"og:image:height\" content=\"628\" \/>\n\t<meta property=\"og:image:type\" content=\"image\/jpeg\" \/>\n<meta name=\"author\" content=\"TechVidvan Team\" \/>\n<meta name=\"twitter:card\" content=\"summary_large_image\" \/>\n<meta name=\"twitter:creator\" content=\"@vidvantech\" \/>\n<meta name=\"twitter:site\" content=\"@vidvantech\" \/>\n<meta name=\"twitter:label1\" content=\"Written by\" \/>\n\t<meta name=\"twitter:data1\" content=\"TechVidvan Team\" \/>\n\t<meta name=\"twitter:label2\" content=\"Est. reading time\" \/>\n\t<meta name=\"twitter:data2\" content=\"6 minutes\" \/>\n<!-- \/ Yoast SEO plugin. -->","yoast_head_json":{"title":"Python Arrays | Python Array Module - TechVidvan","robots":{"index":"index","follow":"follow","max-snippet":"max-snippet:-1","max-image-preview":"max-image-preview:large","max-video-preview":"max-video-preview:-1"},"canonical":"https:\/\/techvidvan.com\/tutorials\/python-array-module\/","og_locale":"en_US","og_type":"article","og_title":"Python Arrays | Python Array Module - TechVidvan","og_description":"Array is yet another interesting topic of python, which covers and requires a good knowledge of basics before actually applying it. But the article is of course, one more magic spell from fairy basket,&#46;&#46;&#46;","og_url":"https:\/\/techvidvan.com\/tutorials\/python-array-module\/","og_site_name":"TechVidvan","article_publisher":"https:\/\/www.facebook.com\/TechVidvan\/","article_published_time":"2021-05-19T03:30:08+00:00","og_image":[{"width":1200,"height":628,"url":"https:\/\/techvidvan.com\/tutorials\/wp-content\/uploads\/2021\/05\/Arrays-in-Python.jpg","type":"image\/jpeg"}],"author":"TechVidvan Team","twitter_card":"summary_large_image","twitter_creator":"@vidvantech","twitter_site":"@vidvantech","twitter_misc":{"Written by":"TechVidvan Team","Est. reading time":"6 minutes"},"schema":{"@context":"https:\/\/schema.org","@graph":[{"@type":"Article","@id":"https:\/\/techvidvan.com\/tutorials\/python-array-module\/#article","isPartOf":{"@id":"https:\/\/techvidvan.com\/tutorials\/python-array-module\/"},"author":{"name":"TechVidvan Team","@id":"https:\/\/techvidvan.com\/tutorials\/#\/schema\/person\/e9c26e74dd3d87421f7ada9433b8cd22"},"headline":"Python Arrays | Python Array Module","datePublished":"2021-05-19T03:30:08+00:00","mainEntityOfPage":{"@id":"https:\/\/techvidvan.com\/tutorials\/python-array-module\/"},"wordCount":1225,"commentCount":0,"publisher":{"@id":"https:\/\/techvidvan.com\/tutorials\/#organization"},"image":{"@id":"https:\/\/techvidvan.com\/tutorials\/python-array-module\/#primaryimage"},"thumbnailUrl":"https:\/\/techvidvan.com\/tutorials\/wp-content\/uploads\/2021\/05\/Arrays-in-Python.jpg","keywords":["Python Array","Python Array Class","Python Array length","Python Array Module","Python Array Operations","Python Arrays","python arrays Examples","python arrays indexing"],"articleSection":["Python Tutorials"],"inLanguage":"en-US","potentialAction":[{"@type":"CommentAction","name":"Comment","target":["https:\/\/techvidvan.com\/tutorials\/python-array-module\/#respond"]}]},{"@type":"WebPage","@id":"https:\/\/techvidvan.com\/tutorials\/python-array-module\/","url":"https:\/\/techvidvan.com\/tutorials\/python-array-module\/","name":"Python Arrays | Python Array Module - TechVidvan","isPartOf":{"@id":"https:\/\/techvidvan.com\/tutorials\/#website"},"primaryImageOfPage":{"@id":"https:\/\/techvidvan.com\/tutorials\/python-array-module\/#primaryimage"},"image":{"@id":"https:\/\/techvidvan.com\/tutorials\/python-array-module\/#primaryimage"},"thumbnailUrl":"https:\/\/techvidvan.com\/tutorials\/wp-content\/uploads\/2021\/05\/Arrays-in-Python.jpg","datePublished":"2021-05-19T03:30:08+00:00","breadcrumb":{"@id":"https:\/\/techvidvan.com\/tutorials\/python-array-module\/#breadcrumb"},"inLanguage":"en-US","potentialAction":[{"@type":"ReadAction","target":["https:\/\/techvidvan.com\/tutorials\/python-array-module\/"]}]},{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/techvidvan.com\/tutorials\/python-array-module\/#primaryimage","url":"https:\/\/techvidvan.com\/tutorials\/wp-content\/uploads\/2021\/05\/Arrays-in-Python.jpg","contentUrl":"https:\/\/techvidvan.com\/tutorials\/wp-content\/uploads\/2021\/05\/Arrays-in-Python.jpg","width":1200,"height":628,"caption":"Arrays in Python"},{"@type":"BreadcrumbList","@id":"https:\/\/techvidvan.com\/tutorials\/python-array-module\/#breadcrumb","itemListElement":[{"@type":"ListItem","position":1,"name":"Home","item":"https:\/\/techvidvan.com\/tutorials\/"},{"@type":"ListItem","position":2,"name":"Python Arrays | Python Array Module"}]},{"@type":"WebSite","@id":"https:\/\/techvidvan.com\/tutorials\/#website","url":"https:\/\/techvidvan.com\/tutorials\/","name":"TechVidvan Blogs","description":"","publisher":{"@id":"https:\/\/techvidvan.com\/tutorials\/#organization"},"potentialAction":[{"@type":"SearchAction","target":{"@type":"EntryPoint","urlTemplate":"https:\/\/techvidvan.com\/tutorials\/?s={search_term_string}"},"query-input":{"@type":"PropertyValueSpecification","valueRequired":true,"valueName":"search_term_string"}}],"inLanguage":"en-US"},{"@type":"Organization","@id":"https:\/\/techvidvan.com\/tutorials\/#organization","name":"TechVidvan","url":"https:\/\/techvidvan.com\/tutorials\/","logo":{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/techvidvan.com\/tutorials\/#\/schema\/logo\/image\/","url":"https:\/\/techvidvan.com\/tutorials\/wp-content\/uploads\/2024\/03\/techvidvan-logo-200x50-1.webp","contentUrl":"https:\/\/techvidvan.com\/tutorials\/wp-content\/uploads\/2024\/03\/techvidvan-logo-200x50-1.webp","width":200,"height":50,"caption":"TechVidvan"},"image":{"@id":"https:\/\/techvidvan.com\/tutorials\/#\/schema\/logo\/image\/"},"sameAs":["https:\/\/www.facebook.com\/TechVidvan\/","https:\/\/x.com\/vidvantech"]},{"@type":"Person","@id":"https:\/\/techvidvan.com\/tutorials\/#\/schema\/person\/e9c26e74dd3d87421f7ada9433b8cd22","name":"TechVidvan Team","description":"The TechVidvan Team delivers practical, beginner-friendly tutorials on programming, Java, Python, C++, DSA, AI, ML, data Science, Android, Flutter, MERN, Web Development, and technology. Our experts are here to help you upskill and excel in today\u2019s tech industry."}]}},"amp_enabled":true,"_links":{"self":[{"href":"https:\/\/techvidvan.com\/tutorials\/wp-json\/wp\/v2\/posts\/80723","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/techvidvan.com\/tutorials\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/techvidvan.com\/tutorials\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/techvidvan.com\/tutorials\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/techvidvan.com\/tutorials\/wp-json\/wp\/v2\/comments?post=80723"}],"version-history":[{"count":0,"href":"https:\/\/techvidvan.com\/tutorials\/wp-json\/wp\/v2\/posts\/80723\/revisions"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/techvidvan.com\/tutorials\/wp-json\/wp\/v2\/media\/80774"}],"wp:attachment":[{"href":"https:\/\/techvidvan.com\/tutorials\/wp-json\/wp\/v2\/media?parent=80723"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/techvidvan.com\/tutorials\/wp-json\/wp\/v2\/categories?post=80723"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/techvidvan.com\/tutorials\/wp-json\/wp\/v2\/tags?post=80723"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}