Skip to content

Course home

Sign up

Data types and structures

EasyMedium
12345678910
Question 9

A venue ticketing system issues membership pass codes using a specific format.

The format of each pass code is structured as follows:

  • The first character is the membership tier ('G' for Gold, 'S' for Silver, or 'B' for Bronze).
  • This is followed by a hyphen (-).
  • The next field is a 4-character venue code.
  • This is followed by a hyphen (-).
  • The next field is a 3-character event category code.
  • This is followed by a hyphen (-).
  • The final field is a 4-digit unique ticket number.

Example valid pass codes:

  • G-WEMB-CON-1024
  • S-O2AR-SPO-0452
  • B-NECB-EXH-9182

Assume a variable named pass_code stores one of these valid codes as a string.

Construct an expression, using string slicing or indexing, to extract the 4-character venue code from pass_code.

[3]
Markscheme

Data types and structures Questions

  1. GCSE
  2. /Computer Science
  3. /Data types and structures

44 exam-style questions on Edexcel GCSE Computer Science Data types and structures, covering Primitive and structured data types, Using variables and constants, and Manipulating strings. Each one has a worked solution and a mark scheme showing where the marks go.

Question bank