{"id":205,"date":"2017-07-20T12:40:30","date_gmt":"2017-07-20T11:40:30","guid":{"rendered":"http:\/\/192.168.1.18\/?page_id=205"},"modified":"2017-07-21T00:47:17","modified_gmt":"2017-07-20T23:47:17","slug":"python-variables","status":"publish","type":"page","link":"http:\/\/www.bulis.co.uk\/?page_id=205","title":{"rendered":"Python: Variables"},"content":{"rendered":"<p>In mathematics variables store numerical values and are usually assigned a single letter for example <strong>E=MC<\/strong><strong>\u00b2<\/strong>. This formula states that energy (<strong>E<\/strong>) equals mass (<strong>M<\/strong>) multiplied by the speed of light (<strong>C<\/strong>) squared. When writing programs developers can use variables of any length allowing for more descriptive names; when assigning a value to a variable we use the = (equal sign). When choosing a name for your variable there are recommended coding conventions; these are outlined in PEP8. Choose clear, concise lower-case names with _ (underscores) to seperate different words.<\/p>\n<p>The above equation could use variable names like <strong>energy<\/strong> = ((<strong>mass<\/strong> * <strong>speed<\/strong>)**2):<\/p>\n<pre class=\"brush: python; title: ; notranslate\" title=\"\">\r\nmass = 1                        # Mass (kilograms)\r\nspeed = 299792458               # Speed of light (metres per second)\r\nenergy = ((mass * speed) ** 2)  # Energy (joules)\r\n<\/pre>\n<p>Output:<\/p>\n<pre class=\"brush: python; title: ; notranslate\" title=\"\">\r\n&gt;&gt;&gt; print energy\r\n89875517873681764\r\n<\/pre>\n<p>Variables can also store values of different data types i.e. numbers, text, lists etc.:<\/p>\n<pre class=\"brush: python; title: ; notranslate\" title=\"\">\r\n&gt;&gt;&gt; age = 42\r\n&gt;&gt;&gt; greeting = &quot;Hello World!&quot;\r\n&gt;&gt;&gt; parent_names = &#x5B;&quot;Brian Damage&quot;, &quot;Emma Nutter&quot;]\r\n<\/pre>\n<p>&nbsp;<\/p>\n","protected":false},"excerpt":{"rendered":"<p>In mathematics variables store numerical values and are usually assigned a single letter for example E=MC\u00b2. This formula states that energy (E) equals mass (M) multiplied by the speed of light (C) squared. When writing programs developers can use variables of any length allowing for more descriptive names; when assigning a value to a variable [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"parent":73,"menu_order":0,"comment_status":"closed","ping_status":"closed","template":"","meta":[],"acf":[],"yoast_head":"<!-- This site is optimized with the Yoast SEO plugin v20.12 - https:\/\/yoast.com\/wordpress\/plugins\/seo\/ -->\n<title>Python: Variables - Phantom Raspberry Blower<\/title>\n<meta name=\"robots\" content=\"index, follow, max-snippet:-1, max-image-preview:large, max-video-preview:-1\" \/>\n<link rel=\"canonical\" href=\"http:\/\/www.bulis.co.uk\/?page_id=205\" \/>\n<meta property=\"og:locale\" content=\"en_GB\" \/>\n<meta property=\"og:type\" content=\"article\" \/>\n<meta property=\"og:title\" content=\"Python: Variables - Phantom Raspberry Blower\" \/>\n<meta property=\"og:description\" content=\"In mathematics variables store numerical values and are usually assigned a single letter for example E=MC\u00b2. This formula states that energy (E) equals mass (M) multiplied by the speed of light (C) squared. When writing programs developers can use variables of any length allowing for more descriptive names; when assigning a value to a variable [&hellip;]\" \/>\n<meta property=\"og:url\" content=\"http:\/\/www.bulis.co.uk\/?page_id=205\" \/>\n<meta property=\"og:site_name\" content=\"Phantom Raspberry Blower\" \/>\n<meta property=\"article:modified_time\" content=\"2017-07-20T23:47:17+00:00\" \/>\n<meta name=\"twitter:card\" content=\"summary_large_image\" \/>\n<meta name=\"twitter:label1\" content=\"Estimated reading time\" \/>\n\t<meta name=\"twitter:data1\" content=\"1 minute\" \/>\n<script type=\"application\/ld+json\" class=\"yoast-schema-graph\">{\"@context\":\"https:\/\/schema.org\",\"@graph\":[{\"@type\":\"WebPage\",\"@id\":\"http:\/\/www.bulis.co.uk\/?page_id=205\",\"url\":\"http:\/\/www.bulis.co.uk\/?page_id=205\",\"name\":\"Python: Variables - Phantom Raspberry Blower\",\"isPartOf\":{\"@id\":\"http:\/\/www.bulis.co.uk\/#website\"},\"datePublished\":\"2017-07-20T11:40:30+00:00\",\"dateModified\":\"2017-07-20T23:47:17+00:00\",\"breadcrumb\":{\"@id\":\"http:\/\/www.bulis.co.uk\/?page_id=205#breadcrumb\"},\"inLanguage\":\"en-GB\",\"potentialAction\":[{\"@type\":\"ReadAction\",\"target\":[\"http:\/\/www.bulis.co.uk\/?page_id=205\"]}]},{\"@type\":\"BreadcrumbList\",\"@id\":\"http:\/\/www.bulis.co.uk\/?page_id=205#breadcrumb\",\"itemListElement\":[{\"@type\":\"ListItem\",\"position\":1,\"name\":\"Home\",\"item\":\"http:\/\/www.bulis.co.uk\/\"},{\"@type\":\"ListItem\",\"position\":2,\"name\":\"Tutorials\",\"item\":\"http:\/\/www.bulis.co.uk\/?page_id=57\"},{\"@type\":\"ListItem\",\"position\":3,\"name\":\"Python Tutorials\",\"item\":\"http:\/\/www.bulis.co.uk\/?page_id=73\"},{\"@type\":\"ListItem\",\"position\":4,\"name\":\"Python: Variables\"}]},{\"@type\":\"WebSite\",\"@id\":\"http:\/\/www.bulis.co.uk\/#website\",\"url\":\"http:\/\/www.bulis.co.uk\/\",\"name\":\"Phantom Raspberry Blower\",\"description\":\"Blowing Raspberrys since 1989\",\"potentialAction\":[{\"@type\":\"SearchAction\",\"target\":{\"@type\":\"EntryPoint\",\"urlTemplate\":\"http:\/\/www.bulis.co.uk\/?s={search_term_string}\"},\"query-input\":\"required name=search_term_string\"}],\"inLanguage\":\"en-GB\"}]}<\/script>\n<!-- \/ Yoast SEO plugin. -->","yoast_head_json":{"title":"Python: Variables - Phantom Raspberry Blower","robots":{"index":"index","follow":"follow","max-snippet":"max-snippet:-1","max-image-preview":"max-image-preview:large","max-video-preview":"max-video-preview:-1"},"canonical":"http:\/\/www.bulis.co.uk\/?page_id=205","og_locale":"en_GB","og_type":"article","og_title":"Python: Variables - Phantom Raspberry Blower","og_description":"In mathematics variables store numerical values and are usually assigned a single letter for example E=MC\u00b2. This formula states that energy (E) equals mass (M) multiplied by the speed of light (C) squared. When writing programs developers can use variables of any length allowing for more descriptive names; when assigning a value to a variable [&hellip;]","og_url":"http:\/\/www.bulis.co.uk\/?page_id=205","og_site_name":"Phantom Raspberry Blower","article_modified_time":"2017-07-20T23:47:17+00:00","twitter_card":"summary_large_image","twitter_misc":{"Estimated reading time":"1 minute"},"schema":{"@context":"https:\/\/schema.org","@graph":[{"@type":"WebPage","@id":"http:\/\/www.bulis.co.uk\/?page_id=205","url":"http:\/\/www.bulis.co.uk\/?page_id=205","name":"Python: Variables - Phantom Raspberry Blower","isPartOf":{"@id":"http:\/\/www.bulis.co.uk\/#website"},"datePublished":"2017-07-20T11:40:30+00:00","dateModified":"2017-07-20T23:47:17+00:00","breadcrumb":{"@id":"http:\/\/www.bulis.co.uk\/?page_id=205#breadcrumb"},"inLanguage":"en-GB","potentialAction":[{"@type":"ReadAction","target":["http:\/\/www.bulis.co.uk\/?page_id=205"]}]},{"@type":"BreadcrumbList","@id":"http:\/\/www.bulis.co.uk\/?page_id=205#breadcrumb","itemListElement":[{"@type":"ListItem","position":1,"name":"Home","item":"http:\/\/www.bulis.co.uk\/"},{"@type":"ListItem","position":2,"name":"Tutorials","item":"http:\/\/www.bulis.co.uk\/?page_id=57"},{"@type":"ListItem","position":3,"name":"Python Tutorials","item":"http:\/\/www.bulis.co.uk\/?page_id=73"},{"@type":"ListItem","position":4,"name":"Python: Variables"}]},{"@type":"WebSite","@id":"http:\/\/www.bulis.co.uk\/#website","url":"http:\/\/www.bulis.co.uk\/","name":"Phantom Raspberry Blower","description":"Blowing Raspberrys since 1989","potentialAction":[{"@type":"SearchAction","target":{"@type":"EntryPoint","urlTemplate":"http:\/\/www.bulis.co.uk\/?s={search_term_string}"},"query-input":"required name=search_term_string"}],"inLanguage":"en-GB"}]}},"_links":{"self":[{"href":"http:\/\/www.bulis.co.uk\/index.php?rest_route=\/wp\/v2\/pages\/205"}],"collection":[{"href":"http:\/\/www.bulis.co.uk\/index.php?rest_route=\/wp\/v2\/pages"}],"about":[{"href":"http:\/\/www.bulis.co.uk\/index.php?rest_route=\/wp\/v2\/types\/page"}],"author":[{"embeddable":true,"href":"http:\/\/www.bulis.co.uk\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"http:\/\/www.bulis.co.uk\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=205"}],"version-history":[{"count":0,"href":"http:\/\/www.bulis.co.uk\/index.php?rest_route=\/wp\/v2\/pages\/205\/revisions"}],"up":[{"embeddable":true,"href":"http:\/\/www.bulis.co.uk\/index.php?rest_route=\/wp\/v2\/pages\/73"}],"wp:attachment":[{"href":"http:\/\/www.bulis.co.uk\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=205"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}