{"id":881,"date":"2015-09-21T11:48:08","date_gmt":"2015-09-21T11:48:08","guid":{"rendered":"https:\/\/blogs.glowscotland.org.uk\/nl\/ColtnessHS-ComputingScience\/?p=881"},"modified":"2015-09-21T11:48:08","modified_gmt":"2015-09-21T11:48:08","slug":"python-functions","status":"publish","type":"post","link":"https:\/\/blogs.glowscotland.org.uk\/nl\/ColtnessHS-ComputingScience\/2015\/09\/21\/python-functions\/","title":{"rendered":"Python Functions"},"content":{"rendered":"<p>A function is a predefined block of code which is used then programming. It often contains a number of commands and steps.<\/p>\n<p>Here are some of the functions we have met<\/p>\n<h3>print()<\/h3>\n<p>This function displays the string that is contained in it parenthesis ().<\/p>\n<p><em>print(&#8216;Hi there, how are you?)<\/em><\/p>\n<h3>input()<\/h3>\n<p>This function displays the string in its parenthesis but allows the user to enter a string that is then returned and assigned to a variable.<\/p>\n<p><em>age=input(&#8216;What is your age?&#8217;)<\/em><\/p>\n<h3>str()<\/h3>\n<p>Converts the contents of its parenthesis to a string<\/p>\n<p><em>check=input(&#8216;Is your age &#8216;+str(age))<\/em><\/p>\n<h3>len()<\/h3>\n<p>Outputs the length (number of characters) of a string or the size (number of elements) in an array<\/p>\n<p><em>print(&#8216;The length of your name is&#8217;,len(name))<\/em><\/p>\n<h3>float()<\/h3>\n<p>Converts a value to a floating point number<\/p>\n<p><em>weight=float(input(&#8216;How many KG do you weight&#8217;))<\/em><\/p>\n<h3>int()<\/h3>\n<p>Converts a value to an integer<\/p>\n<p><em>age=int(input(&#8216;What is your age?&#8217;)<\/em>)<\/p>\n<p>&nbsp;<\/p>\n","protected":false},"excerpt":{"rendered":"<p>A function is a predefined block of code which is used then programming. It often contains a number of commands and steps. Here are some of the functions we have met print() This function displays the string that is contained in it parenthesis (). print(&#8216;Hi there, how are you?) input() This function displays the string &hellip;<\/p>\n","protected":false},"author":32,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[17932,17012,319,17013,17009],"tags":[30618,9753,9849,21482,12735,125716,125722],"class_list":["post-881","post","type-post","status-publish","format-standard","hentry","category-computational-constructs","category-national-4","category-oldhigher","category-national-5","category-software-design-devlopment","tag-float","tag-function","tag-input","tag-int","tag-len","tag-print","tag-str"],"jetpack_featured_media_url":"","jetpack_sharing_enabled":true,"_links":{"self":[{"href":"https:\/\/blogs.glowscotland.org.uk\/nl\/ColtnessHS-ComputingScience\/wp-json\/wp\/v2\/posts\/881","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=881"}],"version-history":[{"count":1,"href":"https:\/\/blogs.glowscotland.org.uk\/nl\/ColtnessHS-ComputingScience\/wp-json\/wp\/v2\/posts\/881\/revisions"}],"predecessor-version":[{"id":882,"href":"https:\/\/blogs.glowscotland.org.uk\/nl\/ColtnessHS-ComputingScience\/wp-json\/wp\/v2\/posts\/881\/revisions\/882"}],"wp:attachment":[{"href":"https:\/\/blogs.glowscotland.org.uk\/nl\/ColtnessHS-ComputingScience\/wp-json\/wp\/v2\/media?parent=881"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/blogs.glowscotland.org.uk\/nl\/ColtnessHS-ComputingScience\/wp-json\/wp\/v2\/categories?post=881"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/blogs.glowscotland.org.uk\/nl\/ColtnessHS-ComputingScience\/wp-json\/wp\/v2\/tags?post=881"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}