Zum Inhalt springen

English:Scratch events, sequence and selection - Computing Year 5

Aus MOOCsWiki Staging
aiMOOC-Siegel aiMOOC

Scratch events, sequence and selection - Computing Year 5

QR-Code



Introduction

A freely licensed 2023 screenshot illustrates a Scratch 3 editor. Its sound example is not the visitor-guide project built in this course.
A freely licensed 2023 screenshot illustrates a Scratch 3 editor. Its sound example is not the visitor-guide project built in this course.

A character can follow instructions in order and still make different choices. Build a small visitor guide that starts on an event, asks for a fictional route choice and uses selection to choose the next action.

Learn to explain an event, trace a sequence and test both outcomes of an if/else decision. Your final evidence is a Scratch project you have run, a test record and an explanation of one corrected error. Scratch is an example environment for the broader key-stage-2 programming ideas; this Year 5 placement is editorial rather than a nationally prescribed software sequence.

Use a classroom-approved browser editor or the offline Scratch editor. No public account, public project sharing or personal information is required. The route inputs are invented A, B and Other. Editor layout may differ from the historical screenshot.


Start with an event and control the sequence

A sprite is an object you can program in Scratch. The Stage is the area where the project is shown. Select the intended sprite before adding its script; blocks attached to another sprite will control that other object instead. You can draw a simple arrow costume of your own rather than choosing a branded character.

An event is something that triggers a script, such as the green flag being clicked, a key being pressed or a sprite being clicked. A script beginning with when green flag clicked waits for that event. The blocks connected beneath it form a sequence: instructions run in the order they are stacked, subject to what each block does.

Start a fresh project with one guide sprite. Use a plain backdrop so its movement is easy to see. This course's Scratch 3 Stage uses x for horizontal position and y for vertical position. Increasing x moves right; increasing y moves up. The example starts at x = −120, y = 0, safely within the standard Stage.


Build and trace the starter

Order Scratch block or setting Purpose
1 Events: when green flag clicked Starts this script on the chosen event
2 Motion: go to x: −120 y: 0 Resets the starting position
3 Looks: say Welcome to the gallery! for 2 seconds Displays a temporary message
4 Sensing: ask Choose A or B and wait Waits for the user's reply

The answer reporter contains the most recent reply. Drag the rounded answer block into a comparison later; do not type the word 'answer' as ordinary text. The ask-and-wait block pauses this script until the reply is submitted. The timed say block also waits for its stated duration before continuing.

Resetting the position makes a restart predictable. If you only use 'change x by 120' without a reset, repeated runs can keep moving the sprite from wherever the previous run ended. An absolute 'go to' sets a position; a relative 'change' adds to the existing position.

Multiple scripts with the same green-flag event can start together. Do not assume that one separate script always finishes first just because it appears further left on the workspace. Keep the reset and the dependent route actions in one connected script for this first project.


Make a decision from a true or false condition

A condition is a test that has a true or false outcome. Selection uses that outcome to choose which instructions run. In Scratch, a hexagonal condition fits into the matching input space of an if then or if then else block. An equals block from Operators can compare the answer reporter with the route label A.

For one if/else decision, the then branch runs when the condition is true and the else branch runs when it is false. Both branches do not normally run in the same evaluation of that block. A condition is checked when execution reaches it; an if block alone is not a permanent watcher. Repetition is developed in the next course.

This original CS Discoveries film explains conditionals in a different programming context. Use its true/false idea, then return to the Scratch example. It is not a screen-by-screen demonstration of the visitor-guide project.


Test the two outcomes of a simple decision

First make a small test version after the ask block: if answer equals A, say 'Route A'; otherwise say 'Not A'. Predict and try A and B. A should take the then branch; B should take the else branch. This is a useful first test of a two-outcome decision.

Notice the limitation: 'Not A' includes B, Other and many other replies. An else branch means the condition was false; it does not automatically mean 'the answer must be B'. To make a guide with two accepted choices and a helpful response to another input, add a second test inside the first else branch.

The complete logic is: test A; if true take route A; otherwise test B; if that is true take route B; otherwise request one of the accepted choices without moving. The second if/else is nested because it sits inside a branch of the first one.

Use A, B and Other exactly as the course's named test inputs. Scratch can handle some text comparisons without distinguishing letter case; the project does not depend on a claim that every editor or language treats all input text identically. Extra spaces and unexpected replies still need testing if you extend the design.


Build the complete visitor guide and trace each route

