{"id":152,"date":"2021-03-14T17:26:06","date_gmt":"2021-03-14T17:26:06","guid":{"rendered":"https:\/\/blogs.glowscotland.org.uk\/sh\/ahscomputingpython\/?page_id=152"},"modified":"2023-02-07T08:51:39","modified_gmt":"2023-02-07T08:51:39","slug":"arrays","status":"publish","type":"page","link":"https:\/\/blogs.glowscotland.org.uk\/sh\/ahscomputingpython\/national-5\/arrays\/","title":{"rendered":"About Arrays"},"content":{"rendered":"<p>Lots of values could be stored using lots of variables:<\/p>\n<pre class=\"brush: python; title: ; notranslate\" title=\"\"> # \r\nname1 = &quot;Fred&quot;\r\nname2 = &quot;Sue&quot;\r\nname3 = &quot;Mark&quot;\r\nname4 = &quot;Alice&quot; \r\n#<\/pre>\n<p>An array stores several values:<\/p>\n<pre class=\"brush: python; title: ; notranslate\" title=\"\"> #\r\nname = &#x5B;&quot;Fred&quot;, &quot;Sue&quot;, &quot;Mark&quot;, &quot;Alice&quot;]\r\n#<\/pre>\n<p>Each item in an array is identified by an index value, starting with 0:<\/p>\n<pre class=\"brush: python; title: ; notranslate\" title=\"\"> # \r\nprint(name&#x5B;0]) # &quot;Fred&quot;\r\nprint(name&#x5B;1]) # &quot;Sue&quot; \r\nprint(name&#x5B;2]) # &quot;Mark&quot; \r\n#<\/pre>\n<p>The values in an array can be accessed efficiently using loops:<\/p>\n<pre class=\"brush: python; title: ; notranslate\" title=\"\"> # \r\nfor index in range(4):\r\n    print(name&#x5B;index])\r\n#<\/pre>\n<p>&nbsp;<\/p>\n","protected":false},"excerpt":{"rendered":"<p>Lots of values could be stored using lots of variables: # name1 = &quot;Fred&quot; name2 = &quot;Sue&quot; name3 = &quot;Mark&quot; name4 = &quot;Alice&quot; # An array stores several values: # name = &#x5B;&quot;Fred&quot;, &quot;Sue&quot;, &quot;Mark&quot;, &quot;Alice&quot;] # Each item in an array is identified by an index value, starting with 0: # print(name&#x5B;0]) # &quot;Fred&quot; print(name&#x5B;1]) # &quot;Sue&quot; print(name&#x5B;2]) # &quot;Mark&quot; # The values in an array can be accessed<\/p>\n<p><a class=\"more-link\" href=\"https:\/\/blogs.glowscotland.org.uk\/sh\/ahscomputingpython\/national-5\/arrays\/\">Read More<\/a><\/p>\n","protected":false},"author":7,"featured_media":0,"parent":337,"menu_order":0,"comment_status":"closed","ping_status":"closed","template":"","meta":{"footnotes":""},"class_list":["post-152","page","type-page","status-publish","hentry"],"_links":{"self":[{"href":"https:\/\/blogs.glowscotland.org.uk\/sh\/ahscomputingpython\/wp-json\/wp\/v2\/pages\/152","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/blogs.glowscotland.org.uk\/sh\/ahscomputingpython\/wp-json\/wp\/v2\/pages"}],"about":[{"href":"https:\/\/blogs.glowscotland.org.uk\/sh\/ahscomputingpython\/wp-json\/wp\/v2\/types\/page"}],"author":[{"embeddable":true,"href":"https:\/\/blogs.glowscotland.org.uk\/sh\/ahscomputingpython\/wp-json\/wp\/v2\/users\/7"}],"replies":[{"embeddable":true,"href":"https:\/\/blogs.glowscotland.org.uk\/sh\/ahscomputingpython\/wp-json\/wp\/v2\/comments?post=152"}],"version-history":[{"count":10,"href":"https:\/\/blogs.glowscotland.org.uk\/sh\/ahscomputingpython\/wp-json\/wp\/v2\/pages\/152\/revisions"}],"predecessor-version":[{"id":737,"href":"https:\/\/blogs.glowscotland.org.uk\/sh\/ahscomputingpython\/wp-json\/wp\/v2\/pages\/152\/revisions\/737"}],"up":[{"embeddable":true,"href":"https:\/\/blogs.glowscotland.org.uk\/sh\/ahscomputingpython\/wp-json\/wp\/v2\/pages\/337"}],"wp:attachment":[{"href":"https:\/\/blogs.glowscotland.org.uk\/sh\/ahscomputingpython\/wp-json\/wp\/v2\/media?parent=152"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}