{"componentChunkName":"component---src-templates-blog-post-js","path":"/the_range_function/","result":{"data":{"site":{"siteMetadata":{"title":"Freddy Bihozagara's Blog"}},"markdownRemark":{"id":"c27a8586-2699-53e9-b7e5-70eb23b64083","excerpt":"If you do need to iterate over a sequence of numbers, the built-in python function range() comes in handy. It generates arithmetic progressions: Source: https…","html":"<p>If you do need to iterate over a sequence of numbers, the built-in python function range() comes in handy. It generates arithmetic progressions:</p>\n<div class=\"gatsby-highlight\" data-language=\"text\"><pre class=\"language-text\"><code class=\"language-text\">&gt;&gt;&gt; for i in range(5):\n...     print(i)\n...\n0\n1\n2\n3\n4</code></pre></div>\n<div class=\"gatsby-highlight\" data-language=\"text\"><pre class=\"language-text\"><code class=\"language-text\">range(5, 10)\n   5, 6, 7, 8, 9\n\nrange(0, 10, 3)\n   0, 3, 6, 9\n\nrange(-10, -100, -30)\n  -10, -40, -70</code></pre></div>\n<div class=\"gatsby-highlight\" data-language=\"text\"><pre class=\"language-text\"><code class=\"language-text\">&gt;&gt;&gt; a = [&#39;100&#39;, &#39;200&#39;, &#39;30000&#39;, &#39;500000&#39;, &#39;1000000&#39;]\n&gt;&gt;&gt; for i in range(len(a)):\n...     print(i, a[i])\n...\n0 100\n1 200\n2 30000\n3 500000\n4 1000000</code></pre></div>\n<div class=\"gatsby-highlight\" data-language=\"text\"><pre class=\"language-text\"><code class=\"language-text\">&gt;&gt;&gt; sum(range(4))  # 0 + 1 + 2 + 3\n6</code></pre></div>\n<div class=\"gatsby-highlight\" data-language=\"text\"><pre class=\"language-text\"><code class=\"language-text\">&gt;&gt;&gt; list(range(4))\n[0, 1, 2, 3]</code></pre></div>\n<p>Source: <a href=\"https://www.python.org/\">https://www.python.org/</a></p>","frontmatter":{"title":"The range() Function","date":"January 10, 2021","description":"If you do need to iterate over a sequence of numbers, the built-in function range() comes in handy. It generates arithmetic progressions: .."}},"previous":{"fields":{"slug":"/wiki_ai/"},"frontmatter":{"title":"Artificial Intelligence (AI)"}},"next":{"fields":{"slug":"/wsb-stock-markets/"},"frontmatter":{"title":"WSB/reddit, GME, AMC, Robinhood, key takeaways"}}},"pageContext":{"id":"c27a8586-2699-53e9-b7e5-70eb23b64083","previousPostId":"7c95bf97-8ac1-5ae8-83d4-c8f02a2712f9","nextPostId":"e0046930-cf9e-5af9-984c-8f923896f612"}},"staticQueryHashes":["2841359383","916993862"]}