The guide has a small, testable purpose: accept route A or B, move the sprite in the corresponding direction, and give a helpful message for another reply. It is an invented gallery guide, not a navigation aid for a real building.

Keep the four starter blocks from the first chapter. Directly below the ask-and-wait block, add the following structure. A then branch and an else branch are the separate spaces inside a Scratch if/else block; the second if/else belongs inside the first block's else space.

Location Block or condition Instructions placed inside
After the ask block Control: if then else; condition is answer = A The first decision
First decision's then space Motion: change x by 120 Then Looks: say Route A for 2 seconds
First decision's else space A second if then else; condition is answer = B This entire decision is nested in the first else
Second decision's then space Motion: change y by 60 Then Looks: say Route B for 2 seconds
Second decision's else space Looks: say Choose A or B for 2 seconds No movement block in this branch

Use the rounded answer reporter inside each equals condition. The other input contains the literal route label A or B. The conditions need to be connected to the if blocks, and the branch instructions need to sit inside the correct spaces. Merely placing blocks nearby on the workspace does not attach them.


Trace before you run

Input A: The reset puts the sprite at x = −120, y = 0. The first condition is true. Adding 120 to x gives x = 0, while y stays zero. The sprite displays Route A. The first else branch, including the second decision, is skipped.

Input B: The first condition is false. Execution enters the first else, where the second condition is true. Adding 60 to y gives y = 60, while x stays −120. The sprite displays Route B.

Input Other: Both equality tests are false. The final else displays the choice message and has no movement block, so the reset position remains x = −120, y = 0. This version does not automatically ask again; click the green flag to start another complete run. Re-prompting with repetition is a possible later extension.

The instructions are a readable recipe for assembling Scratch blocks, not a separate text language to paste into the editor. Recreate the block structure and inspect the sprite's displayed x and y values. A correct paper trace predicts the behaviour, but actual running tests are needed to demonstrate that the assembled project works.


Test both outcomes, debug a cause and keep evidence

A test case specifies a starting situation, an input and an expected result. Predict the result before running the project. Record the actual result separately: copying your prediction into the actual column is not evidence that you tested it.

Test Start and input Expected result
A route Click green flag, then submit A Position x = 0, y = 0; Route A message
B route Click green flag, then submit B Position x = −120, y = 60; Route B message
Other reply Click green flag, then submit Other Position x = −120, y = 0; choice message
Repeatability Complete A, then click green flag and submit A again The same x = 0, y = 0 outcome on both runs

These cases exercise true and false outcomes of both decisions. A successful A test alone never enters the first else and therefore cannot prove the B branch works. Testing Other checks that the second else is connected and that an unaccepted reply does not move the guide.


Find the first cause, not only the visible symptom

Bug: Route A reaches x = 0 the first time but x = 120 the next time.

Investigation: Check whether the 'go to x: −120 y: 0' reset is missing or disconnected. Relative movement adds to the existing position, so a script without its reset can drift across repeated runs. Restore the reset before the ask and retest all three inputs.

Bug: B receives the 'Not A' message even though you intended Route B.

Investigation: You may still have the simple test version rather than the nested complete version. The first else means only that the A condition is false. Add the B decision inside it, then check B and Other separately.

Bug: Every reply takes an unexpected branch.

Investigation: Inspect whether you inserted the answer reporter or typed the word 'answer'. Check the selected sprite, connected event block, literal route labels and placement of the branch blocks. Change one suspected cause at a time, then rerun the same test so you can explain which change mattered.


Finish with a reproducible project record

Save a copy locally using the editor's file-saving option or your teacher's approved method. Keep a block-structure screenshot or accessible description, the test table with actual results, and one before/after explanation of a correction. A public upload is not required. Use an invented project title and the supplied route inputs rather than names, passwords or location data.

Personalise the guide with your own arrow, backdrop or messages after the core tests pass. If you change a route distance or add a new choice, update the expected results and run the affected tests again. Attractive artwork does not compensate for an untested condition.

If you cannot use an editor yet, complete the traces and explain the decisions, but label the practical project test as pending. A worksheet or quiz alone does not establish that you have created and run a working program.


Interactive Tasks


Quiz: Test Your Knowledge

What starts the main script in this project? (Clicking the green flag triggers its event block.) (!Saving the image starts every possible script.) (!Moving an unattached block starts the whole project.) (!The sprite always runs every block on the workspace.)



Why is the starting position set before asking for a route? (Each run begins from the same defined position.) (!It makes every answer equal to A.) (!It removes the need for any testing.) (!It changes the Stage into a different sprite.)



