Lesson 21 — Properties
Computed attributes
@property makes a method act like a read-only attribute: you write c.area, not c.area(). The value is calculated every time you read it, so it always matches the other fields. Put @property on the line right above the def.
class User:
def __init__(self, first, last):
self.first, self.last = first, last
@property
def full(self):
return self.first + " " + self.last
Why it matters: it hides logic behind a clean attribute-style API.
Add an area property to Circle (round(3.14159 * r * r, 2)) and print it.
Run your code — when the output matches the task, you will see a green check. Then mark the lesson complete.
A quick 3-question quiz on this lesson — instant feedback.
Ready for more? Optional paid resources that pick up where this lesson leaves off.
Some links on this page are affiliate links: we may earn a commission at no extra cost to you. As an Amazon Associate I earn from qualifying purchases.
Project-based Python Intermediate courses if you want a structured paid path after the free lessons. Wait for a sale — prices drop often.
Browse on Udemy →Search Amazon for Python Intermediate books — check the publication year so the examples match current versions.
Search Amazon →