{"id":908,"date":"2020-01-10T15:03:28","date_gmt":"2020-01-10T15:03:28","guid":{"rendered":"https:\/\/netlab.com.ph\/?p=908"},"modified":"2020-01-10T15:03:28","modified_gmt":"2020-01-10T15:03:28","slug":"coding-concepts-part-two","status":"publish","type":"post","link":"https:\/\/netlab.com.ph\/?p=908","title":{"rendered":"Coding Concepts &#8211; Part Two"},"content":{"rendered":"\n<p><strong>Variables<\/strong><\/p>\n\n\n\n<p>Variables hold a specific type of information. Programmers use variables to hold the value of information that may change. &nbsp;For example, a game program can have a variable to hold the current player&#8217;s score. <\/p>\n\n\n\n<p>Microbit variables can be numbers, strings, booleans, sprites and arrays. To use a variable, you assign a type of information it should hold. From that point forward, you can only change the value of that variable to another value of the same type. <\/p>\n\n\n\n<figure class=\"wp-block-image\"><img decoding=\"async\" src=\"https:\/\/netlab.com.ph\/wp-content\/uploads\/2020\/01\/variables.jpg\" alt=\"\" class=\"wp-image-909\" \/><\/figure>\n\n\n\n<ul class=\"wp-block-list\"><li>A number variable could hold numerical data such as the score, the year, age, etc..<\/li><li>A string variable holds a string of alphanumeric characters such as a person\u2019s name, a password, address, etc..<\/li><li>A Boolean variable has only two values: true or false. For example, you might have certain things that happen only when the variable called Bonus is true.<\/li><li>A sprite is a special variable that represents a single dot on the screen and holds two separate values for the row and column the dot is currently in.<\/li><li>An array is another special type of variable that holds a list of multiple items.<\/li><li><\/li><\/ul>\n\n\n\n<p><strong>Iterations<\/strong><\/p>\n\n\n\n<p>Certain\nsequence of commands are commonly repeated several times in a program, this is\ncalled iteration. &nbsp;Computer programmers\ncan use a special type of code called a loop around the commands they want to\nrepeat as a form of iteration. A loop repeats code until a certain condition is\nmet.<\/p>\n\n\n\n<p>There\nare three types of loops in Microsoft Make Code:<\/p>\n\n\n\n<ul class=\"wp-block-list\"><li>repeat block \u2013 This block repeats the code n\nnumber of times.<\/li><\/ul>\n\n\n\n<figure class=\"wp-block-image\"><img decoding=\"async\" src=\"https:\/\/netlab.com.ph\/wp-content\/uploads\/2020\/01\/repeat.jpg\" alt=\"\" class=\"wp-image-910\" \/><\/figure>\n\n\n\n<ul class=\"wp-block-list\"><li>while block \u2013 This block runs the code as long\nas the condition inside of it is true.<\/li><\/ul>\n\n\n\n<figure class=\"wp-block-image\"><img decoding=\"async\" src=\"https:\/\/netlab.com.ph\/wp-content\/uploads\/2020\/01\/while.jpg\" alt=\"\" class=\"wp-image-911\" \/><\/figure>\n\n\n\n<p>for block \u2013 This block repeats the code n number of times, but with a variable.<\/p>\n\n\n\n<figure class=\"wp-block-image\"><img decoding=\"async\" src=\"https:\/\/netlab.com.ph\/wp-content\/uploads\/2020\/01\/for.jpg\" alt=\"\" class=\"wp-image-913\" \/><\/figure>\n\n\n\n<p>As an example, let us take the last sample program from&nbsp; Lesson 8: Controlling individual onboard LED and use a for block loop to simplify the program. Assign coordinate y&nbsp; for the iteration and lit and unlit it five times.&nbsp; Note that the x coordinate should retain the value 2 since the value of the &nbsp;horizontal remains the same.<\/p>\n\n\n\n<figure class=\"wp-block-image\"><img decoding=\"async\" src=\"https:\/\/netlab.com.ph\/wp-content\/uploads\/2020\/01\/racing_led2.jpg\" alt=\"\" class=\"wp-image-915\" \/><\/figure>\n","protected":false},"excerpt":{"rendered":"<p>Variables Variables hold a specific type of information. Programmers use variables to hold the value of information that may change. &nbsp;For example, a game program can have a variable to hold the current player&#8217;s score. Microbit variables can be numbers, <a href=\"https:\/\/netlab.com.ph\/?p=908\" class=\"read-more\">Read More &#8230;<\/a><\/p>\n","protected":false},"author":2,"featured_media":0,"comment_status":"open","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[2],"tags":[],"class_list":["post-908","post","type-post","status-publish","format-standard","hentry","category-microbit"],"_links":{"self":[{"href":"https:\/\/netlab.com.ph\/index.php?rest_route=\/wp\/v2\/posts\/908","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/netlab.com.ph\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/netlab.com.ph\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/netlab.com.ph\/index.php?rest_route=\/wp\/v2\/users\/2"}],"replies":[{"embeddable":true,"href":"https:\/\/netlab.com.ph\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=908"}],"version-history":[{"count":0,"href":"https:\/\/netlab.com.ph\/index.php?rest_route=\/wp\/v2\/posts\/908\/revisions"}],"wp:attachment":[{"href":"https:\/\/netlab.com.ph\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=908"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/netlab.com.ph\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=908"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/netlab.com.ph\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=908"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}