{"base":{"id":"cs9-04","subject":"Algorithms","title":"Designing an algorithm: flowchart and pseudocode","scene":"code9","steps":[{"mode":"flow","eyebrow":"Two ways to show it","title":"Flowchart and pseudocode","body":"A heater algorithm: input the temperature; if it is below 18 °C, turn the heater on. Follow it in the flowchart and see the matching pseudocode line light up. Change the temperature.","controls":[{"id":"t","label":"Temperature","min":10,"max":25,"step":1,"value":15,"unit":"°C"}],"actions":[{"id":"step","label":"Follow one box"},{"id":"reset","label":"Start again"}]},{"mode":"loopflow","eyebrow":"Loops in a flowchart","title":"An arrow that goes back","body":"A password check gives up to 3 tries. In a flowchart, a loop is an arrow back to an earlier box. Choose how many wrong tries happen, then follow the path.","controls":[{"id":"w","label":"Wrong tries","min":0,"max":3,"step":1,"value":1}],"actions":[{"id":"step","label":"Follow one box"},{"id":"reset","label":"Start again"}]},{"mode":"parts","eyebrow":"The parts","title":"Input, decision, repetition, output","body":"Every algorithm design should show its inputs, decisions, repeated steps and outputs. Look at each part in the heater algorithm.","actions":[{"id":"i0","label":"Input"},{"id":"i1","label":"Decision"},{"id":"i2","label":"Repetition"},{"id":"i3","label":"Output"}]},{"mode":"quiz","eyebrow":"Check yourself","title":"Flowchart symbols","body":"A flowchart box asks 'Is the score more than 100?'.","question":"Which shape should it be?","options":["A diamond","A rectangle","An oval"],"answer":0,"right":"Correct. Decisions (yes/no questions) use a diamond.","wrong":"Not quite. Which symbol has two exits?","look":"flow"}],"more":[{"type":"cards","id":"ideas","eyebrow":"Popular idea vs science","title":"Common mix-ups","items":[{"tag":"Popular idea","title":"\"A flowchart and pseudocode are different algorithms.\"","body":"They can show exactly the same algorithm in two forms."},{"tag":"Popular idea","title":"\"Flowcharts can't show loops.\"","body":"An arrow back to an earlier box makes a loop."},{"tag":"Popular idea","title":"\"You design the algorithm after writing the code.\"","body":"Designing first saves time and catches mistakes early."}]},{"type":"cards","id":"code","eyebrow":"Design","title":"Symbols and keywords","items":[{"tag":"Oval","title":"Start / stop","body":"START … STOP","code":true},{"tag":"Parallelogram","title":"Input / output","body":"INPUT temp\nOUTPUT \"Heater on\"","code":true},{"tag":"Rectangle","title":"Process","body":"count ← count + 1","code":true},{"tag":"Diamond","title":"Decision","body":"IF temp < 18 THEN … ELSE … ENDIF","code":true}]},{"type":"activities","id":"try","eyebrow":"Try it at home","title":"Morning routine","items":[{"title":"Design an algorithm","time":"20 minutes","need":["Paper","Pencil"],"steps":["Choose a routine, such as getting ready for school.","Draw it as a flowchart with at least one decision (Is it raining?) and one loop (Repeat until bag is packed).","Write the same algorithm in pseudocode.","Ask someone to follow each version. Are they the same?"],"why":"Writing one algorithm two ways helps you check it is complete and clear.","safety":"No safety risks."}]},{"type":"quiz","id":"quiz","eyebrow":"Quiz","title":"Six more questions","questions":[{"question":"Which flowchart shape is used for INPUT or OUTPUT?","options":["Diamond","Parallelogram","Oval"],"answer":1,"right":"Correct. Inputs and outputs use parallelograms.","wrong":"Not quite. Not the decision shape."},{"question":"How does a flowchart show repetition?","options":["A double box","An arrow back to an earlier step","A dotted line"],"answer":1,"right":"Correct. The arrow makes a loop.","wrong":"Not quite. Think of going round again."},{"question":"What does a decision box always have?","options":["Two exits, e.g. Yes and No","One exit","No exits"],"answer":0,"right":"Correct. It chooses a path.","wrong":"Not quite. A question with two answers."},{"question":"Which pseudocode matches a decision box?","options":["OUTPUT","INPUT","IF … THEN … ELSE"],"answer":2,"right":"Correct. Selection.","wrong":"Not quite. Choosing between paths."},{"question":"Why stop a password loop after 3 tries?","options":["To save ink","To make it faster","To stop it repeating forever"],"answer":2,"right":"Correct. The loop needs an end condition.","wrong":"Not quite. What if the user never gets it right?"},{"question":"Which part is the temperature reading?","options":["Output","Decision","Input"],"answer":2,"right":"Correct. It comes into the algorithm.","wrong":"Not quite. Data coming in."}]},{"type":"checklist","id":"check","eyebrow":"Self-check","title":"I can explain…","items":["how to show an algorithm as a flowchart","how to show the same algorithm in pseudocode","how loops appear in a flowchart","how to identify inputs, decisions, repetition and outputs"]},{"type":"keywords","id":"words","eyebrow":"Key words","title":"Words to know","items":[{"word":"flowchart","meaning":"A diagram of an algorithm using symbols and arrows."},{"word":"decision","meaning":"A yes/no question that chooses a path."},{"word":"process","meaning":"A step that does something, such as a calculation."},{"word":"selection","meaning":"Choosing which steps to run."},{"word":"design","meaning":"Planning an algorithm before coding it."}]},{"type":"sources","id":"sources","title":"Sources","items":["BBC Bitesize KS3 Computer Science","Raspberry Pi Foundation, Computing curriculum resources"]}]},"overlay":null}