In Python, docstrings can be used in methods just like functions, but they belong to a **class** and describe how the method works within that class.
### Example:
```python
```
### Key Points:
1. **Methods are functions inside a class.** Docstrings work the same way, but they document the method **within a class context**.
2. **Use triple quotes (`"""`) at the beginning of the method.** This helps generate structured documentation.
3. **Docstrings can be retrieved using `.__doc__`.** This works for both classes and methods.
### Example:
```python
Python:
class Calculator:
"""A simple calculator class."""
def add(self, a, b):
"""
Adds two numbers and returns the result.
Parameters:
a (int, float): First number.
b (int, float): Second number.
Returns:
int, float: Sum of the numbers.
"""
return a + b
# Accessing method docstring
print(Calculator.add.__doc__)
### Key Points:
1. **Methods are functions inside a class.** Docstrings work the same way, but they document the method **within a class context**.
2. **Use triple quotes (`"""`) at the beginning of the method.** This helps generate structured documentation.
3. **Docstrings can be retrieved using `.__doc__`.** This works for both classes and methods.