{"id":348,"date":"2021-03-16T10:03:41","date_gmt":"2021-03-16T10:03:41","guid":{"rendered":"https:\/\/blogs.glowscotland.org.uk\/sh\/ahscomputingpython\/?page_id=348"},"modified":"2021-03-16T12:44:16","modified_gmt":"2021-03-16T12:44:16","slug":"conventions","status":"publish","type":"page","link":"https:\/\/blogs.glowscotland.org.uk\/sh\/ahscomputingpython\/reference\/conventions\/","title":{"rendered":"Conventions"},"content":{"rendered":"<h1>Program Structure<\/h1>\n<p>For readability, programs should follow a standard layout:<\/p>\n<pre>imports\nconstants\nrecord\/object definitions\nsubprograms\nmain program<\/pre>\n<h1>Naming Conventions<\/h1>\n<p>Proper use of capitalisation and plurals makes lines like this readable:<\/p>\n<pre>students = [Student() for student in range(STUDENTS)]<\/pre>\n<h2>Capital and small letters<\/h2>\n<p>Constants should be in full capitals:<\/p>\n<pre>NUMBER_OF_STUDENTS = 20<\/pre>\n<p>All variables and subprogram names should be in either <em>camelCase<\/em> or <em>snake_case.<br \/>\n<\/em>Be consistent &#8211; use one or the other, but not both:<\/p>\n<pre>studentName = \"fred\"\nstudent_name = \"fred\"<\/pre>\n<p>Record definitions should be in <em>PascalCase<\/em>:<\/p>\n<pre>@dataclass\nclass SchoolPupil:<\/pre>\n<h2>Singular and Plural Names<\/h2>\n<p>Variables that store a single value should use singular names:<\/p>\n<pre><strong>name<\/strong> = \"fred\"\nage = 23\n<\/pre>\n<p>Variables that store a several values (arrays and lists) should use plural names:<\/p>\n<pre>names = [\"fred\", \"sue\", \"alice\", \"mark\"]\nages = [23, 45, 12, 19]\n<\/pre>\n","protected":false},"excerpt":{"rendered":"<p>Program Structure For readability, programs should follow a standard layout: imports constants record\/object definitions subprograms main program Naming Conventions Proper use of capitalisation and plurals makes lines like this readable: students = [Student() for student in range(STUDENTS)] Capital and small letters Constants should be in full capitals: NUMBER_OF_STUDENTS = 20 All variables and subprogram names should be in either camelCase or snake_case. Be consistent &#8211; use one or the other,<\/p>\n<p><a class=\"more-link\" href=\"https:\/\/blogs.glowscotland.org.uk\/sh\/ahscomputingpython\/reference\/conventions\/\">Read More<\/a><\/p>\n","protected":false},"author":7,"featured_media":0,"parent":294,"menu_order":0,"comment_status":"closed","ping_status":"closed","template":"","meta":{"footnotes":""},"class_list":["post-348","page","type-page","status-publish","hentry"],"_links":{"self":[{"href":"https:\/\/blogs.glowscotland.org.uk\/sh\/ahscomputingpython\/wp-json\/wp\/v2\/pages\/348","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=348"}],"version-history":[{"count":7,"href":"https:\/\/blogs.glowscotland.org.uk\/sh\/ahscomputingpython\/wp-json\/wp\/v2\/pages\/348\/revisions"}],"predecessor-version":[{"id":361,"href":"https:\/\/blogs.glowscotland.org.uk\/sh\/ahscomputingpython\/wp-json\/wp\/v2\/pages\/348\/revisions\/361"}],"up":[{"embeddable":true,"href":"https:\/\/blogs.glowscotland.org.uk\/sh\/ahscomputingpython\/wp-json\/wp\/v2\/pages\/294"}],"wp:attachment":[{"href":"https:\/\/blogs.glowscotland.org.uk\/sh\/ahscomputingpython\/wp-json\/wp\/v2\/media?parent=348"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}