---
title: "Classes and Objects: Bundling Data with Behaviour"
description: "A class describes what every object of its kind holds and what it can do; an object is one filled-in copy of that description. The constructor sets the starting state and the methods are the only code"
canonical: https://lightmysky.com/learn/computing/classes-and-objects-bundling-data-with-behaviour-mt_kRvg7LZ_kk
source: https://lightmysky.com/learn/computing/classes-and-objects-bundling-data-with-behaviour-mt_kRvg7LZ_kk.md
retrieved: 2026-09-12
---

> **Agent view.** This is the Markdown twin of the page, for tools and assistants.
> When to use this site, and the call that answers each job: https://lightmysky.com/agent-instructions.md
> API description (OpenAPI 3.1): https://lightmysky.com/openapi.json · Authentication: https://lightmysky.com/auth.md
> Pricing: https://lightmysky.com/pricing.md · Catalog: https://lightmysky.com/llms.txt · Full catalog: https://lightmysky.com/llms-full.txt
> Every machine-readable file on this domain: https://lightmysky.com/.well-known/ai-catalog.json
> Ask for Markdown with `Accept: text/markdown`, a `.md` address, or `?mode=agent`.

# Classes and Objects: Bundling Data with Behaviour

A class describes what every object of its kind holds and what it can do; an object is one filled-in copy of that description. The constructor sets the starting state and the methods are the only code that changes it.

Subject: Computing · Area: Programming · Ages 16 to 18
Page: https://lightmysky.com/learn/computing/classes-and-objects-bundling-data-with-behaviour-mt_kRvg7LZ_kk

## Ready when they can

- Define a class with a constructor and two methods, then create two objects from it
- Say what belongs to the object and what belongs to the class
- Rewrite a loose group of variables and functions as one class, and say what improved

## Lesson: Blueprints that build their own copies

A class is a blueprint that defines the fields and procedures of one kind of thing. An object, also called an instance, is a single thing built from that blueprint with its own data. With class Cat, pet_1 = Cat() and pet_2 = Cat() are two separate cats, and changing one never touches the other.

**Example.** The constructor, __init__(), runs each time a new object is created and sets its starting state. In class Account, __init__ stores the opening balance, deposit adds to it and withdraw takes from it. Two accounts, mia = Account(100) and sam = Account(40), then evolve independently as each calls its own methods.

Data unique to one object, like a name or a balance, is an instance attribute reached as pet_1.name. Data shared by every object, like the shop name loc, is a class attribute reached as CoffeeOrder.loc. Instance methods are the code that reads and updates that state: self always means the object that called, so room_1.area() uses room_1 values only.

**Tip.** Turn a loose bundle of variables plus free functions into a class when they all describe one thing. Related data and behaviour then sit together, shared logic is written once, and each object guards its own state through its methods instead of letting any line of code rewrite it.

**Recap.** The class describes the kind, each object carries its own data, and methods are how that data changes.

## Practice

8 questions on this page, each with its working shown.

## Needs first

- [Dictionaries: Values Found by Key](https://lightmysky.com/learn/computing/dictionaries-values-found-by-key-mt_mofpj0n5AM)
- [Defining a Function with Parameters](https://lightmysky.com/learn/computing/defining-a-function-with-parameters-mt_pyo7yBg4H3)

## Opens up

- [Inheritance and Overriding Behaviour](https://lightmysky.com/learn/computing/inheritance-and-overriding-behaviour-mt_wBp7j_B6fj)
