Data types and structures

EasyMedium
12345678910
Question 5
Medium

An automated weather monitoring network generates data telemetry packets with a specific code format.

The format of each telemetry packet code is structured as follows:

  • The first two characters represent the country region code (e.g., 'UK', 'US', 'FR').
  • This is followed by a colon (:).
  • The next field is a 5-character station identifier.
  • This is followed by a colon (:).
  • The next field is a 4-character sensor type code.
  • This is followed by a colon (:).
  • The final field is a 5-digit transmission sequence number.

Example valid telemetry packet codes:

  • UK:STN03:TEMP:08194
  • US:STN21:WIND:11048
  • FR:STN09:HUMI:00392

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

Construct an expression, using string slicing or indexing, to extract the 4-character sensor type code from packet_id.

[3]

Data types and structures Questions

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