Paper 1 Lab Skills Answers

These answers correspond to Paper 1 Lab Skills Drills.

Answer 1: Workflow

Incremental development makes it easier to locate faults because each stage is tested before the next stage is added. For this task, the student could first test reading data/books.csv, then test the database insert, then test the /books route, instead of debugging CSV, database, and Flask errors all at once.

Mark points:

  • explains small-stage testing or incremental development;
  • links it to easier debugging or reduced risk in the given Flask/CSV/database task.

Common weak answer:

  • saying it is faster to write everything first. Untested combined code is usually harder to debug.

Answer 2: File Management

Two problems:

  • if data/books.csv is moved, the relative path may fail at runtime and the CSV may be omitted from the submitted folder;
  • if books.html is moved, Flask may not find it because templates are expected inside templates/, and the template may be omitted from submission.

Mark points:

  • identifies a path/file-not-found problem for books.csv;
  • identifies template lookup or missing-submission problem for books.html.

Common weak answer:

  • saying file location does not matter if the code is correct. Practical apps depend on correct relative paths.

Answer 3: Requirement Table

CategoryItem
inputuser chooses a category
outputmatching products displayed in a web page
storageshop.db
required filedata/products.csv or templates/products.html

Mark points:

  • identifies an input;
  • identifies an output;
  • identifies a storage item;
  • identifies a required file.

Common weak answer:

  • mixing up input, output, storage, and required files, for example writing only “products” without saying whether it is a file, table, page, or displayed data.

Answer 4: Testing Ladder

Correct order:

B, C, A, D

Reason:

  • B is a small function test;
  • C is a feature/route test;
  • A is an integrated workflow test;
  • D is the final clean rerun.

Mark points:

  • places function test first;
  • places route/feature test before full integration;
  • places full app workflow after smaller checks;
  • places final clean rerun last.

Common weak answer:

  • doing only the final clean rerun. If it fails, it gives little information about where the fault is.

Answer 5: Debugging

Four checks or actions:

  • confirm the current working directory is the task folder;
  • check that data/products.csv exists;
  • check spelling and capitalization of data and products.csv;
  • print or inspect the resolved file path, or use a relative path from app.py.

Mark points:

  • gives four relevant file/path debugging actions.

Common weak answer:

  • changing the CSV contents before checking whether the file is found.

Answer 6: Error Message

The line number points to line 27 in app.py, inside load_products, near where the failure was detected. The ValueError says the program tried to convert an empty string '' to a float, so at least one row has a blank price field or the CSV parsing did not read the intended price value.

Mark points:

  • explains line number/location;
  • explains error type/cause: empty string cannot be converted to float.

Common weak answer:

  • saying Python cannot handle decimals. The problem is the blank value, not floating-point support.

Answer 7: Database Smoke Test

The insert/select test confirms that the program is using the intended database connection and path, that the Product table and columns are compatible with the query, and that inserted data can be read back. This catches path, table-name, schema/column, write-read, and commit/query problems before larger routes depend on the database.

Mark points:

  • confirms database path/table/schema/write-read behaviour;
  • explains why this is useful before building full features.

Common weak answer:

  • saying smoke tests prove the whole Flask app is correct. They only prove one small critical database path and write-read behaviour.

Answer 8: Submission Check

Four checks:

  • app.py is present and starts without error;
  • data/books.csv is present at the expected relative path;
  • templates/books.html is inside templates/;
  • static/style.css and library.db are included if required by the task.

A clean rerun from the submitted folder is also a good final dry-run habit, but the four counted checks above should still be inspected separately.

Mark points:

  • gives four relevant final checks tied to the supplied folder tree.

Common weak answer:

  • checking only that the code editor still has files open. Submission depends on files actually present in the task folder.

Answer 9: Resource Inspection

The header gives the exact field names: product_id, name, price, and category. Inspecting it prevents code from using wrong keys such as id or cost, and confirms the delimiter and expected data shape before writing parsing code.

Mark points:

  • identifies that the header gives exact field names;
  • explains that inspection prevents parsing/key/delimiter assumptions.

Common weak answer:

  • ignoring the header and guessing field names from memory.

Answer 10: Recovery

Three practical recovery actions:

  • return to the last saved working version or checkpoint if available;
  • isolate or disable only the broken image-upload feature if it is not essential, while preserving working product listing and database insert;
  • rerun final tests on the remaining working features and submit the best working version; if the instructions allow, note any remaining limitation clearly.

Mark points:

  • restore or preserve working code;
  • isolate/disable the broken feature rather than breaking everything;
  • rerun tests or document limitation before submission.

Common weak answer:

  • continuing to make large untested changes until time runs out.