{"id":359,"date":"2020-03-10T06:45:57","date_gmt":"2020-03-10T06:45:57","guid":{"rendered":"http:\/\/learnlearn.uk\/alevelcs\/?page_id=359"},"modified":"2021-03-26T06:54:46","modified_gmt":"2021-03-26T06:54:46","slug":"syntax-runtime-logical-errors","status":"publish","type":"page","link":"https:\/\/learnlearn.uk\/alevelcs\/syntax-runtime-logical-errors\/","title":{"rendered":"Syntax, Runtime and Logical Errors"},"content":{"rendered":"<div class=\"responsive-tabs\">\n<h2 class=\"tabtitle\">Tutorial Video<\/h2>\n<div class=\"tabcontent\">\n\n<h3>Syntax, Runtime and Logical Errors Tutorial Video<\/h3>\n<p><a href=\"https:\/\/drive.google.com\/open?id=1T8bmxFrRuqyAVgKYx1zDsp-xfvgTpke_\">Can&#8217;t access YouTube? Click Here<\/a><\/p>\n<div class=\"nv-iframe-embed\">\n<div class=\"container-lazyload preview-lazyload container-youtube js-lazyload--not-loaded\"><a href=\"https:\/\/www.youtube.com\/watch?v=ToPP5UGgJUM\" class=\"lazy-load-youtube preview-lazyload preview-youtube\" data-video-title=\"Syntax, Runtime and Logical Errors in Python\" title=\"Play video &quot;Syntax, Runtime and Logical Errors in Python&quot;\">https:\/\/www.youtube.com\/watch?v=ToPP5UGgJUM<\/a><noscript>Video can&#8217;t be loaded because JavaScript is disabled: <a href=\"https:\/\/www.youtube.com\/watch?v=ToPP5UGgJUM\" title=\"Syntax, Runtime and Logical Errors in Python\">Syntax, Runtime and Logical Errors in Python (https:\/\/www.youtube.com\/watch?v=ToPP5UGgJUM)<\/a><\/noscript><\/div>\n<\/div>\n<p>&nbsp;<\/p>\n\n<\/div><h2 class=\"tabtitle\">Syntax Errors<\/h2>\n<div class=\"tabcontent\">\n\n<h3>Syntax Errors<\/h3>\n<p><img decoding=\"async\" loading=\"lazy\" class=\"alignright size-full wp-image-571\" src=\"https:\/\/learnlearn.uk\/gcsecs\/wp-content\/uploads\/sites\/8\/2017\/01\/error2.jpg\" alt=\"Syntax, Runtime and Logical Errors\" width=\"225\" height=\"225\" \/><\/p>\n<p>These are errors where the computer cannot interpret the inputted code and therefore cannot compile or translate the code.<\/p>\n<p>These ares are usually the first errors that a programmer will encounter and are the easiest to spot, as the computer will usually inform you of the offending line.<\/p>\n<p><strong>Example 1<\/strong><\/p>\n<pre>name = input('Nice to meet you)<\/pre>\n<p>Here the code is missing a closing inverted comma.<\/p>\n<p><strong>Example 2<\/strong><\/p>\n<pre>age = int(input(\"how old are you?\")))<\/pre>\n<p>Here the code has closed too many brackets.<\/p>\n\n<\/div><h2 class=\"tabtitle\">Runtime Errors<\/h2>\n<div class=\"tabcontent\">\n\n<h3>Runtime errors<\/h3>\n<p>These are errors that are not detected until the program is running. The program executes successfully until a certain point, where it crashes.<\/p>\n<p>These errors often occur because of:<\/p>\n<ul>\n<li>Failing to does type conversions (e.g. from string it integer)<\/li>\n<\/ul>\n<p><strong>Example 1<\/strong><\/p>\n<pre>age = input('How old are you?')\r\n\r\nif age &gt; 50:\r\n\r\n\u00a0 \u00a0 print('You are old!')<\/pre>\n<p>Here the program will successfully run and ask for an age input. However on the second line the program will crash because age has been input as a string and therefore needs to be reassigned or cast as an integer before being compared to the 50.<\/p>\n<p><strong>Example 2<\/strong><\/p>\n<pre>shopping = ['cheese','egg','beef']\r\n\r\nprint(shopping[3])<\/pre>\n<p>Here the program will crash when it attempts to\u00a0 print out index 3. This is because Python starts indexing from 0, not 1 and therefore item 3 does not exist.<\/p>\n<p>&nbsp;<\/p>\n\n<\/div><h2 class=\"tabtitle\">Logical<\/h2>\n<div class=\"tabcontent\">\n\n<h3>Logical Errors<\/h3>\n<p>These are errors that do not cause the program to crash, but simply do not function as the code intended. Since the program does not crash, these errors are often the most difficult to spot and therefore the most dangerous errors. These errors can only be detected through thorough testing.<\/p>\n<p><strong>Example 1\u00a0<\/strong><\/p>\n<pre>age = int(input('How old are you?'))\r\n\r\nif age &lt; 50:\r\n\r\n\u00a0 \u00a0 print('You are old!')\r\n\r\nelse:\r\n\r\n\u00a0 \u00a0 print('You are young!')<\/pre>\n<p>Here the code will execute without an error, however the comparison operator &lt; is the wrong one. It&#8217;s should be &lt;.<\/p>\n<p><strong>Example 2<\/strong><\/p>\n<pre>while True:\r\n\r\n\u00a0 \u00a0 answer = input('Press enter to break out of the loop')\r\n\r\n\u00a0 \u00a0 if answer == \"\u00a0 \u00a0\":\r\n\r\n\u00a0 \u00a0 \u00a0 \u00a0 break<\/pre>\n<p>Here the program contains too many spaces inside of the &#8221;\u00a0 \u00a0 &#8220;. This will mean that the user would have to input 3 spaces for the program to break, not one. The program would not crash, it would simply keep looping forever&#8230;<\/p>\n<p>&nbsp;<\/p>\n\n<\/div><h2 class=\"tabtitle\">Teacher Resources<\/h2>\n<div class=\"tabcontent\">\n\n<p><a href=\"https:\/\/docs.google.com\/presentation\/d\/e\/2PACX-1vRfxYrFUpERS1lxz2dsh1P1ZgJ-u5gEVRCA14vZKKWkYpHn_5NyWYhZJUoHRQ0pktRCpXUn-3nYyRd-\/pub?start=false&amp;loop=false&amp;delayms=1800000&amp;slide=id.g47c4f98c38_0_46\">Presentation<\/a><\/p>\n<p><a href=\"https:\/\/play.kahoot.it\/#\/k\/cab4af43-d782-4cd7-a18f-8859424a3bd3\">Kahoot &#8211; Error Types Kahoot<\/a><\/p>\n<p><a href=\"https:\/\/docs.google.com\/document\/d\/1kDbFnovyDp2wywGfU4brVq8ceVw90xoZ3_xj5peWa5U\/edit?usp=sharing\">Worksheet<\/a><\/p>\n<\/div><\/div>\n","protected":false},"excerpt":{"rendered":"<p>Syntax, Runtime and Logical Errors Tutorial Video Can&#8217;t access YouTube? Click Here https:\/\/www.youtube.com\/watch?v=ToPP5UGgJUMVideo can&#8217;t be loaded because JavaScript is disabled: Syntax, Runtime and Logical Errors in Python (https:\/\/www.youtube.com\/watch?v=ToPP5UGgJUM) &nbsp; Syntax Errors These are errors where the computer cannot interpret the inputted code and therefore cannot compile or translate the code. These ares are usually the&hellip;&nbsp;<a href=\"https:\/\/learnlearn.uk\/alevelcs\/syntax-runtime-logical-errors\/\" class=\"\" rel=\"bookmark\">Read More &raquo;<span class=\"screen-reader-text\">Syntax, Runtime and Logical Errors<\/span><\/a><\/p>\n","protected":false},"author":1,"featured_media":0,"parent":0,"menu_order":0,"comment_status":"closed","ping_status":"closed","template":"","meta":{"neve_meta_sidebar":"","neve_meta_container":"","neve_meta_enable_content_width":"","neve_meta_content_width":70,"neve_meta_title_alignment":"","neve_meta_author_avatar":"","neve_post_elements_order":"","neve_meta_disable_header":"","neve_meta_disable_footer":"","neve_meta_disable_title":""},"yoast_head":"<!-- This site is optimized with the Yoast SEO plugin v20.6 - https:\/\/yoast.com\/wordpress\/plugins\/seo\/ -->\n<title>Syntax, Runtime and Logical Errors - A Level Computer Science<\/title>\n<meta name=\"robots\" content=\"index, follow, max-snippet:-1, max-image-preview:large, max-video-preview:-1\" \/>\n<link rel=\"canonical\" href=\"https:\/\/learnlearn.uk\/alevelcs\/syntax-runtime-logical-errors\/\" \/>\n<meta property=\"og:locale\" content=\"en_GB\" \/>\n<meta property=\"og:type\" content=\"article\" \/>\n<meta property=\"og:title\" content=\"Syntax, Runtime and Logical Errors - A Level Computer Science\" \/>\n<meta property=\"og:description\" content=\"Syntax, Runtime and Logical Errors Tutorial Video Can&#8217;t access YouTube? Click Here https:\/\/www.youtube.com\/watch?v=ToPP5UGgJUMVideo can&#8217;t be loaded because JavaScript is disabled: Syntax, Runtime and Logical Errors in Python (https:\/\/www.youtube.com\/watch?v=ToPP5UGgJUM) &nbsp; Syntax Errors These are errors where the computer cannot interpret the inputted code and therefore cannot compile or translate the code. These ares are usually the&hellip;&nbsp;Read More &raquo;Syntax, Runtime and Logical Errors\" \/>\n<meta property=\"og:url\" content=\"https:\/\/learnlearn.uk\/alevelcs\/syntax-runtime-logical-errors\/\" \/>\n<meta property=\"og:site_name\" content=\"A Level Computer Science\" \/>\n<meta property=\"article:modified_time\" content=\"2021-03-26T06:54:46+00:00\" \/>\n<meta property=\"og:image\" content=\"https:\/\/learnlearn.uk\/gcsecs\/wp-content\/uploads\/sites\/8\/2017\/01\/error2.jpg\" \/>\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=\"2 minutes\" \/>\n<script type=\"application\/ld+json\" class=\"yoast-schema-graph\">{\"@context\":\"https:\/\/schema.org\",\"@graph\":[{\"@type\":\"WebPage\",\"@id\":\"https:\/\/learnlearn.uk\/alevelcs\/syntax-runtime-logical-errors\/\",\"url\":\"https:\/\/learnlearn.uk\/alevelcs\/syntax-runtime-logical-errors\/\",\"name\":\"Syntax, Runtime and Logical Errors - A Level Computer Science\",\"isPartOf\":{\"@id\":\"https:\/\/learnlearn.uk\/alevelcs\/#website\"},\"datePublished\":\"2020-03-10T06:45:57+00:00\",\"dateModified\":\"2021-03-26T06:54:46+00:00\",\"breadcrumb\":{\"@id\":\"https:\/\/learnlearn.uk\/alevelcs\/syntax-runtime-logical-errors\/#breadcrumb\"},\"inLanguage\":\"en-GB\",\"potentialAction\":[{\"@type\":\"ReadAction\",\"target\":[\"https:\/\/learnlearn.uk\/alevelcs\/syntax-runtime-logical-errors\/\"]}]},{\"@type\":\"BreadcrumbList\",\"@id\":\"https:\/\/learnlearn.uk\/alevelcs\/syntax-runtime-logical-errors\/#breadcrumb\",\"itemListElement\":[{\"@type\":\"ListItem\",\"position\":1,\"name\":\"A Level Computer Science Home\",\"item\":\"https:\/\/learnlearn.uk\/alevelcs\/\"},{\"@type\":\"ListItem\",\"position\":2,\"name\":\"Syntax, Runtime and Logical Errors\"}]},{\"@type\":\"WebSite\",\"@id\":\"https:\/\/learnlearn.uk\/alevelcs\/#website\",\"url\":\"https:\/\/learnlearn.uk\/alevelcs\/\",\"name\":\"A Level Computer Science\",\"description\":\"CIE Specification\",\"publisher\":{\"@id\":\"https:\/\/learnlearn.uk\/alevelcs\/#organization\"},\"potentialAction\":[{\"@type\":\"SearchAction\",\"target\":{\"@type\":\"EntryPoint\",\"urlTemplate\":\"https:\/\/learnlearn.uk\/alevelcs\/?s={search_term_string}\"},\"query-input\":\"required name=search_term_string\"}],\"inLanguage\":\"en-GB\"},{\"@type\":\"Organization\",\"@id\":\"https:\/\/learnlearn.uk\/alevelcs\/#organization\",\"name\":\"A Level Computer Science\",\"url\":\"https:\/\/learnlearn.uk\/alevelcs\/\",\"logo\":{\"@type\":\"ImageObject\",\"inLanguage\":\"en-GB\",\"@id\":\"https:\/\/learnlearn.uk\/alevelcs\/#\/schema\/logo\/image\/\",\"url\":\"https:\/\/learnlearn.uk\/alevelcs\/wp-content\/uploads\/sites\/20\/2019\/09\/LearnLearnLogowhite.png\",\"contentUrl\":\"https:\/\/learnlearn.uk\/alevelcs\/wp-content\/uploads\/sites\/20\/2019\/09\/LearnLearnLogowhite.png\",\"width\":710,\"height\":98,\"caption\":\"A Level Computer Science\"},\"image\":{\"@id\":\"https:\/\/learnlearn.uk\/alevelcs\/#\/schema\/logo\/image\/\"}}]}<\/script>\n<!-- \/ Yoast SEO plugin. -->","yoast_head_json":{"title":"Syntax, Runtime and Logical Errors - A Level Computer Science","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":"https:\/\/learnlearn.uk\/alevelcs\/syntax-runtime-logical-errors\/","og_locale":"en_GB","og_type":"article","og_title":"Syntax, Runtime and Logical Errors - A Level Computer Science","og_description":"Syntax, Runtime and Logical Errors Tutorial Video Can&#8217;t access YouTube? Click Here https:\/\/www.youtube.com\/watch?v=ToPP5UGgJUMVideo can&#8217;t be loaded because JavaScript is disabled: Syntax, Runtime and Logical Errors in Python (https:\/\/www.youtube.com\/watch?v=ToPP5UGgJUM) &nbsp; Syntax Errors These are errors where the computer cannot interpret the inputted code and therefore cannot compile or translate the code. These ares are usually the&hellip;&nbsp;Read More &raquo;Syntax, Runtime and Logical Errors","og_url":"https:\/\/learnlearn.uk\/alevelcs\/syntax-runtime-logical-errors\/","og_site_name":"A Level Computer Science","article_modified_time":"2021-03-26T06:54:46+00:00","og_image":[{"url":"https:\/\/learnlearn.uk\/gcsecs\/wp-content\/uploads\/sites\/8\/2017\/01\/error2.jpg"}],"twitter_card":"summary_large_image","twitter_misc":{"Estimated reading time":"2 minutes"},"schema":{"@context":"https:\/\/schema.org","@graph":[{"@type":"WebPage","@id":"https:\/\/learnlearn.uk\/alevelcs\/syntax-runtime-logical-errors\/","url":"https:\/\/learnlearn.uk\/alevelcs\/syntax-runtime-logical-errors\/","name":"Syntax, Runtime and Logical Errors - A Level Computer Science","isPartOf":{"@id":"https:\/\/learnlearn.uk\/alevelcs\/#website"},"datePublished":"2020-03-10T06:45:57+00:00","dateModified":"2021-03-26T06:54:46+00:00","breadcrumb":{"@id":"https:\/\/learnlearn.uk\/alevelcs\/syntax-runtime-logical-errors\/#breadcrumb"},"inLanguage":"en-GB","potentialAction":[{"@type":"ReadAction","target":["https:\/\/learnlearn.uk\/alevelcs\/syntax-runtime-logical-errors\/"]}]},{"@type":"BreadcrumbList","@id":"https:\/\/learnlearn.uk\/alevelcs\/syntax-runtime-logical-errors\/#breadcrumb","itemListElement":[{"@type":"ListItem","position":1,"name":"A Level Computer Science Home","item":"https:\/\/learnlearn.uk\/alevelcs\/"},{"@type":"ListItem","position":2,"name":"Syntax, Runtime and Logical Errors"}]},{"@type":"WebSite","@id":"https:\/\/learnlearn.uk\/alevelcs\/#website","url":"https:\/\/learnlearn.uk\/alevelcs\/","name":"A Level Computer Science","description":"CIE Specification","publisher":{"@id":"https:\/\/learnlearn.uk\/alevelcs\/#organization"},"potentialAction":[{"@type":"SearchAction","target":{"@type":"EntryPoint","urlTemplate":"https:\/\/learnlearn.uk\/alevelcs\/?s={search_term_string}"},"query-input":"required name=search_term_string"}],"inLanguage":"en-GB"},{"@type":"Organization","@id":"https:\/\/learnlearn.uk\/alevelcs\/#organization","name":"A Level Computer Science","url":"https:\/\/learnlearn.uk\/alevelcs\/","logo":{"@type":"ImageObject","inLanguage":"en-GB","@id":"https:\/\/learnlearn.uk\/alevelcs\/#\/schema\/logo\/image\/","url":"https:\/\/learnlearn.uk\/alevelcs\/wp-content\/uploads\/sites\/20\/2019\/09\/LearnLearnLogowhite.png","contentUrl":"https:\/\/learnlearn.uk\/alevelcs\/wp-content\/uploads\/sites\/20\/2019\/09\/LearnLearnLogowhite.png","width":710,"height":98,"caption":"A Level Computer Science"},"image":{"@id":"https:\/\/learnlearn.uk\/alevelcs\/#\/schema\/logo\/image\/"}}]}},"rttpg_featured_image_url":null,"rttpg_author":{"display_name":"learnlearnadmin","author_link":"https:\/\/learnlearn.uk\/alevelcs\/author\/learnlearnadmin\/"},"rttpg_comment":0,"rttpg_category":null,"rttpg_excerpt":"Syntax, Runtime and Logical Errors Tutorial Video Can&#8217;t access YouTube? Click Here https:\/\/www.youtube.com\/watch?v=ToPP5UGgJUMVideo can&#8217;t be loaded because JavaScript is disabled: Syntax, Runtime and Logical Errors in Python (https:\/\/www.youtube.com\/watch?v=ToPP5UGgJUM) &nbsp; Syntax Errors These are errors where the computer cannot interpret the inputted code and therefore cannot compile or translate the code. These ares are usually the&hellip;&nbsp;Read&hellip;","_links":{"self":[{"href":"https:\/\/learnlearn.uk\/alevelcs\/wp-json\/wp\/v2\/pages\/359"}],"collection":[{"href":"https:\/\/learnlearn.uk\/alevelcs\/wp-json\/wp\/v2\/pages"}],"about":[{"href":"https:\/\/learnlearn.uk\/alevelcs\/wp-json\/wp\/v2\/types\/page"}],"author":[{"embeddable":true,"href":"https:\/\/learnlearn.uk\/alevelcs\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/learnlearn.uk\/alevelcs\/wp-json\/wp\/v2\/comments?post=359"}],"version-history":[{"count":2,"href":"https:\/\/learnlearn.uk\/alevelcs\/wp-json\/wp\/v2\/pages\/359\/revisions"}],"predecessor-version":[{"id":1869,"href":"https:\/\/learnlearn.uk\/alevelcs\/wp-json\/wp\/v2\/pages\/359\/revisions\/1869"}],"wp:attachment":[{"href":"https:\/\/learnlearn.uk\/alevelcs\/wp-json\/wp\/v2\/media?parent=359"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}