🧭Property (Programming)
Also known as Object Property, Instance Variable, Field (Programming)
A named value kept in an object, like a dog's name or age.
Think of it like
It is like a name tag and a height chart for a pet. Each pet has its own.
Example
Emma's game has a player object. Its health property starts at 100 and drops each time the player is hit.
Why it matters
Definition
Example code
python
class Dog:
def __init__(self, name):
self.name = name
rex = Dog("Rex")
print(rex.name)
# RexCommon mistake
Key takeaways
- 1Belongs to an object. Each object has its own copy.
- 2Read with a dot. Like dog.name or player.health.
- 3Guard it. Check values before they change.