Coding · Grade 8
Functions, Modules and Structured Data
Learners design functions that are easy for teammates to use (default and keyword arguments, docstrings, returning several values), organise code into modules and use the standard library, represent real data as lists of dictionary records with nested fields, and process records with filter, aggregate, transform and key-based sorting.
- 4 lessons
- About 85 minutes
- Check what you learned: 8 questions
- Ways to answer: fill in the blanks, choose an answer, put code in order, trace code, match pairs and type a number
What learners will discover
- Write and call functions with default parameters, keyword arguments, docstrings and multiple return values.
- Organise code into modules and use import, from-import and standard-library modules such as math.
- Represent records as dictionaries in lists and access nested fields correctly.
- Process lists of records by filtering, aggregating, transforming and sorting with a key function.
Lessons
-
Designing better functions 7 steps4 practiceabout 22 min
-
Modules and imports 5 steps3 practiceabout 20 min
-
Records and nested data 5 steps3 practiceabout 20 min
-
Processing structured data 6 steps3 practiceabout 20 min
-
Check what you learned 8 questions at the end
Keep exploring
Games to practice with
- Bug DetectiveA robot program almost works. Run it, spot the buggy block, and fix it.
- Sorting FactoryTurn a work order into if/else rules and watch the conveyor sort every item.
- Garden AutomationProgram a garden robot with sensor rules — then watch a whole day play out.
More 8th grade coding
- 8th Grade Coding Games4 games to play free
- 8th Grade Coding Worksheets10 printable worksheets
Guide for grown-ups
- How to start homeschooling: a step-by-step guide for familiesA guide for parents · 7 min read