16Hard
0/15

An automated logistics terminal uses a system to dispatch shipments.

The shipment records are stored in a two-dimensional list. Each record contains: Container ID, Client Name, Destination, Tracking Code, and Passcode.

The list is sorted alphabetically by Tracking Code. All shipments have Passcodes that are integers between 5000 and 9999 inclusive.

Open file Q06.

Write a program to meet the following requirements:

Inputs

  • Prompt for and accept a Tracking Code (no input validation required).
  • Prompt for and accept a four-digit Security Passcode. You can assume only configuration-valid integers will be entered.
  • Validate the Passcode to ensure it is between 5000 and 9999, inclusive. The user must be re-prompted until a valid Passcode 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 Tracking Code and Passcode.
  • Stop searching early when the alphabetical position where the Tracking Code should have been found is exceeded. For example, if searching for 'LON104' and the search reaches 'MAN002', the program should stop searching as 'LON104' cannot appear later in the sorted list.
  • The program does not need to run in a continuous loop after the check is complete.

Outputs

  • If the correct Tracking Code and matching Passcode are found, display a personalized shipment confirmation message including the Client Name and Destination.
  • If they are not found, display a "Dispatch Denied - Package Not Located" 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 Q06FINISHED.py

[15]
PreviousNext

Computational thinking Questions

  1. GCSE
  2. /Computer Science
  3. /Computational thinking