SHSubjectHub

File handling and SQL

OCR J2772.2 L9GCSELesson packSubscription
Also online

This worksheet marks itself

Set it as homework or classwork and every answer is marked as pupils go, with feedback on what they got wrong. The scores go straight into your mark book, so you can see who needs help before the next lesson.

  • 12 questions
  • 36 marks
  • about 40 minutes
  • marked instantly

Question types: short answer, multiple choice, true or false.

Try one from this worksheet

The text file log.txt already holds three lines. Identify the Python line that opens it so that new lines are added to the end and the three lines are kept.

Pick an answer: it's marked straight away, just as your pupils would see it.

About this resource

OCR GCSE Computer Science (J277) 2.2.3 Additional programming techniques: basic file handling (open, read, write, close) and the use of SQL to search for data. Python lesson 9 of 10 in 2.2 Programming fundamentals, with OCR Exam Reference Language beside the Python: a spot-the-mistakes Do Now, a…

18 slides.

Lesson outline

  1. Do Now: spot the 3 mistakes
  2. Do Now: answers
  3. Key idea: Write to a file: open, write, close
  4. Key idea: Read a file, one line at a time
  5. Quick check: the end of a line
  6. Key idea: Every line at once, and adding to the end
  7. Key idea: SQL: search a table
  8. Set 1: write, then read back
  9. Set 2: read every line
  10. Exam question E1: read a file of scores
  11. Model answer E1
  12. Exam question E2: refine an SQL statement
Unit bundle2.2 Programming fundamentals · Python and OCR ERL lessons
Part of: 2.2 Programming fundamentals · Python and OCR ERL lessons: the whole unitEvery resource in the unit in one zip.

More from 2.2 Programming fundamentals · Python and OCR ERL lessons