{"id":967,"date":"2015-11-30T15:42:44","date_gmt":"2015-11-30T15:42:44","guid":{"rendered":"https:\/\/blogs.glowscotland.org.uk\/nl\/ColtnessHS-ComputingScience\/?p=967"},"modified":"2015-11-30T15:43:55","modified_gmt":"2015-11-30T15:43:55","slug":"national-5-boolean","status":"publish","type":"post","link":"https:\/\/blogs.glowscotland.org.uk\/nl\/ColtnessHS-ComputingScience\/2015\/11\/30\/national-5-boolean\/","title":{"rendered":"National 5 &#8211; Boolean"},"content":{"rendered":"<p>A<span style=\"text-decoration: underline\"> boolean variable<\/span> is used to store <em>True<\/em> or <em>False<\/em> values. This can be very useful in programs, as you can use it in the program logic.<\/p>\n<p>In the example below the user has to choose to exit the program, this sets the <em>quitProg\u00a0<\/em>boolean variable to <em>True<\/em> which makes the result of the condition in line 3 <em>False<\/em>. Notice that True\/False have capitals at the start of the value.<\/p>\n<div style=\"background: #ffffff;overflow: auto;width: auto;border: solid gray;border-width: .1em .1em .1em .8em;padding: .2em .6em\">\n<table>\n<tbody>\n<tr>\n<td>\n<pre style=\"margin: 0;line-height: 125%\"> 1\r\n 2\r\n 3\r\n 4\r\n 5\r\n 6\r\n 7\r\n 8\r\n 9\r\n10\r\n11<\/pre>\n<\/td>\n<td>\n<pre style=\"margin: 0;line-height: 125%\">quitProg<span style=\"color: #333333\">=<\/span><span style=\"color: #007020\">False<\/span>\r\n\r\n<span style=\"color: #008800;font-weight: bold\">while<\/span> <span style=\"color: #000000;font-weight: bold\">not<\/span> quitProg:\r\n\r\n    <span style=\"color: #888888\">#Program does stuff here<\/span>\r\n    \r\n    choice<span style=\"color: #333333\">=<\/span><span style=\"color: #007020\">input<\/span>(<span style=\"background-color: #fff0f0\">'Do you want to quit (Y\/N):'<\/span>)\r\n    <span style=\"color: #008800;font-weight: bold\">if<\/span> choice <span style=\"color: #000000;font-weight: bold\">in<\/span> <span style=\"background-color: #fff0f0\">'Yy'<\/span>:\r\n        quitProg<span style=\"color: #333333\">=<\/span><span style=\"color: #007020\">True<\/span>\r\n\r\n<span style=\"color: #008800;font-weight: bold\">print<\/span>(<span style=\"background-color: #fff0f0\">'Exiting program'<\/span>)    \r\n<\/pre>\n<\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n<\/div>\n","protected":false},"excerpt":{"rendered":"<p>A boolean variable is used to store True or False values. This can be very useful in programs, as you can use it in the program logic. In the example below the user has to choose to exit the program, this sets the quitProg\u00a0boolean variable to True which makes the result of the condition in &hellip;<\/p>\n","protected":false},"author":32,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[17933,17009],"tags":[125735,125737,6910,125736],"class_list":["post-967","post","type-post","status-publish","format-standard","hentry","category-data-types-and-structures","category-software-design-devlopment","tag-boolean","tag-exit-program","tag-quit","tag-while"],"jetpack_featured_media_url":"","jetpack_sharing_enabled":true,"_links":{"self":[{"href":"https:\/\/blogs.glowscotland.org.uk\/nl\/ColtnessHS-ComputingScience\/wp-json\/wp\/v2\/posts\/967","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/blogs.glowscotland.org.uk\/nl\/ColtnessHS-ComputingScience\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/blogs.glowscotland.org.uk\/nl\/ColtnessHS-ComputingScience\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/blogs.glowscotland.org.uk\/nl\/ColtnessHS-ComputingScience\/wp-json\/wp\/v2\/users\/32"}],"replies":[{"embeddable":true,"href":"https:\/\/blogs.glowscotland.org.uk\/nl\/ColtnessHS-ComputingScience\/wp-json\/wp\/v2\/comments?post=967"}],"version-history":[{"count":4,"href":"https:\/\/blogs.glowscotland.org.uk\/nl\/ColtnessHS-ComputingScience\/wp-json\/wp\/v2\/posts\/967\/revisions"}],"predecessor-version":[{"id":971,"href":"https:\/\/blogs.glowscotland.org.uk\/nl\/ColtnessHS-ComputingScience\/wp-json\/wp\/v2\/posts\/967\/revisions\/971"}],"wp:attachment":[{"href":"https:\/\/blogs.glowscotland.org.uk\/nl\/ColtnessHS-ComputingScience\/wp-json\/wp\/v2\/media?parent=967"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/blogs.glowscotland.org.uk\/nl\/ColtnessHS-ComputingScience\/wp-json\/wp\/v2\/categories?post=967"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/blogs.glowscotland.org.uk\/nl\/ColtnessHS-ComputingScience\/wp-json\/wp\/v2\/tags?post=967"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}