Skip to content
PlayOwl

Coding · Grade 10

Objects, Classes and Encapsulation

Using a makerspace tool library, learners design classes that start valid, act through well-named methods and print readably with __str__. They protect data with encapsulation (underscore conventions and validating properties), distinguish class and instance attributes and identity from equality, and build classes from others with composition (has-a) and inheritance (is-a), including overriding and polymorphism.

  • 4 lessons
  • About 95 minutes
  • Check what you learned: 8 questions
  • Ways to answer: choose an answer, put code in order, trace code, match pairs, type a number and sort into groups
Try it now (no account) One of the five free starter courses Open in PlayOwl

What learners will discover

  • Design classes with __init__, methods that return results and a readable __str__.
  • Encapsulate data with internal attributes and validating properties so invariants are preserved.
  • Distinguish class attributes from instance attributes, and identity (is) from equality (== and __eq__).
  • Use composition and inheritance appropriately, including overriding, super() and polymorphism.

Lessons

  1. Designing classes 5 steps2 practiceabout 20 min
  2. Encapsulation 6 steps4 practiceabout 24 min
  3. Class attributes, identity and equality 4 steps2 practiceabout 20 min
  4. Composition and inheritance 5 steps3 practiceabout 22 min
  5. Check what you learned 8 questions at the end

Keep exploring

More 10th grade coding

Guide for grown-ups