{"id":2382,"date":"2021-09-20T16:31:26","date_gmt":"2021-09-20T15:31:26","guid":{"rendered":"https:\/\/blogs.glowscotland.org.uk\/nl\/ColtnessHS-ComputingScience\/?p=2382"},"modified":"2021-09-20T16:45:22","modified_gmt":"2021-09-20T15:45:22","slug":"national-5-sdd-predefined-functions","status":"publish","type":"post","link":"https:\/\/blogs.glowscotland.org.uk\/nl\/ColtnessHS-ComputingScience\/2021\/09\/20\/national-5-sdd-predefined-functions\/","title":{"rendered":"National 5 &#8211; SDD Predefined Functions"},"content":{"rendered":"<p>So today we were looking over predefined function.\u00a0For the N5 course we have to be aware of RANDOM, ROUND, &amp; LENGTH.<\/p>\n<p>The <em><strong>RANDOM<\/strong> <\/em>function picks an integer between two values.<\/p>\n<pre class=\"brush: python; title: ; notranslate\" title=\"\">\r\nimport random\r\nnumber=random.randint(1,20) # random(StartValue,EndValue)\r\nprint(number)\r\n<\/pre>\n<p>The <em><strong>ROUND<\/strong> <\/em>function rounds a real number (floating point) to a fixed number of decimal points.<\/p>\n<pre class=\"brush: python; title: ; notranslate\" title=\"\">\r\na=1.2 # 1\r\nb=2.6 # 3\r\nc=2.5 # 2\r\nd=3.5 # 4\r\ne=3.453444354\r\n\r\nprint(round(e,2)) # round(valueToRound,NoOfDecimalDigits)\r\n<\/pre>\n<p>The <em><strong>LENGTH<\/strong> <\/em>function displays the number of characters in a String or the length of an Array.<\/p>\n<pre class=\"brush: python; title: ; notranslate\" title=\"\">\r\nname=&quot;Stratton was here&quot;\r\nnumbers=&#x5B;1,2,3,4,2,3,4,6,4,3,2,43]\r\nprint(len(name))\r\nprint(len(numbers))\r\nprint(numbers)\r\n\r\nfor index in range(len(numbers)):\r\n    print(numbers&#x5B;index])\r\n\r\nfor index in range(len(name)):\r\n    print(name&#x5B;index])\r\n<\/pre>\n<p>&nbsp;<\/p>\n","protected":false},"excerpt":{"rendered":"<p>So today we were looking over predefined function.\u00a0For the N5 course we have to be aware of RANDOM, ROUND, &amp; LENGTH. The RANDOM function picks an integer between two values. import random number=random.randint(1,20) # random(StartValue,EndValue) print(number) The ROUND function rounds a real number (floating point) to a fixed number of decimal points. a=1.2 # 1 &hellip;<\/p>\n","protected":false},"author":32,"featured_media":1385,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[17932,432053,17009],"tags":[9753,432107,13697,432106],"class_list":["post-2382","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-computational-constructs","category-national-5-2","category-software-design-devlopment","tag-function","tag-length","tag-random","tag-round"],"jetpack_featured_media_url":"https:\/\/blogs.glowscotland.org.uk\/nl\/public\/ColtnessHS-ComputingScience\/uploads\/sites\/12638\/2016\/09\/Slide3.png","jetpack_sharing_enabled":true,"_links":{"self":[{"href":"https:\/\/blogs.glowscotland.org.uk\/nl\/ColtnessHS-ComputingScience\/wp-json\/wp\/v2\/posts\/2382","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=2382"}],"version-history":[{"count":6,"href":"https:\/\/blogs.glowscotland.org.uk\/nl\/ColtnessHS-ComputingScience\/wp-json\/wp\/v2\/posts\/2382\/revisions"}],"predecessor-version":[{"id":2388,"href":"https:\/\/blogs.glowscotland.org.uk\/nl\/ColtnessHS-ComputingScience\/wp-json\/wp\/v2\/posts\/2382\/revisions\/2388"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/blogs.glowscotland.org.uk\/nl\/ColtnessHS-ComputingScience\/wp-json\/wp\/v2\/media\/1385"}],"wp:attachment":[{"href":"https:\/\/blogs.glowscotland.org.uk\/nl\/ColtnessHS-ComputingScience\/wp-json\/wp\/v2\/media?parent=2382"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/blogs.glowscotland.org.uk\/nl\/ColtnessHS-ComputingScience\/wp-json\/wp\/v2\/categories?post=2382"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/blogs.glowscotland.org.uk\/nl\/ColtnessHS-ComputingScience\/wp-json\/wp\/v2\/tags?post=2382"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}