Year 7 βΊ Scratch II: Subroutines and lists βΊ Lesson 2 of 5
Year 7 Β· Summer 1 Β· Scratch II: Subroutines and lists Lists: high scores and inventories
Topic 14 Programming further
KS3 Computing Β· Real programs keep data in lists, take text apart as strings, split work into subroutines, check their input, save to files, and get tested on purpose.
Programming Cambridge Lower Secondary Computing 0860
You will learn to Explain what a list is and why it is better than lots of separate variables. Use blocks to add an item, delete an item and show one item from a list. Explain that Scratch counts list items from 1, but Python counts from 0.
Success criteria I can make a list of names and a list of scores. I can add an item, delete an item and show item 1. I can say that the first item is item 1 in Scratch and index 0 in Python.
list One name holding many values in order. Also called an array.
index An item's position in a list, counting from 0.
Subroutine A named block of code you can call when needed.
Function A subroutine that returns a value.
Parameter A placeholder in a subroutine for a value passed in.
Validation Checking input is reasonable before using it.
Boundary data Test data at the very edge of what's allowed.
Lists A list (or array ) stores many values under one name, in order.
scores = [12, 45, 33, 50] ? Why?Why start at 0? The index means 'how many steps from the start'. The first item is 0 steps away.
scores[0] β 12scores[-1] β 50 (the last one)scores.append(28) adds to the endlen(scores) β how many itemsscores[10] β error: no item there
Mark this lesson as done Saved on this device.
β Previous lesson Decomposition and subroutines (My Blocks) Next lesson β Linear search through a list