Arrays and 2D arrays – OCR A Level Computer Science lesson (H446)
Students learn to declare, fill and traverse one- and two-dimensional arrays in Python and OCR pseudocode.
Lesson 8 of 16 in unit 12.2 Programming Foundations and Computational Thinking, taught in Year 12, Autumn 1. It answers one big question: How can one identifier hold a whole grid of data?
By the end, students can declare, fill and traverse one- and two-dimensional arrays in Python and OCR pseudocode.
- The Build (the main task)
- Write a program that stores the number of bikes at each of 5 Fernbridge CycleShare stations at each of 4 times of day in a two-dimensional array, then outputs the total for each station (6 marks).
- Support version
- The declaration and outer loop are given; students complete the inner loop and the running total, using a labelled grid of the array with its indexes.
- Challenge
- Write a function that returns the index of the station with the fewest bikes at a given time of day.
- Real-world link
- Fernbridge CycleShare's control room records how many bikes each station holds at 6am, 10am, 2pm and 6pm.
- Key words
- Array, Index and Dimension, each with a definition, an icon and a common mix-up on the key vocabulary slide.
- Misconceptions it tackles
- “The order of the two indexes in a 2D array does not matter”; “An array can be declared without a size and grows as items are added”.
- OCR H446 specification
- 1.4.2 (a) (arrays of up to three dimensions: one- and two-dimensional arrays are introduced in lesson 8; records, lists, tuples and the full topic follow in 12.8); 2.2.1 (a).
Every lesson follows the same Code & Commerce structure: a Bell Task recall starter, key vocabulary with definitions and icons, short teaching chunks with a check before pupils move on, The Build (one main task), challenge questions that get harder, and an exit question. Answers reveal one at a time on the slides, and everything is editable PowerPoint and Word.
Students need computers for the main task.
Also sold in the Programming Foundations and Computational Thinking unit bundle, which includes the medium term plan, and in the full-year and complete-course bundles.
An independent resource written for OCR A Level Computer Science (H446). It is not endorsed by OCR or Cambridge University Press & Assessment. Programming project (NEA) lessons teach general skills on a made-up example project and give supervised time, within JCQ's rules on the help a centre may give.
What's included
- Slide deck (PowerPoint)
- Lesson plan (Word)
- Worksheet (Word)
- Support worksheet with scaffolds (Word)
- Single-teacher licence: use and adapt it with your own classes
More for A Level Computer Science
See allStudents learn to name the debugging tools in their IDE and write a short algorithm in both Python and OCR exam pseudocode.
Free sample lessonStudents learn to identify sequence, selection and iteration in code, and choose between IF, ELSEIF and SWITCH for a task.
Students learn to choose the correct primitive data type for each item of data and use casting to convert between types.
Written for the specifications named. Not endorsed by or affiliated with any exam board.