Review, explain, practice

Study guide: Read Text Files and Structured Formats

Interpret CSV A,"red,blue",5 and JSON {"id":"007","count":5}. Plan a read-only source inspection and a separate derived output.

Download the grade study pack

Ideas to explain in your own words

Useful vocabulary

CSV quoting
Rules allowing separators inside a field.
JSON object
Text keys associated with structured values.
file mode
The requested type of file operation.

Watch your reasoning

A worked review example

Paper Python 3 expression: " red ".strip(). What value results? The supported answer is 'red'. Tracing the expression under Python 3 rules gives 'red'. Remove surrounding whitespace and preserve characters inside the stated text. Do not collapse an internal space just because surrounding whitespace is trimmed. Python strip removes specified leading and trailing characters, or surrounding whitespace when no characters are specified. Purpose: inspect original without changing it. Which stated plan fits the purpose? The supported answer is Read original. Use read mode for inspection and a separate destination when the original must remain. Opening a destination for writing can replace existing content; do not treat it as harmless inspection. The supplied facts, rather than an assumed real-world detail, determine this paper case. Compare the recorded action or value with the stated rule before choosing an answer.

Make a practice plan

  1. Make a four-row summary, one row for each lesson, with its computing idea and one worked decision.
  2. Explain one tempting mistake using the actual supplied example.
  3. Complete the new unit review before consulting its explanations.
  4. Try the transfer task on paper and compare your evidence against the model response.