GCSE Computer Science: Strings, Subroutines and Files

The programming paper expects students to read short programs precisely and to explain the techniques behind them. This material trains the programming techniques that sit beyond loops and selection, based on the DfE GCSE subject content for computer science, which requires following and writing algorithms, data types and data structures including records, and structuring programs into modular parts with clear interfaces, and on the programming-technique sections of the exam board specifications: string handling, subroutines, random numbers and file handling.

The quiz has twelve questions. Seven ask what a short program prints, and every value and file content they need is in the question: a substring from a city name, a slice combined with an upper-case letter, a character code shifted three places, two strings added before and after casting, a function whose local variable hides a global one, a function and a procedure working together, a text file of scores added line by line and a word whose letters are counted in a loop. The others test the reasoning behind the code: why local variables are safer than global ones, which totals two random dice can give, what write mode does to a file that already holds data, and why a record suits a book with a title, a page count, a price and a loan flag. Code is shown in Python, and pseudocode follows the style of OCR's Exam Reference Language, where strings are indexed from zero; students taking another board will recognise the same ideas under slightly different keywords.

Every explanation walks through the program line by line. The flashcards collect the definitions and the details that cost marks: slices that stop before the end index, ord and chr, casting, procedures and functions, parameters, local and global scope, randint including both ends, write and append modes, and records.

The written work gives eight longer tasks, each with a model answer and the points a marker would look for: writing a password-checking function, explaining procedures and functions, local and global variables, the steps to count and append to a file, designing a record, simulating dice, predicting the output of string operations and explaining the benefits of subroutines.

An oral practice with an examiner is included too: short programs read aloud one line at a time, one question at a time and brief feedback at the end. The material suits Year 10 and Year 11 students preparing for the programming paper.

  • Predict the result of string operations: length, slicing or substring, concatenation, case changes and character codes
  • Explain the effect of casting between strings and numbers
  • Distinguish procedures from functions and trace parameters and return values
  • Explain local and global scope and why local variables are good practice
  • Use random number generation and state the range of values it can produce
  • Read from and write to text files, including the difference between overwriting and appending
  • Use records to group related data of different types

Practice material written by Zestly, based on the DfE GCSE subject content for computer science (algorithms, data types and structures, modular programs) and the programming-technique sections of the AQA (8525, 3.2) and OCR (J277, 2.2.3) GCSE Computer Science specifications. Pseudocode follows the style of OCR's Exam Reference Language.

Sample question

What does this Python program print? ```python a = "7" b = "3" print(a + b) print(int(a) + int(b)) ```

See the answer

73 and then 10

a and b are strings, so + joins them (concatenation), printing 73. After casting both to integers with int, + adds them, printing 10.

← Computer Science

↑ GCSE