What supplies the reply in the condition after ask and wait? (The rounded answer reporter.) (!The ordinary typed word answer.) (!Any disconnected green flag block.) (!The name of the backdrop alone.)



When does a single if then else block choose its then branch? (When its condition is true at that evaluation.) (!Whenever its else branch is visually longer.) (!Only when the project is saved online.) (!It runs both branches for every evaluation.)



The first test is answer equals A. What does its else branch establish? (The tested answer did not match A.) (!The answer must be B.) (!The answer reporter is always empty.) (!All later tests must be true.)



In the complete guide, what is the final position after input A? (x is zero and y is zero.) (!x is minus 120 and y is 60.) (!x is minus 120 and y is zero.) (!x is 120 and y is 60.)



In the complete guide, which decisions are evaluated for input B? (The A test is false and the nested B test is true.) (!The A test is true so the B test is skipped.) (!Both tests are false and the guide does not move.) (!The sprite never reaches any condition.)



What should input Other do in the complete guide? (Display the choice message without moving from the reset position.) (!Take Route B because all non-A replies mean B.) (!Move through both routes in the same run.) (!Automatically ask forever without any repetition blocks.)



A route-A project ends at x zero once and x 120 on the next run. What should you inspect first? (Whether the starting-position reset is missing or disconnected.) (!Whether the background is decorative enough.) (!Whether a public account has a photograph.) (!Whether the correct test results can be deleted.)



What is sufficient practical evidence that the assembled guide works for the specified cases? (The saved project and actual results for A, B, Other and a repeated run.) (!Only a perfect score on definitions.) (!A prediction table relabelled as actual results without running it.) (!Only an attractive screenshot with no connected script.)





Memory Game

Sprite A programmable object in the project.
Event A trigger that can start an attached script.
Sequence The order of connected instructions.
Condition A test with a true or false outcome.
Selection Choosing instructions according to a condition.
Trace Following an input through the steps and recording the state.





Drag and Drop

Green-flag event Begins the main guide script when clicked.
Starting-position reset Places the guide at the defined coordinates before each choice.
Ask and wait Pauses this script until a reply is submitted.
Answer reporter Supplies the most recent reply to an equality test.
Nested B decision Checks the second accepted route only after the A test is false.





Crossword Puzzle

sprite The programmable guide object rather than its backdrop.
event A trigger such as a green-flag click.
sequence The intended order of connected blocks.
condition A true-or-false test controlling a choice.
selection The programming idea used to choose a branch.
debug Find a cause of incorrect behaviour and correct it.





LearningApps

Optional extra practice. Choose an appropriate activity with your teacher. If the external collection is unavailable, use the native activities and independent tasks in this course.


Cloze Text

Complete the explanation.
The guide is a programmable

. Clicking the flag provides an

. Connected blocks run in a

. An equality comparison forms a

. Choosing a branch is called

. A second decision inside a branch is

. Before every route, the position

makes the start predictable. A step-by-step

predicts the outcome for one input.



Open Tasks


Easy

  1. Identify the guide sprite and Stage: Describe which object the script controls and which area displays it. Explain how selecting the wrong sprite can affect the result.
  2. Assemble the guide starter sequence: Connect the flag, position reset, timed welcome and ask-and-wait blocks. Predict what happens before and after a reply is submitted.
  3. Compare a reporter with literal text: Explain the difference between inserting the answer reporter and typing the word answer in the condition. Label both in a sketch or accessible description.
  4. Trace the A route: Start at x minus 120 and y zero. Trace the first true condition, the horizontal movement and the skipped branch. State the final coordinates.


Standard

  1. Build both decisions in the visitor guide: Create the complete nested block structure, with B checked inside the first else. Save the project using an approved local or classroom method.
  2. Run the three guide input tests: Predict A, B and Other, then run each from a fresh green-flag start. Record actual coordinates and messages separately from expectations.
  3. Repair a missing reset: Explain the repeated-A drift fault, inspect the reset connection and correct it. Rerun A twice, then B and Other, retaining the before-and-after evidence.
  4. Explain why else does not mean B: Compare the initial simple decision with the completed nested version. Use Other as a counterexample to the claim that every non-A reply must be B.


Advanced

  1. Adapt a route distance and update tests: Change the A movement to 80 while retaining the start at x minus 120. Predict and run all three inputs. Explain which expected coordinates change and why.
  2. Extend the guide to a third accepted route: Plan a C route inside the remaining false branch and retain a helpful invalid-input response. State new tests before assembling and running the extension.
  3. Investigate unexpected guide behaviour: Choose one plausible connection or reporter fault. Write its predicted symptom, change one cause at a time and record reproducible tests. Do not remove failed evidence.
  4. Review a guide project for repeatability: Use a partner's approved project without personal information. Test both decisions and restart behaviour, then recommend one improvement supported by actual results.



