Data types and casting – OCR GCSE Computer Science lesson (J277)
Pupils learn to choose integer, real, Boolean, character or string for a value and use casting so that typed input can be used in calculations.
Lesson 6 of 13 in unit 10.1 Systems Architecture and First Programs, taught in Year 10, Autumn 1. It answers one big question: Why does a program care what kind of data it holds?
By the end, pupils can choose integer, real, Boolean, character or string for a value and use casting so that typed input can be used in calculations.
- The Build (the main task)
- Write a Python program that asks for the number of pupils and the cost per pupil, casts each input to the right data type, and prints the total cost of the trip.
- Support version
- Parsons problem: the program's lines are jumbled with one distractor line that forgets to cast the input.
- Challenge
- State the best data type for a phone number and explain why it should not be an integer.
- Real-world link
- The trip planner must turn '32' typed by a teacher into the number 32 before it can work out a cost.
- Key words
- Data type, Casting and Convert, each with a definition, an icon and a common mix-up on the key vocabulary slide.
- Misconceptions it tackles
- “input() gives a number when the user types digits”; “"5" and 5 are the same value”.
- OCR J277 specification
- 2.2.2 (data types and casting).
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.
Pupils need computers for the main task.
Also sold in the Systems Architecture and First Programs unit bundle, which includes the medium term plan, and in the full-year and complete-course bundles.
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 GCSE Computer Science (OCR)
See allPupils learn to describe a computer system as input, process, storage and output, and write an algorithm as precise numbered steps for a stated purpose.
Free sample lessonPupils learn to decompose a problem into smaller sub-problems in a structure diagram and use abstraction to decide which details a solution needs and which it can ignore.
Pupils learn to state the purpose of the CPU and describe von Neumann architecture, in which instructions and data are stored together in the same memory.
Written for the specifications named. Not endorsed by or affiliated with any exam board.