Skip to content

Course home

Sign up

Input/output

EasyMediumHard
123
Question 2

A program is required to process data about fleet vehicles. The data is stored in a comma-separated value text file named Vehicles.txt

The columns in the data file are:

  • make
  • model
  • year

Open file Q06.py and write a program to meet these requirements:

  • Create a primary key for each vehicle. A valid key is a single string consisting of (in this order):
    • The first two letters of the make name
    • The year integer divided by 10 (using integer division)
    • The first three letters of the model name
  • Create a record for each vehicle. A valid record consists of (in this order):
    • The generated key, the year (as an integer), the make and the model
  • Store the record for each vehicle in a 2D list named vehicleTable
  • Call the supplied subprogram, displayTable(), to show the contents of vehicleTable
  • The program must work with any number of lines in the data file.

Use comments, white space, and indentation to make your program easy to read and understand.

Do not add any additional functionality.

Save your amended code as Q06FINISHED.py

[15]
Markscheme

Input/output Questions

  1. GCSE
  2. /Computer Science
  3. /Input/output

25 exam-style questions on Edexcel GCSE Computer Science Input/output, covering Accepting and responding to user input, Reading and writing CSV text files, Implementing validation, and Implementing authentication. Each one has a worked solution and a mark scheme showing where the marks go.

Question bank