Community resourceWorksheet
OCR H446 1.4.1 Primitive data types and casting
Part 1 of 11 · H446 1.4.1 · Data types
OCR H446 1.4.1 asks students to choose a primitive data type from what a value represents and what the program does with it, not from how the value looks. Set in a music-event booking system, this worksheet builds that two-question method and then has students trace what casting really does to a value, including in running Python.
Students will:
- choose an OCR primitive type from a value's purpose and the operations needed
- justify storing a fixed-format identifier as a string rather than an integer
- trace the effect of a cast, including the loss of a fractional part
- complete a Python function that casts supplied text, calculates a total and returns a set sentence
- recall the type and casting definitions in a closed-book check
Inside: 10 explanation cells, 2 multiple-choice questions, 2 fill-in-the-blanks cells, 1 written answer and 2 Python tasks. 17 marks, about 40 to 50 minutes.
Series: H446 1.4.1 · Data types, part 1 of 11.
Shared by Coding PathwayVerified teacher
- 17 cells
- About 45 minutes
- CC BY-SA 4.0
- Shared 31 Aug 2026
- Updated 3 Sept 2026
Preview
The whole resource, exactly as a class sees it. Answers and marking are held back.
Primitive data types and casting
A music-event booking system stores names, prices, counts and yes/no decisions. Choosing a type is not about guessing from how a value looks: it is about what the value represents and what the program must do with it.
By the end, you will be able to
- distinguish integer, real, character, string and Boolean values;
- choose a type using both the value and its purpose;
- explain the Python–OCR difference for a single character;
- predict what common casts produce and identify information loss;
- apply type choices and casting in a small booking function.
Reactivate: an assignment such as attendees = 240 gives a value a name. The type describes the kind of value stored.
Five primitive types
| OCR type | Example | Suitable purpose |
|---|---|---|
| Integer | 240 | a whole-number attendee count |
| Real | 12.50 | a ticket price with a fractional part |
| Character | 'A' | one stage code |
| String | 'Night Shift' | an event name made from characters |
| Boolean | True | whether step-free access is available |
In Python, a single character is represented using a string of length one. OCR still expects you to understand the conceptual distinction between a character and a string.
How to choose rather than guess
For the value 240, ask two questions:
- What does it represent? A count of attendees.
- What will the program do with it? Add, subtract and compare whole quantities.
That evidence supports Integer. A ticket reference containing the same digits may instead be a String because it is an identifier, may begin with zero and is not used in arithmetic.
Worked model: choose each type
| Requirement | Reasoning | Choice |
|---|---|---|
| Store ticket price 12.50 | fractional arithmetic is needed | Real |
| Store stage code A | exactly one symbol | Character in OCR terminology |
| Store event name Night Shift | a sequence of characters | String |
| Store whether access is required | exactly two logical states | Boolean |
Sense check: say a meaningful operation aloud. “Add two event names” sounds wrong; “compare access_required with True” fits the Boolean choice.
Guided checkpoint
Use the same two-question method for member_code = '0074'.
- What does it represent? A fixed-format identifier.
- What operations are needed? Displaying and comparing, but not arithmetic.
- Which feature must be preserved? The leading zero.
Now answer the two checks below. In the second one, look for the option that uses both the value and its purpose.
Which value is best described as a character in OCR terminology?
- A'M'
- B'Main'
- C77
- DFalse
A booking reference is stored as the value '0417'. Why is string a better choice than integer?
- AIt will always use less memory.
- BIt preserves the leading zero and is not used in arithmetic.
- CStrings can only contain digits.
- DIntegers cannot be compared.
attendees_text = "240"
attendees = int(attendees_text)
price = float("12.50")
whole_pounds = int(price)
summary = str(attendees) + " tickets"
print(attendees + 10)
print(whole_pounds)
print(summary)
print(type(attendees).__name__)Read the model line by line
The program produces:
250
12
240 tickets
int
- int('240') reads numeric text and creates the integer 240, so adding 10 gives 250.
- float('12.50') creates a real value.
- int(12.50) produces 12 by discarding the fractional part. It does not round.
- str(240) creates text so it can be joined to the word tickets.
A useful prediction routine is: source type → target type → resulting value → information lost?
Examples: int('27') → 27 with no numeric information lost; int(8.9) → 8 with the fractional part lost; int('eight') → conversion error because the text is not a valid integer representation.
Casting changes the representation a program works with
Run the model. Casting 12.50 to an integer produces 12 by discarding the fractional part; this is not rounding. A conversion can fail when the source text is not a valid representation of the target type.
- integer
- string
- Boolean
- discards
- rounds
Model a small input-processing function
Before the independent booking task, study this smaller pattern:
def badge_text(quantity_text):
quantity = int(quantity_text) # text → integer
doubled = quantity * 2 # arithmetic on integers
return str(doubled) + ' badges' # integer → text for a message
Trace badge_text('6'):
- quantity becomes the integer 6;
- doubled becomes 12;
- the returned value is the string '12 badges'.
The independent task uses the same plan with two inputs and a real-valued price. Write the plan as comments first: convert → calculate → format → return.
Build a booking summary
Complete the function so it casts the supplied text values, calculates the total price and returns a sentence in the exact form shown by the checks. The inputs supplied to the function are valid numeric text.
def booking_summary(ticket_count_text, ticket_price_text):
# Convert both values, calculate the total and return the summary.
passThe system also stores event_name = 'Night Shift' and access_required = False. State the most suitable OCR data type for each value and justify each choice.
Link each type to the value stored or the operations/decisions the program needs.
Students type their answer here.
Closed-book checkpoint
Complete each sentence from memory. There is no answer bank and correctness is held for teacher review.
Closed-book retrieval
Without looking back, explain aloud or on paper:
- Why can the digits 0074 be a String rather than an Integer?
- What distinguishes a Character from a String in OCR terminology?
- What does int(8.9) produce, and why is that not rounding?
- What four-step plan did the booking function follow?
Compare your response with every prompt and strengthen any uncertain step. If casting is uncertain, trace source type → target type → result → information loss.