{"id":97,"date":"2021-03-11T17:22:59","date_gmt":"2021-03-11T17:22:59","guid":{"rendered":"https:\/\/blogs.glowscotland.org.uk\/sh\/ahscomputingpython\/?page_id=97"},"modified":"2021-03-15T19:39:48","modified_gmt":"2021-03-15T19:39:48","slug":"decisions","status":"publish","type":"page","link":"https:\/\/blogs.glowscotland.org.uk\/sh\/ahscomputingpython\/nat4\/decisions\/","title":{"rendered":"Decisions (if commands)"},"content":{"rendered":"<p>Python programs use <strong>if<\/strong> commands and <a href=\"https:\/\/blogs.glowscotland.org.uk\/sh\/ahscomputingpython\/conditions\/\">conditions<\/a> to make decisions.<\/p>\n<p>Indentation (4 spaces) is used to show what actions have to be taken.<\/p>\n<h1>if<\/h1>\n<p>Do something or nothing:<\/p>\n<pre class=\"brush: python; title: ; notranslate\" title=\"\">\r\n#\r\nif temperature &lt; 17:\r\n    print('It is too cold')\r\n#\r\n<\/pre>\n<h1>if-else<\/h1>\n<p>Do one thing or another:<\/p>\n<pre class=\"brush: python; title: ; notranslate\" title=\"\">\r\n#\r\nif speed &gt; 60:\r\n    print('That is over the national speed limit')\r\nelse:\r\n    print('That is inside the national speed limit')    \r\n# <\/pre>\n<h1>if-elif-else:<\/h1>\n<p>Do one of several things:<\/p>\n<pre class=\"brush: python; title: ; notranslate\" title=\"\">\r\n#\r\nif mark &gt;= 70:\r\n    grade = 'A' \r\nelif mark &gt;=60:  \r\n    grade = 'B'\r\nelif mark &gt;=50:\r\n    grade = 'C'\r\nelif mark &gt;=40:\r\n    grade = &quot;D&quot;\r\nelse:\r\n    grade = &quot;F&quot;\r\n# <\/pre>\n<pre><\/pre>\n","protected":false},"excerpt":{"rendered":"<p>Python programs use if commands and conditions to make decisions. Indentation (4 spaces) is used to show what actions have to be taken. if Do something or nothing: # if temperature &lt; 17: print(&#8216;It is too cold&#8217;) # if-else Do one thing or another: # if speed &gt; 60: print(&#8216;That is over the national speed limit&#8217;) else: print(&#8216;That is inside the national speed limit&#8217;) # if-elif-else: Do one of several<\/p>\n<p><a class=\"more-link\" href=\"https:\/\/blogs.glowscotland.org.uk\/sh\/ahscomputingpython\/nat4\/decisions\/\">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-97","page","type-page","status-publish","hentry"],"_links":{"self":[{"href":"https:\/\/blogs.glowscotland.org.uk\/sh\/ahscomputingpython\/wp-json\/wp\/v2\/pages\/97","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=97"}],"version-history":[{"count":14,"href":"https:\/\/blogs.glowscotland.org.uk\/sh\/ahscomputingpython\/wp-json\/wp\/v2\/pages\/97\/revisions"}],"predecessor-version":[{"id":207,"href":"https:\/\/blogs.glowscotland.org.uk\/sh\/ahscomputingpython\/wp-json\/wp\/v2\/pages\/97\/revisions\/207"}],"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=97"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}