{"id":215,"date":"2023-05-26T13:24:18","date_gmt":"2023-05-26T12:24:18","guid":{"rendered":"https:\/\/blogs.glowscotland.org.uk\/glowblogs\/insidem11\/?page_id=215"},"modified":"2023-05-26T14:08:01","modified_gmt":"2023-05-26T13:08:01","slug":"program-5-detention-lines","status":"publish","type":"page","link":"https:\/\/blogs.glowscotland.org.uk\/glowblogs\/insidem11\/program-5-detention-lines\/","title":{"rendered":"Program 5: Detention Lines"},"content":{"rendered":"\n<p>Back in the day, it was common practice for teachers to issue pupils with &#8216;lines&#8217; to complete in detention. This involved writing the same thing over and over again. For example &#8216;I must remember a pencil&#8217;.<\/p>\n\n\n\n<p>This program outputs the above sentence 20 times.<\/p>\n\n\n\n<p>You can see the code below, or you can access it on repl.it by <a href=\"https:\/\/replit.com\/@MrWilsonDFSA\/Detention-Lines#main.py\">clicking here.<\/a><\/p>\n\n\n\n<h2 class=\"wp-block-heading\">Code<\/h2>\n\n\n\n<figure class=\"wp-block-image size-full\"><img loading=\"lazy\" decoding=\"async\" width=\"984\" height=\"68\" src=\"https:\/\/blogs.glowscotland.org.uk\/glowblogs\/public\/insidem11\/uploads\/sites\/10357\/2023\/05\/26133437\/image-13.png\" alt=\"\" class=\"wp-image-224\" srcset=\"https:\/\/blogs.glowscotland.org.uk\/glowblogs\/public\/insidem11\/uploads\/sites\/10357\/2023\/05\/26133437\/image-13.png 984w, https:\/\/blogs.glowscotland.org.uk\/glowblogs\/public\/insidem11\/uploads\/sites\/10357\/2023\/05\/26133437\/image-13-300x21.png 300w, https:\/\/blogs.glowscotland.org.uk\/glowblogs\/public\/insidem11\/uploads\/sites\/10357\/2023\/05\/26133437\/image-13-768x53.png 768w\" sizes=\"auto, (max-width: 984px) 100vw, 984px\" \/><\/figure>\n\n\n\n<h2 class=\"wp-block-heading\">Output<\/h2>\n\n\n\n<figure class=\"wp-block-image size-full\"><img loading=\"lazy\" decoding=\"async\" width=\"830\" height=\"217\" src=\"https:\/\/blogs.glowscotland.org.uk\/glowblogs\/public\/insidem11\/uploads\/sites\/10357\/2023\/05\/26133447\/image-14.png\" alt=\"\" class=\"wp-image-225\" srcset=\"https:\/\/blogs.glowscotland.org.uk\/glowblogs\/public\/insidem11\/uploads\/sites\/10357\/2023\/05\/26133447\/image-14.png 830w, https:\/\/blogs.glowscotland.org.uk\/glowblogs\/public\/insidem11\/uploads\/sites\/10357\/2023\/05\/26133447\/image-14-300x78.png 300w, https:\/\/blogs.glowscotland.org.uk\/glowblogs\/public\/insidem11\/uploads\/sites\/10357\/2023\/05\/26133447\/image-14-768x201.png 768w\" sizes=\"auto, (max-width: 830px) 100vw, 830px\" \/><\/figure>\n\n\n\n<h2 class=\"wp-block-heading\">New Constructs\/Concepts<\/h2>\n\n\n\n<h3 class=\"wp-block-heading\">Fixed Loop<\/h3>\n\n\n\n<p>This program introduces the concept of a &#8216;fixed loop&#8217;. This is used to repeat a block of code a fixed amount of times. In this case, the block of code is just one line (Line 3) and it is repeated 10 times.<\/p>\n\n\n\n<p>Remember that a block of code must be indented to clearly display which lines of code are part of the block.<\/p>\n\n\n\n<figure class=\"wp-block-table\"><table class=\"has-fixed-layout\"><thead><tr><th>Construct<\/th><th>Line(s)<\/th><th>Python Syntax<\/th><th>Purpose<\/th><\/tr><\/thead><tbody><tr><td>Fixed Loop<\/td><td>2<\/td><td>for index in range(x):<\/td><td>To repeat a block of code a fixed amount of times<\/td><\/tr><\/tbody><\/table><\/figure>\n\n\n\n<div class=\"wp-block-buttons is-layout-flex wp-block-buttons-is-layout-flex\">\n<div class=\"wp-block-button has-custom-width wp-block-button__width-100\"><a class=\"wp-block-button__link\" href=\"https:\/\/blogs.glowscotland.org.uk\/glowblogs\/insidem11\/program-6-detention-lines-enhanced\/\">Next: Program 6<\/a><\/div>\n<\/div>\n\n\n\n<div class=\"wp-block-buttons is-layout-flex wp-block-buttons-is-layout-flex\">\n<div class=\"wp-block-button has-custom-width wp-block-button__width-100\"><a class=\"wp-block-button__link\" href=\"https:\/\/blogs.glowscotland.org.uk\/glowblogs\/insidem11\/program-4-driving-age-checker\/\">Previous: Program 4<\/a><\/div>\n<\/div>\n","protected":false},"excerpt":{"rendered":"<p>Back in the day, it was common practice for teachers to issue pupils with &#8216;lines&#8217; to complete in detention. This involved writing the same thing over and over again. For example &#8216;I must remember a pencil&#8217;. This program outputs the above sentence 20 times. You can see the code below, or you can access it&hellip; <a class=\"more-link\" href=\"https:\/\/blogs.glowscotland.org.uk\/glowblogs\/insidem11\/program-5-detention-lines\/\">Continue reading <span class=\"screen-reader-text\">Program 5: Detention Lines<\/span><\/a><\/p>\n","protected":false},"author":73977,"featured_media":0,"parent":0,"menu_order":0,"comment_status":"closed","ping_status":"closed","template":"","meta":{"footnotes":""},"class_list":["post-215","page","type-page","status-publish","hentry","entry"],"_links":{"self":[{"href":"https:\/\/blogs.glowscotland.org.uk\/glowblogs\/insidem11\/wp-json\/wp\/v2\/pages\/215","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/blogs.glowscotland.org.uk\/glowblogs\/insidem11\/wp-json\/wp\/v2\/pages"}],"about":[{"href":"https:\/\/blogs.glowscotland.org.uk\/glowblogs\/insidem11\/wp-json\/wp\/v2\/types\/page"}],"author":[{"embeddable":true,"href":"https:\/\/blogs.glowscotland.org.uk\/glowblogs\/insidem11\/wp-json\/wp\/v2\/users\/73977"}],"replies":[{"embeddable":true,"href":"https:\/\/blogs.glowscotland.org.uk\/glowblogs\/insidem11\/wp-json\/wp\/v2\/comments?post=215"}],"version-history":[{"count":3,"href":"https:\/\/blogs.glowscotland.org.uk\/glowblogs\/insidem11\/wp-json\/wp\/v2\/pages\/215\/revisions"}],"predecessor-version":[{"id":234,"href":"https:\/\/blogs.glowscotland.org.uk\/glowblogs\/insidem11\/wp-json\/wp\/v2\/pages\/215\/revisions\/234"}],"wp:attachment":[{"href":"https:\/\/blogs.glowscotland.org.uk\/glowblogs\/insidem11\/wp-json\/wp\/v2\/media?parent=215"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}