{"id":285,"date":"2022-05-16T14:35:46","date_gmt":"2022-05-16T13:35:46","guid":{"rendered":"https:\/\/blogs.glowscotland.org.uk\/glowblogs\/phsn5computingscience\/?page_id=285"},"modified":"2023-08-30T10:38:47","modified_gmt":"2023-08-30T09:38:47","slug":"loops","status":"publish","type":"page","link":"https:\/\/blogs.glowscotland.org.uk\/glowblogs\/phsn5computingscience\/loops\/","title":{"rendered":"Loops"},"content":{"rendered":"<h2 style=\"color: red\"><strong>Fixed Loop<\/strong><\/h2>\n<p>A <strong>fixed loop<\/strong> will repeat for a set amount of time and allows the code to carry out repetitive lines of code.\u00a0 The number of times a selection of code has to be repeated is normally specified by the programmer.<\/p>\n<p>The <strong>For Loop<\/strong> has a loop <strong>counter<\/strong>. This <strong>counter<\/strong> is an integer and its value will <strong>increase by 1<\/strong> every time a loop has completed.<\/p>\n<p>The code within a loop is indented so show where the\u00a0 loop will begin and end within the program.<\/p>\n<p><img loading=\"lazy\" decoding=\"async\" class=\"alignnone wp-image-292\" src=\"https:\/\/blogs.glowscotland.org.uk\/glowblogs\/public\/phsn5computingscience\/uploads\/sites\/10033\/2022\/05\/16144356\/Screenshot-2022-05-16-144304-300x40.png\" alt=\"\" width=\"713\" height=\"95\" srcset=\"https:\/\/blogs.glowscotland.org.uk\/glowblogs\/public\/phsn5computingscience\/uploads\/sites\/10033\/2022\/05\/16144356\/Screenshot-2022-05-16-144304-300x40.png 300w, https:\/\/blogs.glowscotland.org.uk\/glowblogs\/public\/phsn5computingscience\/uploads\/sites\/10033\/2022\/05\/16144356\/Screenshot-2022-05-16-144304-1024x135.png 1024w, https:\/\/blogs.glowscotland.org.uk\/glowblogs\/public\/phsn5computingscience\/uploads\/sites\/10033\/2022\/05\/16144356\/Screenshot-2022-05-16-144304-768x101.png 768w, https:\/\/blogs.glowscotland.org.uk\/glowblogs\/public\/phsn5computingscience\/uploads\/sites\/10033\/2022\/05\/16144356\/Screenshot-2022-05-16-144304-624x82.png 624w, https:\/\/blogs.glowscotland.org.uk\/glowblogs\/public\/phsn5computingscience\/uploads\/sites\/10033\/2022\/05\/16144356\/Screenshot-2022-05-16-144304.png 1260w\" sizes=\"auto, (max-width: 713px) 100vw, 713px\" \/><\/p>\n<p><img loading=\"lazy\" decoding=\"async\" class=\"alignnone wp-image-293\" src=\"https:\/\/blogs.glowscotland.org.uk\/glowblogs\/public\/phsn5computingscience\/uploads\/sites\/10033\/2022\/05\/16144416\/Screenshot-2022-05-16-144324-300x38.png\" alt=\"\" width=\"711\" height=\"90\" srcset=\"https:\/\/blogs.glowscotland.org.uk\/glowblogs\/public\/phsn5computingscience\/uploads\/sites\/10033\/2022\/05\/16144416\/Screenshot-2022-05-16-144324-300x38.png 300w, https:\/\/blogs.glowscotland.org.uk\/glowblogs\/public\/phsn5computingscience\/uploads\/sites\/10033\/2022\/05\/16144416\/Screenshot-2022-05-16-144324-1024x128.png 1024w, https:\/\/blogs.glowscotland.org.uk\/glowblogs\/public\/phsn5computingscience\/uploads\/sites\/10033\/2022\/05\/16144416\/Screenshot-2022-05-16-144324-768x96.png 768w, https:\/\/blogs.glowscotland.org.uk\/glowblogs\/public\/phsn5computingscience\/uploads\/sites\/10033\/2022\/05\/16144416\/Screenshot-2022-05-16-144324-624x78.png 624w, https:\/\/blogs.glowscotland.org.uk\/glowblogs\/public\/phsn5computingscience\/uploads\/sites\/10033\/2022\/05\/16144416\/Screenshot-2022-05-16-144324.png 1260w\" sizes=\"auto, (max-width: 711px) 100vw, 711px\" \/><\/p>\n<p><img loading=\"lazy\" decoding=\"async\" class=\"alignnone wp-image-294\" src=\"https:\/\/blogs.glowscotland.org.uk\/glowblogs\/public\/phsn5computingscience\/uploads\/sites\/10033\/2022\/05\/16144432\/Screenshot-2022-05-16-144339-300x92.png\" alt=\"\" width=\"818\" height=\"251\" srcset=\"https:\/\/blogs.glowscotland.org.uk\/glowblogs\/public\/phsn5computingscience\/uploads\/sites\/10033\/2022\/05\/16144432\/Screenshot-2022-05-16-144339-300x92.png 300w, https:\/\/blogs.glowscotland.org.uk\/glowblogs\/public\/phsn5computingscience\/uploads\/sites\/10033\/2022\/05\/16144432\/Screenshot-2022-05-16-144339-1024x315.png 1024w, https:\/\/blogs.glowscotland.org.uk\/glowblogs\/public\/phsn5computingscience\/uploads\/sites\/10033\/2022\/05\/16144432\/Screenshot-2022-05-16-144339-768x236.png 768w, https:\/\/blogs.glowscotland.org.uk\/glowblogs\/public\/phsn5computingscience\/uploads\/sites\/10033\/2022\/05\/16144432\/Screenshot-2022-05-16-144339-624x192.png 624w, https:\/\/blogs.glowscotland.org.uk\/glowblogs\/public\/phsn5computingscience\/uploads\/sites\/10033\/2022\/05\/16144432\/Screenshot-2022-05-16-144339.png 1260w\" sizes=\"auto, (max-width: 818px) 100vw, 818px\" \/><\/p>\n<h2 style=\"color: red\"><strong>Structure Diagram \u2013 Loop Example<\/strong><\/h2>\n<p><img loading=\"lazy\" decoding=\"async\" class=\"alignnone wp-image-297\" src=\"https:\/\/blogs.glowscotland.org.uk\/glowblogs\/public\/phsn5computingscience\/uploads\/sites\/10033\/2022\/05\/16145115\/Screenshot-2022-05-16-145059-257x300.png\" alt=\"\" width=\"237\" height=\"277\" srcset=\"https:\/\/blogs.glowscotland.org.uk\/glowblogs\/public\/phsn5computingscience\/uploads\/sites\/10033\/2022\/05\/16145115\/Screenshot-2022-05-16-145059-257x300.png 257w, https:\/\/blogs.glowscotland.org.uk\/glowblogs\/public\/phsn5computingscience\/uploads\/sites\/10033\/2022\/05\/16145115\/Screenshot-2022-05-16-145059.png 490w\" sizes=\"auto, (max-width: 237px) 100vw, 237px\" \/><\/p>\n<h2 style=\"color: red\"><strong>Conditional Loop<\/strong><\/h2>\n<p>A <strong>While Loop<\/strong> (conditional loop) will repeat a selection of code <strong>while a condition is false<\/strong>.\u00a0 If that condition is not met, then the selection will repeat until the condition is true.<\/p>\n<p><img loading=\"lazy\" decoding=\"async\" class=\"alignnone wp-image-299\" src=\"https:\/\/blogs.glowscotland.org.uk\/glowblogs\/public\/phsn5computingscience\/uploads\/sites\/10033\/2022\/05\/16145629\/Screenshot-2022-05-16-145554-300x93.png\" alt=\"\" width=\"723\" height=\"224\" srcset=\"https:\/\/blogs.glowscotland.org.uk\/glowblogs\/public\/phsn5computingscience\/uploads\/sites\/10033\/2022\/05\/16145629\/Screenshot-2022-05-16-145554-300x93.png 300w, https:\/\/blogs.glowscotland.org.uk\/glowblogs\/public\/phsn5computingscience\/uploads\/sites\/10033\/2022\/05\/16145629\/Screenshot-2022-05-16-145554-1024x317.png 1024w, https:\/\/blogs.glowscotland.org.uk\/glowblogs\/public\/phsn5computingscience\/uploads\/sites\/10033\/2022\/05\/16145629\/Screenshot-2022-05-16-145554-768x238.png 768w, https:\/\/blogs.glowscotland.org.uk\/glowblogs\/public\/phsn5computingscience\/uploads\/sites\/10033\/2022\/05\/16145629\/Screenshot-2022-05-16-145554-624x193.png 624w, https:\/\/blogs.glowscotland.org.uk\/glowblogs\/public\/phsn5computingscience\/uploads\/sites\/10033\/2022\/05\/16145629\/Screenshot-2022-05-16-145554.png 1260w\" sizes=\"auto, (max-width: 723px) 100vw, 723px\" \/><\/p>\n<p><a href=\"https:\/\/blogs.glowscotland.org.uk\/glowblogs\/public\/phsn5computingscience\/uploads\/sites\/10033\/2023\/08\/30103832\/while.png\"><img loading=\"lazy\" decoding=\"async\" class=\"alignleft size-full wp-image-596\" src=\"https:\/\/blogs.glowscotland.org.uk\/glowblogs\/public\/phsn5computingscience\/uploads\/sites\/10033\/2023\/08\/30103832\/while.png\" alt=\"\" width=\"685\" height=\"109\" srcset=\"https:\/\/blogs.glowscotland.org.uk\/glowblogs\/public\/phsn5computingscience\/uploads\/sites\/10033\/2023\/08\/30103832\/while.png 685w, https:\/\/blogs.glowscotland.org.uk\/glowblogs\/public\/phsn5computingscience\/uploads\/sites\/10033\/2023\/08\/30103832\/while-300x48.png 300w, https:\/\/blogs.glowscotland.org.uk\/glowblogs\/public\/phsn5computingscience\/uploads\/sites\/10033\/2023\/08\/30103832\/while-624x99.png 624w\" sizes=\"auto, (max-width: 685px) 100vw, 685px\" \/><\/a><\/p>\n<p><img loading=\"lazy\" decoding=\"async\" class=\"alignnone wp-image-301\" src=\"https:\/\/blogs.glowscotland.org.uk\/glowblogs\/public\/phsn5computingscience\/uploads\/sites\/10033\/2022\/05\/16145720\/Screenshot-2022-05-16-145708-300x109.png\" alt=\"\" width=\"685\" height=\"249\" srcset=\"https:\/\/blogs.glowscotland.org.uk\/glowblogs\/public\/phsn5computingscience\/uploads\/sites\/10033\/2022\/05\/16145720\/Screenshot-2022-05-16-145708-300x109.png 300w, https:\/\/blogs.glowscotland.org.uk\/glowblogs\/public\/phsn5computingscience\/uploads\/sites\/10033\/2022\/05\/16145720\/Screenshot-2022-05-16-145708-1024x373.png 1024w, https:\/\/blogs.glowscotland.org.uk\/glowblogs\/public\/phsn5computingscience\/uploads\/sites\/10033\/2022\/05\/16145720\/Screenshot-2022-05-16-145708-768x280.png 768w, https:\/\/blogs.glowscotland.org.uk\/glowblogs\/public\/phsn5computingscience\/uploads\/sites\/10033\/2022\/05\/16145720\/Screenshot-2022-05-16-145708-624x227.png 624w, https:\/\/blogs.glowscotland.org.uk\/glowblogs\/public\/phsn5computingscience\/uploads\/sites\/10033\/2022\/05\/16145720\/Screenshot-2022-05-16-145708.png 1260w\" sizes=\"auto, (max-width: 685px) 100vw, 685px\" \/><\/p>\n<h2 style=\"color: red\"><strong>Structure Diagram \u2013 Conditional Loop Example<\/strong><\/h2>\n<p><img loading=\"lazy\" decoding=\"async\" class=\"alignnone size-medium wp-image-304\" src=\"https:\/\/blogs.glowscotland.org.uk\/glowblogs\/public\/phsn5computingscience\/uploads\/sites\/10033\/2022\/05\/16145924\/Screenshot-2022-05-16-145912-211x300.png\" alt=\"\" width=\"211\" height=\"300\" srcset=\"https:\/\/blogs.glowscotland.org.uk\/glowblogs\/public\/phsn5computingscience\/uploads\/sites\/10033\/2022\/05\/16145924\/Screenshot-2022-05-16-145912-211x300.png 211w, https:\/\/blogs.glowscotland.org.uk\/glowblogs\/public\/phsn5computingscience\/uploads\/sites\/10033\/2022\/05\/16145924\/Screenshot-2022-05-16-145912.png 416w\" sizes=\"auto, (max-width: 211px) 100vw, 211px\" \/><\/p>\n<p>&nbsp;<\/p>\n<p>&nbsp;<\/p>\n","protected":false},"excerpt":{"rendered":"<p>Fixed Loop A fixed loop will repeat for a set amount of time and allows the code to carry out repetitive lines of code.\u00a0 The number of times a selection of code has to be repeated is normally specified by the programmer. The For Loop has a loop counter. This counter is an integer and [&hellip;]<\/p>\n","protected":false},"author":79984,"featured_media":0,"parent":0,"menu_order":0,"comment_status":"closed","ping_status":"closed","template":"","meta":{"footnotes":""},"class_list":["post-285","page","type-page","status-publish","hentry"],"_links":{"self":[{"href":"https:\/\/blogs.glowscotland.org.uk\/glowblogs\/phsn5computingscience\/wp-json\/wp\/v2\/pages\/285","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/blogs.glowscotland.org.uk\/glowblogs\/phsn5computingscience\/wp-json\/wp\/v2\/pages"}],"about":[{"href":"https:\/\/blogs.glowscotland.org.uk\/glowblogs\/phsn5computingscience\/wp-json\/wp\/v2\/types\/page"}],"author":[{"embeddable":true,"href":"https:\/\/blogs.glowscotland.org.uk\/glowblogs\/phsn5computingscience\/wp-json\/wp\/v2\/users\/79984"}],"replies":[{"embeddable":true,"href":"https:\/\/blogs.glowscotland.org.uk\/glowblogs\/phsn5computingscience\/wp-json\/wp\/v2\/comments?post=285"}],"version-history":[{"count":12,"href":"https:\/\/blogs.glowscotland.org.uk\/glowblogs\/phsn5computingscience\/wp-json\/wp\/v2\/pages\/285\/revisions"}],"predecessor-version":[{"id":597,"href":"https:\/\/blogs.glowscotland.org.uk\/glowblogs\/phsn5computingscience\/wp-json\/wp\/v2\/pages\/285\/revisions\/597"}],"wp:attachment":[{"href":"https:\/\/blogs.glowscotland.org.uk\/glowblogs\/phsn5computingscience\/wp-json\/wp\/v2\/media?parent=285"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}