43Medium
0/3

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]

Data types and structures Questions

Practise Edexcel GCSE Computer Science Data types and structures with exam-style questions for GCSE Computer Science. 45 questions covering Primitive and structured data types, Using variables and constants, and Manipulating strings, matched to the Edexcel GCSE Computer Science (1CP2) specification and written in Paper 1 and Paper 2 style. Every question includes a full worked solution and mark scheme, so you can see where marks are awarded rather than just whether you got the answer right.

PreviousNext

Data types and structures Questions

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