Coding · Grade 10
Files, Data Validation and Errors
Using athletics results files, learners read and write text files safely with with and in-memory file objects, validate every record for field count, type and range while logging rejects with line numbers, handle exceptions precisely with try, except, else and finally, and assemble a robust read-validate-process-report pipeline whose summary never hides rejected data.
- 4 lessons
- About 90 minutes
- Check what you learned: 8 questions
- Ways to answer: choose an answer, put code in order, trace code, put in order, sort into groups and true or false
What learners will discover
- Read and write text files safely, stripping, splitting and converting each line's fields.
- Validate records for field count, type and range, raising specific errors and logging rejects with line numbers.
- Handle exceptions precisely with specific except blocks, else and finally, avoiding bare excepts.
- Build a read-validate-process-report pipeline that reports rejected data honestly.
Lessons
-
Reading and writing files 6 steps3 practiceabout 20 min
-
Validating records 5 steps3 practiceabout 22 min
-
Exceptions in depth 5 steps3 practiceabout 22 min
-
A robust pipeline end to end 4 steps3 practiceabout 20 min
-
Check what you learned 8 questions at the end
Keep exploring
More 10th grade coding
- 10th Grade Coding Worksheets11 printable worksheets
Guide for grown-ups
- How to start homeschooling: a step-by-step guide for familiesA guide for parents · 7 min read