{"base":{"id":"cs9-14","subject":"Programming","title":"Three kinds of error","scene":"py9","steps":[{"mode":"syntax","eyebrow":"Syntax errors","title":"Breaking the language rules","body":"A syntax error is like a spelling or grammar mistake in code. The program won't even start. Run it, read the message, then fix it.","actions":[{"id":"run","label":"Run"},{"id":"fix","label":"Fix it"}]},{"mode":"runtime","eyebrow":"Runtime errors","title":"A crash while running","body":"A runtime error happens while the program runs, such as dividing by zero. The code is valid, but something impossible happens. Run it, then fix it.","actions":[{"id":"run","label":"Run"},{"id":"fix","label":"Fix it"}]},{"mode":"logic","eyebrow":"Logic errors","title":"Runs, but wrong","body":"A logic error gives no message at all. The program runs but gives the wrong answer. These are the hardest to spot. Run it, then fix it.","actions":[{"id":"run","label":"Run"},{"id":"fix","label":"Fix it"}]},{"mode":"quiz","eyebrow":"Check yourself","title":"Name the error","body":"A program to find the area of a rectangle runs, but uses length + width instead of length × width.","question":"What kind of error is this?","options":["Syntax error","Runtime error","Logic error"],"answer":2,"right":"Correct. It runs without a message but gives the wrong answer.","wrong":"Not quite. Does it crash, or just give a wrong answer?","look":"logic"}],"more":[{"type":"cards","id":"ideas","eyebrow":"Popular idea vs science","title":"Common mix-ups","items":[{"tag":"Popular idea","title":"\"No error message means no errors.\"","body":"Logic errors give no message: always test with known answers."},{"tag":"Popular idea","title":"\"Syntax errors happen while the program runs.\"","body":"They stop it from starting at all."},{"tag":"Popular idea","title":"\"Runtime errors are always the programmer's typing mistakes.\"","body":"They often come from unexpected input, such as 0 or a missing file."}]},{"type":"cards","id":"code","eyebrow":"Python","title":"One of each","items":[{"tag":"Syntax","title":"Missing colon","body":"if score > 10\n    print(\"Win\")","code":true},{"tag":"Runtime","title":"Bad index","body":"names = [\"Ava\", \"Leo\"]\nprint(names[5])   # IndexError","code":true},{"tag":"Logic","title":"Wrong operator","body":"average = a + b / 2   # should be (a + b) / 2","code":true}]},{"type":"activities","id":"try","eyebrow":"Try it at home","title":"Error detective","items":[{"title":"Classify errors","time":"15 minutes","need":["Paper","A partner"],"steps":["Each write three short buggy programs: one syntax, one runtime, one logic error.","Swap and classify each one.","Fix them.","Which kind was hardest to find? Why?"],"why":"Knowing the kind of error tells you where and how to look for it.","safety":"No safety risks."}]},{"type":"quiz","id":"quiz","eyebrow":"Quiz","title":"Six more questions","questions":[{"question":"print(\"Hello\" has a missing bracket. Which error?","options":["Syntax","Logic","Runtime"],"answer":0,"right":"Correct. It breaks the language rules.","wrong":"Not quite. Can it even start?"},{"question":"x = 10 / 0. Which error?","options":["Syntax","Logic","Runtime"],"answer":2,"right":"Correct. Division by zero crashes while running.","wrong":"Not quite. It is valid code."},{"question":"A thermometer program shows 100 °C when it should show 37 °C. Which error?","options":["Syntax","Logic","Runtime"],"answer":1,"right":"Correct. Wrong answer, no crash.","wrong":"Not quite. No error message."},{"question":"Which error is found before the program runs?","options":["Syntax","Runtime","Logic"],"answer":0,"right":"Correct. The translator checks the rules first.","wrong":"Not quite. Before it starts."},{"question":"Which tool helps most with logic errors?","options":["A bigger screen","A trace table and test data","A faster computer"],"answer":1,"right":"Correct. Compare actual with expected values.","wrong":"Not quite. How do you spot wrong answers?"},{"question":"int(\"hello\") causes…","options":["a syntax error","a runtime error","no error"],"answer":1,"right":"Correct. The text can't be converted.","wrong":"Not quite. The code is valid, the data isn't."}]},{"type":"checklist","id":"check","eyebrow":"Self-check","title":"I can explain…","items":["what a syntax error is","what a runtime error is","what a logic error is","how to find and fix each kind"]},{"type":"keywords","id":"words","eyebrow":"Key words","title":"Words to know","items":[{"word":"syntax error","meaning":"Code that breaks the rules of the language."},{"word":"runtime error","meaning":"An error that crashes a program while it runs."},{"word":"logic error","meaning":"A mistake that gives wrong results without crashing."},{"word":"error message","meaning":"Text explaining what went wrong."},{"word":"exception","meaning":"Python's name for a runtime error."}]},{"type":"sources","id":"sources","title":"Sources","items":["BBC Bitesize KS3 Computer Science","Raspberry Pi Foundation, Computing curriculum resources"]}]},"overlay":null}