Skip to content

Course home

Algorithms

Algorithms

EasyMediumHard
12345678910111213141516
Question 12

A control system is needed for a drone logistics hub to validate incoming delivery drones using a unique Drone Callsign and a five-digit Verification Code.

The drone registry is stored in a two-dimensional list. Each record contains: Registry ID, Manufacturer, Model, Drone Callsign, and Verification Code.

The list is sorted alphabetically by Drone Callsign. All drones have Verification Codes that are integers between 10000 and 99999 inclusive.

Open file D02.

Write a program to meet the following requirements:

Inputs

  • Prompt for and accept a Drone Callsign (no input validation required).
  • Prompt for and accept a five-digit Verification Code. You can assume only configuration-valid integers will be entered.
  • Validate the Verification Code to ensure it is between 10000 and 99999, inclusive. The user must be re-prompted until a valid Verification Code is entered.

Process

  • The program must work with any number of records in the two-dimensional list.
  • Use a linear search to find the record matching both the entered Drone Callsign and Verification Code.
  • Stop searching early when the alphabetical position where the Drone Callsign should have been found is exceeded. For example, if searching for 'DRN-150' and the search reaches 'DRN-180', the program should stop searching as 'DRN-150' cannot appear later in the sorted list.
  • The program does not need to run in a continuous loop after the validation is complete.

Outputs

  • If the correct Drone Callsign and matching Verification Code are found, display a clearing message including the drone's manufacturer and model (e.g. "Landing Cleared: [Manufacturer] [Model] verified.").
  • If they are not found, display a "Landing Denied: Unregistered drone." message.

Do not add any additional functionality.

Use comments, white space and indentation to make your program readable and easy to follow.

Save your amended code as D02FINISHED.py

[15]
Markscheme

Algorithms Questions

  1. GCSE
  2. /Computer Science
  3. /Algorithms

159 exam-style questions on Edexcel GCSE Computer Science Algorithms, covering Constructs for solving problems, Variables, constants and data structures, Arithmetic, relational and logical operators, Tracing algorithm output with trace tables, Types of error and correcting logic errors, Standard algorithms (sorts and searches), and Evaluating algorithm fitness and efficiency. Each one has a worked solution and a mark scheme showing where the marks go.

Question bank