Learning Check

  1. Explain the guide control flow: Explain the role of the event, ordered starter blocks and nested selection in this project.
  2. Trace accepted and unaccepted choices: Give final coordinates and messages for A, B and Other, starting each test with the flag.
  3. Distinguish prediction from execution evidence: Explain why correct paper traces and a quiz score do not prove that the assembled project runs.
  4. Diagnose route drift: Explain why a guide could finish Route A at zero once and 120 next time. Give a correction and a retest.
  5. Transfer the guide movement: If Route A changes x by 80 instead of 120, what is its expected position? Explain the impact on the other two routes.
  6. Demonstrate a tested Scratch guide: Provide your saved project, block structure, actual A/B/Other results, repeated-run test and an explained correction or justified improvement.


Worked checks and assessment guidance

  1. The green flag starts the script. The reset, timed welcome and ask run in order. The A comparison selects its then branch when true; otherwise the nested B comparison selects Route B or the choice message.
  2. A finishes at x zero, y zero with Route A; B at x minus 120, y 60 with Route B; Other remains at x minus 120, y zero with Choose A or B. The reset is part of every run.
  3. They support understanding of the intended algorithm, but cannot show whether actual blocks are attached to the correct sprite and branch. A saved implementation and observed results are needed for the practical outcome.
  4. Without the x minus 120, y zero reset, the relative movement adds 120 to the previous position. Restore and connect the reset before asking. Two fresh A runs should both end at zero, zero; also rerun B and Other.
  5. Minus 120 plus 80 gives x minus 40, with y zero. B still ends at minus 120, 60 and Other at minus 120, zero because those branches do not use the changed movement. Run all cases to check the implementation.
  6. Assess the actual connected script and reproducible results against the specified behaviour. An accessible block description can accompany the project. Without editor execution, record the practical result as pending rather than awarding it from predictions alone.


Learning evidence

Knowledge: Explain event, sequence, condition, selection, reporter, nested decision and relative movement in the guide context.

Practical product: Save your own connected Scratch guide and a block-structure screenshot or accessible description. Use fictional inputs and an approved local or classroom saving method; public sharing is unnecessary.

Tests: Keep predictions and actual results for A, B, Other and two fresh A runs, including coordinates and messages. Retain one correction or a justified improvement with new tests.

Transfer: Change a route requirement, update expected results and explain what remains unchanged.

Completion distinction: The practical objective requires an assembled project that has actually run. If only paper tracing is available, record that skill separately and leave project execution pending. Quiz points alone do not certify practical programming competence.


OER and Wikipedia

Department for Education: Computing, key stage 2. The event/sequence/selection objective and Year 5 placement are measurable editorial allocations; the programme does not mandate a national Scratch-specific annual sequence. Official environment guidance: Scratch Foundation: getting started and Raspberry Pi Foundation: getting started with Scratch. The visitor-guide algorithm, traces and tests are original teaching material.

Screenshot, unmodified: Scratch 3.0 editor, screenshot by SergioFLS, Scratch by MIT and contributors, CC BY-SA 2.0 as documented for this historical August 2023 file; optimisation by Obscure2020. The file page also documents the software's BSD licence and trademark caveats. This use illustrates an editor, implies no endorsement and does not claim that newly published Scratch assets have the same historical licence.

Video: CS Discoveries: Conditionals, CodeAI, originally the Code.org CS Discoveries series. The original publisher's upload is embedded, not downloaded or copied. The course identifies its different interface and uses the conditional concept rather than presenting it as a Scratch tutorial.


Linked learning areas


aiMOOC Projects



Schulfach+




aiMOOCs



aiMOOC Projekte









MOOCwiki · Deutsch

Nach dem Lernen ist vor dem Lernen

Entdecke direkt den nächsten Lernkurs. Weitere Inhalte erscheinen, wenn Du weiter nach unten scrollst.

Zur MOOCwiki-Hauptseite

Mediathek

Suche verfeinern

Dein Lernplan bestimmt, was oben steht. Alle anderen Inhalte bleiben erreichbar. Seitenaufrufe beeinflussen die Auswahl nicht.

Inhalte werden geladen ...

Mediathek wird aus dem Wiki geladen ...