{"base":{"id":"cs8-07","subject":"Algorithms","title":"Decisions in algorithms","scene":"code","steps":[{"mode":"flow","eyebrow":"Flowcharts","title":"The diamond decides","body":"Algorithms often need to choose. In a flowchart, a diamond holds a condition: a question whose answer is TRUE or FALSE. Set the temperature, run the flowchart and follow the path.","controls":[{"id":"temp","label":"Temperature input","min":0,"max":40,"step":1,"value":20,"unit":"°C"}],"actions":[{"id":"run","label":"Run the flowchart"}]},{"mode":"ifelse","eyebrow":"IF … THEN … ELSE","title":"Only one branch runs","body":"In pseudocode, IF checks the condition. If it is TRUE, the THEN part runs; if FALSE, the ELSE part runs. Never both. Move the score across 50 and watch the lines change.","controls":[{"id":"score","label":"Score input","min":0,"max":100,"step":1,"value":60}]},{"mode":"elseif","eyebrow":"Several outcomes","title":"Checks run in order","body":"With ELSE IF, the computer checks each condition in order and stops at the first TRUE one. Change the race time and see which medal is chosen.","controls":[{"id":"time","label":"100 m race time","min":8,"max":16,"step":0.5,"value":11,"unit":"s"}]},{"mode":"quiz","eyebrow":"Check yourself","title":"Which branch?","body":"IF age >= 13 THEN OUTPUT \"Join the club\" ELSE OUTPUT \"Wait a little\" ENDIF","question":"The input age is 13. What is output?","options":["Wait a little","Join the club","Both messages"],"answer":1,"right":"Correct. >= means 'at least', so 13 >= 13 is TRUE and the THEN part runs.","wrong":"Not quite. Is 13 at least 13?","look":"ifelse"}],"more":[{"type":"cards","id":"ideas","eyebrow":"Popular idea vs science","title":"Common mix-ups","items":[{"tag":"Popular idea","title":"\"Both branches of an IF run.\"","body":"Only one runs: THEN if the condition is TRUE, ELSE if it is FALSE."},{"tag":"Popular idea","title":"\"In an ELSE IF chain, every TRUE condition gives an output.\"","body":"The checks stop at the first TRUE one. A time of 9 s is also under 12 s, but it never gets that far."},{"tag":"Popular idea","title":"\"50 >= 50 is FALSE because 50 isn't bigger than 50.\"","body":">= means 'greater than or equal to', so it includes 50 itself."}]},{"type":"cards","id":"ops","eyebrow":"Comparisons","title":"Comparison operators","items":[{"tag":">","title":"Greater than","body":"7 > 5 is TRUE. 5 > 5 is FALSE."},{"tag":"<","title":"Less than","body":"3 < 8 is TRUE."},{"tag":">=","title":"At least","body":"5 >= 5 is TRUE."},{"tag":"<=","title":"At most","body":"4 <= 3 is FALSE."},{"tag":"=","title":"Equal to","body":"\"cat\" = \"cat\" is TRUE."},{"tag":"≠","title":"Not equal to","body":"6 ≠ 7 is TRUE."}]},{"type":"cards","id":"shapes","eyebrow":"Flowcharts","title":"Flowchart shapes","items":[{"tag":"Rounded box","title":"Start or stop","body":"Where the algorithm begins and ends."},{"tag":"Parallelogram","title":"Input or output","body":"Getting or showing a value."},{"tag":"Rectangle","title":"Process","body":"A calculation or action, such as total ← total + 1."},{"tag":"Diamond","title":"Decision","body":"A condition with a Yes arrow and a No arrow."}]},{"type":"activities","id":"try","eyebrow":"Try it at home","title":"Decision tree","items":[{"title":"Choose your outfit","time":"15 minutes","need":["Paper and coloured pens"],"steps":["Draw a flowchart that decides what to wear: start, then a diamond 'Is it raining?'.","On the Yes path add 'Take a raincoat'. On the No path add another diamond 'Is it above 25 °C?'.","Finish each path with an output and a STOP.","Ask someone to follow it for today's weather. Then trace it for a cold rainy day and a hot dry day."],"why":"Each diamond is a selection. Tracing with different weather checks every path.","safety":"No safety risks."}]},{"type":"quiz","id":"quiz","eyebrow":"Quiz","title":"Six more questions","questions":[{"question":"What is a condition?","options":["A question that is TRUE or FALSE","A type of loop","An output"],"answer":0,"right":"Correct. Conditions control which branch runs.","wrong":"Not quite. What does the diamond hold?"},{"question":"Which flowchart shape holds a decision?","options":["Diamond","Rectangle","Parallelogram"],"answer":0,"right":"Correct. Two arrows, Yes and No, leave the diamond.","wrong":"Not quite. Which shape has two exits?"},{"question":"IF score >= 50 … ELSE … The score is 49. Which part runs?","options":["The THEN part","Neither","The ELSE part"],"answer":2,"right":"Correct. 49 >= 50 is FALSE.","wrong":"Not quite. Is 49 at least 50?"},{"question":"time = 9: IF time < 10 → Gold, ELSE IF time < 12 → Silver. What is output?","options":["Silver","Gold and Silver","Gold"],"answer":2,"right":"Correct. The first TRUE check wins and the rest are skipped.","wrong":"Not quite. Which check comes first?"},{"question":"Which inputs best test IF temp > 25?","options":["30 only","20, 25 and 30","26, 27 and 28"],"answer":1,"right":"Correct. They test below, exactly at, and above the boundary.","wrong":"Not quite. Try values on both sides and on the boundary."},{"question":"What does ≠ mean?","options":["Equal to","Not equal to","Less than"],"answer":1,"right":"Correct. 6 ≠ 7 is TRUE.","wrong":"Not quite. The line through = means 'not'."}]},{"type":"checklist","id":"check","eyebrow":"Self-check","title":"I can explain…","items":["what selection and a condition are","how a diamond works in a flowchart","why only one branch of IF … ELSE runs","how an ELSE IF chain picks the first TRUE condition","which inputs to choose to test every path"]},{"type":"keywords","id":"words","eyebrow":"Key words","title":"Words to know","items":[{"word":"selection","meaning":"Choosing which steps run, depending on a condition."},{"word":"condition","meaning":"A question with the answer TRUE or FALSE."},{"word":"branch","meaning":"One of the paths an algorithm can take."},{"word":"comparison operator","meaning":"A symbol such as >, <, = that compares two values."},{"word":"flowchart","meaning":"A diagram of an algorithm using shapes and arrows."}]},{"type":"sources","id":"sources","title":"Sources","items":["BBC Bitesize KS3 Computing: Selection"]}]},"overlay":null}