{"id":107,"date":"2021-03-11T17:31:53","date_gmt":"2021-03-11T17:31:53","guid":{"rendered":"https:\/\/blogs.glowscotland.org.uk\/sh\/ahscomputingpython\/?page_id=107"},"modified":"2021-03-17T13:01:02","modified_gmt":"2021-03-17T13:01:02","slug":"fixed-loops","status":"publish","type":"page","link":"https:\/\/blogs.glowscotland.org.uk\/sh\/ahscomputingpython\/nat4\/fixed-loops\/","title":{"rendered":"Fixed Loops"},"content":{"rendered":"<p>Fixed loops will repeat for a set number of times.<\/p>\n<p>A variable is used to count through the loop, starting from zero<\/p>\n<ul>\n<li>give this variable a sensible name<\/li>\n<li>if printing the number out, you might want to add 1 to it<\/li>\n<\/ul>\n<pre class=\"brush: python; title: ; notranslate\" title=\"\">\r\n#\r\nfor pupil in range(5):\r\n \r\n    name = input('Enter name of pupil:')\r\n    print(f'Pupil {name+1} is {name}')\r\n#\r\n<\/pre>\n<p>The value for range can be a number, or a variable:<\/p>\n<pre class=\"brush: python; title: ; notranslate\" title=\"\">\r\n#\r\nclassSize = int(input('Enter number of pupils:'))\r\n \r\nfor pupil in range(classSize):\r\n    name = input('Enter name of pupil:')\r\n    print(f'Pupil {name+1} is {name}')\r\n#\r\n<\/pre>\n<pre><\/pre>\n","protected":false},"excerpt":{"rendered":"<p>Fixed loops will repeat for a set number of times. A variable is used to count through the loop, starting from zero give this variable a sensible name if printing the number out, you might want to add 1 to it # for pupil in range(5): name = input(&#8216;Enter name of pupil:&#8217;) print(f&#8217;Pupil {name+1} is {name}&#8217;) # The value for range can be a number, or a variable: # classSize<\/p>\n<p><a class=\"more-link\" href=\"https:\/\/blogs.glowscotland.org.uk\/sh\/ahscomputingpython\/nat4\/fixed-loops\/\">Read More<\/a><\/p>\n","protected":false},"author":7,"featured_media":0,"parent":297,"menu_order":0,"comment_status":"closed","ping_status":"closed","template":"","meta":{"footnotes":""},"class_list":["post-107","page","type-page","status-publish","hentry"],"_links":{"self":[{"href":"https:\/\/blogs.glowscotland.org.uk\/sh\/ahscomputingpython\/wp-json\/wp\/v2\/pages\/107","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=107"}],"version-history":[{"count":4,"href":"https:\/\/blogs.glowscotland.org.uk\/sh\/ahscomputingpython\/wp-json\/wp\/v2\/pages\/107\/revisions"}],"predecessor-version":[{"id":461,"href":"https:\/\/blogs.glowscotland.org.uk\/sh\/ahscomputingpython\/wp-json\/wp\/v2\/pages\/107\/revisions\/461"}],"up":[{"embeddable":true,"href":"https:\/\/blogs.glowscotland.org.uk\/sh\/ahscomputingpython\/wp-json\/wp\/v2\/pages\/297"}],"wp:attachment":[{"href":"https:\/\/blogs.glowscotland.org.uk\/sh\/ahscomputingpython\/wp-json\/wp\/v2\/media?parent=107"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}