text:
<|im_start|>system
You are Echidna, a helpful AI assistant. Answer accurately with clear markdown formatting when appropriate. Be thorough but concise.<|im_end|>
<|im_start|>user
Solve: 25 × 48<|im_end|>
<|im_start|>assistant
**1,200**

25 × 48 = 25 × (50 - 2) = 1,250 - 50 = 1,200<|im_end|>

[System] You are Echidna, a helpful AI assistant. Answer accurately with clear markdown formatting when appropriate. Be thorough but concise.

[User] Solve: 25 × 48

[Assistant]
**1,200**

25 × 48 = 25 × (50 - 2) = 1,250 - 50 = 1,200


text:
<|im_start|>system
You are Echidna, a helpful AI assistant. Answer accurately with clear markdown formatting when appropriate. Be thorough but concise.<|im_end|>
<|im_start|>user
What is 15% of 340?<|im_end|>
<|im_start|>assistant
**51**

10% of 340 = 34
5% of 340 = 17
34 + 17 = 51<|im_end|>

[System] You are Echidna, a helpful AI assistant. Answer accurately with clear markdown formatting when appropriate. Be thorough but concise.

[User] What is 15% of 340?

[Assistant]
**51**

10% of 340 = 34
5% of 340 = 17
34 + 17 = 51


text:
<|im_start|>system
You are Echidna, a helpful AI assistant. Answer accurately with clear markdown formatting when appropriate. Be thorough but concise.<|im_end|>
<|im_start|>user
Find the LCM of 12 and 18.<|im_end|>
<|im_start|>assistant
**36**

Multiples of 12: 12, 24, 36, 48...
Multiples of 18: 18, 36, 54...
LCM = 36<|im_end|>

[System] You are Echidna, a helpful AI assistant. Answer accurately with clear markdown formatting when appropriate. Be thorough but concise.

[User] Find the LCM of 12 and 18.

[Assistant]
**36**

Multiples of 12: 12, 24, 36, 48...
Multiples of 18: 18, 36, 54...
LCM = 36


text:
<|im_start|>system
You are Echidna, a helpful AI assistant. Answer accurately with clear markdown formatting when appropriate. Be thorough but concise.<|im_end|>
<|im_start|>user
Solve: 2x + 5 = 3x - 2<|im_end|>
<|im_start|>assistant
**x = 7**

2x + 5 = 3x - 2
5 + 2 = 3x - 2x
7 = x<|im_end|>

[System] You are Echidna, a helpful AI assistant. Answer accurately with clear markdown formatting when appropriate. Be thorough but concise.

[User] Solve: 2x + 5 = 3x - 2

[Assistant]
**x = 7**

2x + 5 = 3x - 2
5 + 2 = 3x - 2x
7 = x


text:
<|im_start|>system
You are Echidna, a helpful AI assistant. Answer accurately with clear markdown formatting when appropriate. Be thorough but concise.<|im_end|>
<|im_start|>user
What is the area of a triangle with base 10 and height 6?<|im_end|>
<|im_start|>assistant
**30 square units**

Area = ½ × base × height = ½ × 10 × 6 = 30<|im_end|>

[System] You are Echidna, a helpful AI assistant. Answer accurately with clear markdown formatting when appropriate. Be thorough but concise.

[User] What is the area of a triangle with base 10 and height 6?

[Assistant]
**30 square units**

Area = ½ × base × height = ½ × 10 × 6 = 30


text:
<|im_start|>system
You are Echidna, a helpful AI assistant. Answer accurately with clear markdown formatting when appropriate. Be thorough but concise.<|im_end|>
<|im_start|>user
Convert 0.375 to a fraction.<|im_end|>
<|im_start|>assistant
**3/8**

0.375 = 375/1000 = 75/200 = 15/40 = 3/8<|im_end|>

[System] You are Echidna, a helpful AI assistant. Answer accurately with clear markdown formatting when appropriate. Be thorough but concise.

[User] Convert 0.375 to a fraction.

[Assistant]
**3/8**

0.375 = 375/1000 = 75/200 = 15/40 = 3/8


text:
<|im_start|>system
You are Echidna, a helpful AI assistant. Answer accurately with clear markdown formatting when appropriate. Be thorough but concise.<|im_end|>
<|im_start|>user
A car travels 180 km in 2.5 hours. What's the speed?<|im_end|>
<|im_start|>assistant
**72 km/h**

Speed = distance / time = 180 / 2.5 = 72 km/h<|im_end|>

[System] You are Echidna, a helpful AI assistant. Answer accurately with clear markdown formatting when appropriate. Be thorough but concise.

[User] A car travels 180 km in 2.5 hours. What's the speed?

[Assistant]
**72 km/h**

Speed = distance / time = 180 / 2.5 = 72 km/h


text:
<|im_start|>system
You are Echidna, a helpful AI assistant. Answer accurately with clear markdown formatting when appropriate. Be thorough but concise.<|im_end|>
<|im_start|>user
What is 7³?<|im_end|>
<|im_start|>assistant
**343**

7 × 7 × 7 = 49 × 7 = 343<|im_end|>

[System] You are Echidna, a helpful AI assistant. Answer accurately with clear markdown formatting when appropriate. Be thorough but concise.

[User] What is 7³?

[Assistant]
**343**

7 × 7 × 7 = 49 × 7 = 343


text:
<|im_start|>system
You are Echidna, a helpful AI assistant. Answer accurately with clear markdown formatting when appropriate. Be thorough but concise.<|im_end|>
<|im_start|>user
If 8 workers take 12 days, how long for 6 workers?<|im_end|>
<|im_start|>assistant
**16 days**

Total work = 8 × 12 = 96 worker-days
With 6 workers: 96 / 6 = 16 days<|im_end|>

[System] You are Echidna, a helpful AI assistant. Answer accurately with clear markdown formatting when appropriate. Be thorough but concise.

[User] If 8 workers take 12 days, how long for 6 workers?

[Assistant]
**16 days**

Total work = 8 × 12 = 96 worker-days
With 6 workers: 96 / 6 = 16 days


text:
<|im_start|>system
You are Echidna, a helpful AI assistant. Answer accurately with clear markdown formatting when appropriate. Be thorough but concise.<|im_end|>
<|im_start|>user
What percent of 80 is 20?<|im_end|>
<|im_start|>assistant
**25%**

20/80 = 0.25 = 25%<|im_end|>

[System] You are Echidna, a helpful AI assistant. Answer accurately with clear markdown formatting when appropriate. Be thorough but concise.

[User] What percent of 80 is 20?

[Assistant]
**25%**

20/80 = 0.25 = 25%


text:
<|im_start|>system
You are Echidna, a helpful AI assistant. Answer accurately with clear markdown formatting when appropriate. Be thorough but concise.<|im_end|>
<|im_start|>user
Solve: √144 + √25<|im_end|>
<|im_start|>assistant
**17**

√144 = 12, √25 = 5
12 + 5 = 17<|im_end|>

[System] You are Echidna, a helpful AI assistant. Answer accurately with clear markdown formatting when appropriate. Be thorough but concise.

[User] Solve: √144 + √25

[Assistant]
**17**

√144 = 12, √25 = 5
12 + 5 = 17


text:
<|im_start|>system
You are Echidna, a helpful AI assistant. Answer accurately with clear markdown formatting when appropriate. Be thorough but concise.<|im_end|>
<|im_start|>user
What is the sum of angles in a pentagon?<|im_end|>
<|im_start|>assistant
**540°**

(n-2) × 180° = (5-2) × 180° = 3 × 180° = 540°<|im_end|>

[System] You are Echidna, a helpful AI assistant. Answer accurately with clear markdown formatting when appropriate. Be thorough but concise.

[User] What is the sum of angles in a pentagon?

[Assistant]
**540°**

(n-2) × 180° = (5-2) × 180° = 3 × 180° = 540°


text:
<|im_start|>system
You are Echidna, a helpful AI assistant. Answer accurately with clear markdown formatting when appropriate. Be thorough but concise.<|im_end|>
<|im_start|>user
Calculate: (3 + 7) × (12 - 5)<|im_end|>
<|im_start|>assistant
**70**

(10) × (7) = 70<|im_end|>

[System] You are Echidna, a helpful AI assistant. Answer accurately with clear markdown formatting when appropriate. Be thorough but concise.

[User] Calculate: (3 + 7) × (12 - 5)

[Assistant]
**70**

(10) × (7) = 70


text:
<|im_start|>system
You are Echidna, a helpful AI assistant. Answer accurately with clear markdown formatting when appropriate. Be thorough but concise.<|im_end|>
<|im_start|>user
What is 40% of 250 minus 15% of 200?<|im_end|>
<|im_start|>assistant
**70**

40% of 250 = 100
15% of 200 = 30
100 - 30 = 70<|im_end|>

[System] You are Echidna, a helpful AI assistant. Answer accurately with clear markdown formatting when appropriate. Be thorough but concise.

[User] What is 40% of 250 minus 15% of 200?

[Assistant]
**70**

40% of 250 = 100
15% of 200 = 30
100 - 30 = 70


text:
<|im_start|>system
You are Echidna, a helpful AI assistant. Answer accurately with clear markdown formatting when appropriate. Be thorough but concise.<|im_end|>
<|im_start|>user
A rectangle has perimeter 30 and width 5. Find length.<|im_end|>
<|im_start|>assistant
**Length = 10**

Perimeter = 2L + 2W
30 = 2L + 10
20 = 2L
L = 10<|im_end|>

[System] You are Echidna, a helpful AI assistant. Answer accurately with clear markdown formatting when appropriate. Be thorough but concise.

[User] A rectangle has perimeter 30 and width 5. Find length.

[Assistant]
**Length = 10**

Perimeter = 2L + 2W
30 = 2L + 10
20 = 2L
L = 10


text:
<|im_start|>system
You are Echidna, a helpful AI assistant. Answer accurately with clear markdown formatting when appropriate. Be thorough but concise.<|im_end|>
<|im_start|>user
What comes next: 1, 4, 9, 16, 25, ?<|im_end|>
<|im_start|>assistant
**36**

These are square numbers: 1², 2², 3², 4², 5², 6² = 36<|im_end|>

[System] You are Echidna, a helpful AI assistant. Answer accurately with clear markdown formatting when appropriate. Be thorough but concise.

[User] What comes next: 1, 4, 9, 16, 25, ?

[Assistant]
**36**

These are square numbers: 1², 2², 3², 4², 5², 6² = 36


text:
<|im_start|>system
You are Echidna, a helpful AI assistant. Answer accurately with clear markdown formatting when appropriate. Be thorough but concise.<|im_end|>
<|im_start|>user
Express 5/6 as a decimal to 3 places.<|im_end|>
<|im_start|>assistant
**0.833**

5 ÷ 6 = 0.8333... ≈ 0.833<|im_end|>

[System] You are Echidna, a helpful AI assistant. Answer accurately with clear markdown formatting when appropriate. Be thorough but concise.

[User] Express 5/6 as a decimal to 3 places.

[Assistant]
**0.833**

5 ÷ 6 = 0.8333... ≈ 0.833


text:
<|im_start|>system
You are Echidna, a helpful AI assistant. Answer accurately with clear markdown formatting when appropriate. Be thorough but concise.<|im_end|>
<|im_start|>user
A jacket costs $80 after a 20% discount. Original price?<|im_end|>
<|im_start|>assistant
**$100**

Let x = original price
x × 0.80 = 80
x = 80 / 0.80 = $100<|im_end|>

[System] You are Echidna, a helpful AI assistant. Answer accurately with clear markdown formatting when appropriate. Be thorough but concise.

[User] A jacket costs $80 after a 20% discount. Original price?

[Assistant]
**$100**

Let x = original price
x × 0.80 = 80
x = 80 / 0.80 = $100


text:
<|im_start|>system
You are Echidna, a helpful AI assistant. Answer accurately with clear markdown formatting when appropriate. Be thorough but concise.<|im_end|>
<|im_start|>user
If f(x) = 3x² - 2x + 1, find f(2).<|im_end|>
<|im_start|>assistant
**f(2) = 9**

3(4) - 2(2) + 1 = 12 - 4 + 1 = 9<|im_end|>

[System] You are Echidna, a helpful AI assistant. Answer accurately with clear markdown formatting when appropriate. Be thorough but concise.

[User] If f(x) = 3x² - 2x + 1, find f(2).

[Assistant]
**f(2) = 9**

3(4) - 2(2) + 1 = 12 - 4 + 1 = 9


text:
<|im_start|>system
You are Echidna, a helpful AI assistant. Answer accurately with clear markdown formatting when appropriate. Be thorough but concise.<|im_end|>
<|im_start|>user
How many cm in 2.45 meters?<|im_end|>
<|im_start|>assistant
**245 cm**

1 meter = 100 cm
2.45 × 100 = 245 cm<|im_end|>

[System] You are Echidna, a helpful AI assistant. Answer accurately with clear markdown formatting when appropriate. Be thorough but concise.

[User] How many cm in 2.45 meters?

[Assistant]
**245 cm**

1 meter = 100 cm
2.45 × 100 = 245 cm


text:
<|im_start|>system
You are Echidna, a helpful AI assistant. Answer accurately with clear markdown formatting when appropriate. Be thorough but concise.<|im_end|>
<|im_start|>user
What is the average of 12, 18, 24, 30, 36?<|im_end|>
<|im_start|>assistant
**24**

Sum = 120
Count = 5
Average = 120/5 = 24<|im_end|>

[System] You are Echidna, a helpful AI assistant. Answer accurately with clear markdown formatting when appropriate. Be thorough but concise.

[User] What is the average of 12, 18, 24, 30, 36?

[Assistant]
**24**

Sum = 120
Count = 5
Average = 120/5 = 24


text:
<|im_start|>system
You are Echidna, a helpful AI assistant. Answer accurately with clear markdown formatting when appropriate. Be thorough but concise.<|im_end|>
<|im_start|>user
Solve: 3(x - 4) = 2(x + 1)<|im_end|>
<|im_start|>assistant
**x = 14**

3x - 12 = 2x + 2
3x - 2x = 2 + 12
x = 14<|im_end|>

[System] You are Echidna, a helpful AI assistant. Answer accurately with clear markdown formatting when appropriate. Be thorough but concise.

[User] Solve: 3(x - 4) = 2(x + 1)

[Assistant]
**x = 14**

3x - 12 = 2x + 2
3x - 2x = 2 + 12
x = 14


text:
<|im_start|>system
You are Echidna, a helpful AI assistant. Answer accurately with clear markdown formatting when appropriate. Be thorough but concise.<|im_end|>
<|im_start|>user
A circle has radius 7 cm. Find circumference.<|im_end|>
<|im_start|>assistant
**≈ 43.98 cm**

C = 2πr = 2 × π × 7 ≈ 43.98 cm<|im_end|>

[System] You are Echidna, a helpful AI assistant. Answer accurately with clear markdown formatting when appropriate. Be thorough but concise.

[User] A circle has radius 7 cm. Find circumference.

[Assistant]
**≈ 43.98 cm**

C = 2πr = 2 × π × 7 ≈ 43.98 cm


text:
<|im_start|>system
You are Echidna, a helpful AI assistant. Answer accurately with clear markdown formatting when appropriate. Be thorough but concise.<|im_end|>
<|im_start|>user
What is the GCD of 48 and 180?<|im_end|>
<|im_start|>assistant
**12**

48 = 2⁴ × 3
180 = 2² × 3² × 5
GCD = 2² × 3 = 12<|im_end|>

[System] You are Echidna, a helpful AI assistant. Answer accurately with clear markdown formatting when appropriate. Be thorough but concise.

[User] What is the GCD of 48 and 180?

[Assistant]
**12**

48 = 2⁴ × 3
180 = 2² × 3² × 5
GCD = 2² × 3 = 12


text:
<|im_start|>system
You are Echidna, a helpful AI assistant. Answer accurately with clear markdown formatting when appropriate. Be thorough but concise.<|im_end|>
<|im_start|>user
Calculate compound interest: $1000 at 5% for 3 years.<|im_end|>
<|im_start|>assistant
**$1,157.63**

A = P(1 + r)^t = 1000(1.05)³
= 1000 × 1.157625 = $1,157.63<|im_end|>

[System] You are Echidna, a helpful AI assistant. Answer accurately with clear markdown formatting when appropriate. Be thorough but concise.

[User] Calculate compound interest: $1000 at 5% for 3 years.

[Assistant]
**$1,157.63**

A = P(1 + r)^t = 1000(1.05)³
= 1000 × 1.157625 = $1,157.63


text:
<|im_start|>system
You are Echidna, a helpful AI assistant. Answer accurately with clear markdown formatting when appropriate. Be thorough but concise.<|im_end|>
<|im_start|>user
What are Python dataclasses?<|im_end|>
<|im_start|>assistant
**Dataclasses** (Python 3.7+) reduce boilerplate for data-holding classes:

```python
from dataclasses import dataclass

@dataclass
class Document:
    title: str
    page_count: int = 0
    tags: list = None  # Careful: mutable default!
```

Auto-generates: `__init__`, `__repr__`, `__eq__`. Add `frozen=True` for immutability, `order=True` for comparison.

Use for: config objects, API models, data transfer objects. Don't use for: classes with complex behavior (use regular class instead).<|im_end|>

[System] You are Echidna, a helpful AI assistant. Answer accurately with clear markdown formatting when appropriate. Be thorough but concise.

[User] What are Python dataclasses?

[Assistant]
**Dataclasses** (Python 3.7+) reduce boilerplate for data-holding classes:

```python
from dataclasses import dataclass

@dataclass
class Document:
    title: str
    page_count: int = 0
    tags: list = None  # Careful: mutable default!
```

Auto-generates: `__init__`, `__repr__`, `__eq__`. Add `frozen=True` for immutability, `order=True` for comparison.

Use for: config objects, API models, data transfer objects. Don't use for: classes with complex behavior (use regular class instead).


[System] You are Echidna, a helpful AI assistant. Answer accurately with clear markdown formatting when appropriate. Be thorough but concise.

[User] What's the difference between `sort()` and `sorted()`?

[Assistant]
| Method | Modifies original? | Returns | Works on |
|:---|:---|:---|:---|
| `list.sort()` | Yes (in-place) | None | Lists only |
| `sorted()` | No | New sorted list | Any iterable |

```python
nums = [3, 1, 2]
sorted_nums = sorted(nums)  # [1, 2, 3], nums unchanged
nums.sort()                 # None, nums is now [1, 2, 3]
```
Use `sorted()` when you need the original data preserved.


text:
<|im_start|>system
You are Echidna, a helpful AI assistant. Answer accurately with clear markdown formatting when appropriate. Be thorough but concise.<|im_end|>
<|im_start|>user
What is the Python GIL?<|im_end|>
<|im_start|>assistant
The **Global Interpreter Lock (GIL)** prevents multiple native threads from executing Python bytecode simultaneously:

- **Why**: Simplifies CPython memory management (reference counting)
- **Effect**: CPU-bound multi-threaded code doesn't get true parallelism
- **Not affected**: I/O-bound code (threads release GIL while waiting)

**Workarounds:**
- `multiprocessing` — separate processes (no GIL)
- `asyncio` — cooperative concurrency (single thread)
- C extensions — can release GIL during computation

Python 3.13 introduces optional free-threaded mode (no GIL).<|im_end|>

[System] You are Echidna, a helpful AI assistant. Answer accurately with clear markdown formatting when appropriate. Be thorough but concise.

[User] What is the Python GIL?

[Assistant]
The **Global Interpreter Lock (GIL)** prevents multiple native threads from executing Python bytecode simultaneously:

- **Why**: Simplifies CPython memory management (reference counting)
- **Effect**: CPU-bound multi-threaded code doesn't get true parallelism
- **Not affected**: I/O-bound code (threads release GIL while waiting)

**Workarounds:**
- `multiprocessing` — separate processes (no GIL)
- `asyncio` — cooperative concurrency (single thread)
- C extensions — can release GIL during computation

Python 3.13 introduces optional free-threaded mode (no GIL).


text:
<|im_start|>system
You are Echidna, a helpful AI assistant. Answer accurately with clear markdown formatting when appropriate. Be thorough but concise.<|im_end|>
<|im_start|>user
Explain Python generators and `yield`.<|im_end|>
<|im_start|>assistant
A **generator** produces values lazily using `yield`:

```python
def countdown(n):
    while n > 0:
        yield n
        n -= 1

for num in countdown(5):
    print(num)  # 5, 4, 3, 2, 1
```

**Benefits:**
- **Memory efficient**: Only one value in memory at a time
- **Infinite sequences**: `itertools.count()` never exhausts memory
- **Pipeline composition**: Chain generators for stream processing

Generator expressions: `(x**2 for x in range(10))` — like list comprehension but lazy.<|im_end|>

[System] You are Echidna, a helpful AI assistant. Answer accurately with clear markdown formatting when appropriate. Be thorough but concise.

[User] Explain Python generators and `yield`.

[Assistant]
A **generator** produces values lazily using `yield`:

```python
def countdown(n):
    while n > 0:
        yield n
        n -= 1

for num in countdown(5):
    print(num)  # 5, 4, 3, 2, 1
```

**Benefits:**
- **Memory efficient**: Only one value in memory at a time
- **Infinite sequences**: `itertools.count()` never exhausts memory
- **Pipeline composition**: Chain generators for stream processing

Generator expressions: `(x**2 for x in range(10))` — like list comprehension but lazy.


[System] You are Echidna, a helpful AI assistant. Answer accurately with clear markdown formatting when appropriate. Be thorough but concise.

[User] How do Python's `*args` and `**kwargs` work?

[Assistant]
`*args` collects positional arguments into a tuple, `**kwargs` collects keyword arguments into a dict:

```python
def log_event(event_type, *args, **kwargs):
    print(f"[{event_type}]", args, kwargs)

log_event("ERROR", "disk_full", server="web01", usage=98.5)
# [ERROR] ('disk_full',) {'server': 'web01', 'usage': 98.5}
```

Use `*` to unpack: `func(*[1, 2, 3])` → `func(1, 2, 3)`
Use `**` to unpack: `func(**{'a': 1})` → `func(a=1)`


text:
<|im_start|>system
You are Echidna, a helpful AI assistant. Answer accurately with clear markdown formatting when appropriate. Be thorough but concise.<|im_end|>
<|im_start|>user
What is a Python virtual environment?<|im_end|>
<|im_start|>assistant
A **venv** is an isolated Python environment with its own packages:

```bash
python -m venv .venv
source .venv/Scripts/activate  # Windows
pip install fastapi  # Installed ONLY in .venv
```

**Why use:**
- Project A needs Django 4.0, Project B needs Django 3.2
- Avoids polluting system Python
- Reproducible: `pip freeze > requirements.txt`

In SimpleRAG: `.venv/` contains Python 3.12 with project-specific packages.<|im_end|>

[System] You are Echidna, a helpful AI assistant. Answer accurately with clear markdown formatting when appropriate. Be thorough but concise.

[User] What is a Python virtual environment?

[Assistant]
A **venv** is an isolated Python environment with its own packages:

```bash
python -m venv .venv
source .venv/Scripts/activate  # Windows
pip install fastapi  # Installed ONLY in .venv
```

**Why use:**
- Project A needs Django 4.0, Project B needs Django 3.2
- Avoids polluting system Python
- Reproducible: `pip freeze > requirements.txt`

In SimpleRAG: `.venv/` contains Python 3.12 with project-specific packages.


[System] You are Echidna, a helpful AI assistant. Answer accurately with clear markdown formatting when appropriate. Be thorough but concise.

[User] Explain `try/except/else/finally` in Python.

[Assistant]
```python
try:
    result = risky_operation()
except ValueError as e:
    logger.error(f"Bad value: {e}")
    result = default_value
except Exception:
    logger.exception("Unexpected failure")
    raise
else:
    logger.info(f"Success: {result}")  # No exception occurred
finally:
    cleanup_resources()  # Always runs
```

Execution order: try → (except if error) → (else if no error) → finally (always).
`finally` is for cleanup that MUST happen — close files, release locks.


text:
<|im_start|>system
You are Echidna, a helpful AI assistant. Answer accurately with clear markdown formatting when appropriate. Be thorough but concise.<|im_end|>
<|im_start|>user
How do Python type hints work?<|im_end|>
<|im_start|>assistant
Type hints are optional annotations that tools can check:

```python
from typing import Optional, Union

def get_document(doc_id: str) -> Optional[dict]:
    """Returns document dict or None if not found."""
    return db.get(doc_id)

def process(value: Union[int, float]) -> float:
    return float(value) * 1.1
```

**Benefits:**
- IDE autocomplete and error detection
- `mypy` static type checking catches bugs before runtime
- Self-documenting code

**Note**: Types are NOT enforced at runtime (use Pydantic for that). They're documentation that tools can verify.<|im_end|>

[System] You are Echidna, a helpful AI assistant. Answer accurately with clear markdown formatting when appropriate. Be thorough but concise.

[User] How do Python type hints work?

[Assistant]
Type hints are optional annotations that tools can check:

```python
from typing import Optional, Union

def get_document(doc_id: str) -> Optional[dict]:
    """Returns document dict or None if not found."""
    return db.get(doc_id)

def process(value: Union[int, float]) -> float:
    return float(value) * 1.1
```

**Benefits:**
- IDE autocomplete and error detection
- `mypy` static type checking catches bugs before runtime
- Self-documenting code

**Note**: Types are NOT enforced at runtime (use Pydantic for that). They're documentation that tools can verify.


[System] You are Echidna, a helpful AI assistant. Answer accurately with clear markdown formatting when appropriate. Be thorough but concise.

[User] What is the difference between deep and shallow copy?

[Assistant]
```python
import copy

original = [[1, 2], [3, 4]]

# Shallow copy — copies outer list, shares inner lists
shallow = copy.copy(original)
shallow[0][0] = 99  # Also changes original!

# Deep copy — copies everything recursively
deep = copy.deepcopy(original)
deep[0][0] = 42  # Original unchanged
```

Use shallow copy for simple structures (list of ints). Use deep copy for nested structures when you need full independence.


text:
<|im_start|>system
You are Echidna, a helpful AI assistant. Answer accurately with clear markdown formatting when appropriate. Be thorough but concise.<|im_end|>
<|im_start|>user
What is `functools.lru_cache`?<|im_end|>
<|im_start|>assistant
LRU (Least Recently Used) cache memoizes function results:

```python
from functools import lru_cache

@lru_cache(maxsize=128)
def fibonacci(n):
    if n < 2:
        return n
    return fibonacci(n-1) + fibonacci(n-2)

fibonacci(100)  # Fast — each value computed once
```

Adds O(1) lookup for repeated calls with same arguments. Perfect for: recursive functions, expensive computations, API response caching. Works only with hashable arguments.<|im_end|>

[System] You are Echidna, a helpful AI assistant. Answer accurately with clear markdown formatting when appropriate. Be thorough but concise.

[User] What is `functools.lru_cache`?

[Assistant]
LRU (Least Recently Used) cache memoizes function results:

```python
from functools import lru_cache

@lru_cache(maxsize=128)
def fibonacci(n):
    if n < 2:
        return n
    return fibonacci(n-1) + fibonacci(n-2)

fibonacci(100)  # Fast — each value computed once
```

Adds O(1) lookup for repeated calls with same arguments. Perfect for: recursive functions, expensive computations, API response caching. Works only with hashable arguments.


text:
<|im_start|>system
You are Echidna, a helpful AI assistant. Answer accurately with clear markdown formatting when appropriate. Be thorough but concise.<|im_end|>
<|im_start|>user
What is Big O notation?<|im_end|>
<|im_start|>assistant
**Big O notation** describes how algorithm performance scales with input size:

| Notation | Name | Example |
|:---|:---|:---|
| O(1) | Constant | Array access by index |
| O(log n) | Logarithmic | Binary search |
| O(n) | Linear | Linear search |
| O(n log n) | Linearithmic | Merge sort, quicksort avg |
| O(n²) | Quadratic | Bubble sort, nested loops |
| O(2ⁿ) | Exponential | Brute-force subset problems |

Focus on worst-case and how the algorithm behaves at large N. An O(n²) algorithm is fine for 100 items but unusable for 1,000,000.<|im_end|>

[System] You are Echidna, a helpful AI assistant. Answer accurately with clear markdown formatting when appropriate. Be thorough but concise.

[User] What is Big O notation?

[Assistant]
**Big O notation** describes how algorithm performance scales with input size:

| Notation | Name | Example |
|:---|:---|:---|
| O(1) | Constant | Array access by index |
| O(log n) | Logarithmic | Binary search |
| O(n) | Linear | Linear search |
| O(n log n) | Linearithmic | Merge sort, quicksort avg |
| O(n²) | Quadratic | Bubble sort, nested loops |
| O(2ⁿ) | Exponential | Brute-force subset problems |

Focus on worst-case and how the algorithm behaves at large N. An O(n²) algorithm is fine for 100 items but unusable for 1,000,000.


[System] You are Echidna, a helpful AI assistant. Answer accurately with clear markdown formatting when appropriate. Be thorough but concise.

[User] What is the difference between process and thread?

[Assistant]
| Feature | Process | Thread |
|:---|:---|:---|
| Memory | Separate memory space | Shared memory within process |
| Creation | Heavy (OS-level) | Lightweight |
| Communication | IPC (pipes, sockets) | Shared memory |
| Crash impact | Isolated | Can crash entire process |
| Use case | CPU-bound parallelism | I/O concurrency |

Process = separate program instance. Thread = execution unit within a process. Threads share memory (fast communication, risk of races); processes are isolated (safe, harder to share data).


text:
<|im_start|>system
You are Echidna, a helpful AI assistant. Answer accurately with clear markdown formatting when appropriate. Be thorough but concise.<|im_end|>
<|im_start|>user
Explain the OSI model layers briefly.<|im_end|>
<|im_start|>assistant
| Layer | Name | What it handles |
|:---|:---|:---|
| 7 | Application | HTTP, SMTP, DNS |
| 6 | Presentation | Encryption, compression, encoding |
| 5 | Session | Connection management |
| 4 | Transport | TCP/UDP, ports, reliability |
| 3 | Network | IP, routing, addressing |
| 2 | Data Link | MAC addresses, switches, frames |
| 1 | Physical | Cables, radio, bits on wire |

Mnemonic: **A**ll **P**eople **S**eem **T**o **N**eed **D**ata **P**rocessing. Most developers work at layers 7 (HTTP APIs) and 4 (TCP connections).<|im_end|>

[System] You are Echidna, a helpful AI assistant. Answer accurately with clear markdown formatting when appropriate. Be thorough but concise.

[User] Explain the OSI model layers briefly.

[Assistant]
| Layer | Name | What it handles |
|:---|:---|:---|
| 7 | Application | HTTP, SMTP, DNS |
| 6 | Presentation | Encryption, compression, encoding |
| 5 | Session | Connection management |
| 4 | Transport | TCP/UDP, ports, reliability |
| 3 | Network | IP, routing, addressing |
| 2 | Data Link | MAC addresses, switches, frames |
| 1 | Physical | Cables, radio, bits on wire |

Mnemonic: **A**ll **P**eople **S**eem **T**o **N**eed **D**ata **P**rocessing. Most developers work at layers 7 (HTTP APIs) and 4 (TCP connections).


[System] You are Echidna, a helpful AI assistant. Answer accurately with clear markdown formatting when appropriate. Be thorough but concise.

[User] What is REST and what makes an API RESTful?

[Assistant]
**REST** (Representational State Transfer) is an architectural style:

**Key constraints:**
1. **Stateless**: Each request contains all needed information (no server-side sessions)
2. **Resources**: Everything is a resource with a URL (`/users/123`)
3. **HTTP methods**: GET (read), POST (create), PUT (replace), PATCH (partial update), DELETE (remove)
4. **Representations**: Resources returned as JSON, XML, etc.
5. **HATEOAS**: Responses include links to related actions

```
GET    /api/users      → List users
POST   /api/users      → Create user
GET    /api/users/123  → Get user 123
DELETE /api/users/123  → Delete user 123
```

Most APIs are "REST-ish" — they follow resource naming and HTTP methods but skip HATEOAS.


[System] You are Echidna, a helpful AI assistant. Answer accurately with clear markdown formatting when appropriate. Be thorough but concise.

[User] What is the difference between TCP and UDP?

[Assistant]
| Feature | TCP | UDP |
|:---|:---|:---|
| Connection | Connection-oriented | Connectionless |
| Reliability | Guaranteed delivery | Best-effort (may lose packets) |
| Ordering | In-order delivery | No ordering guarantee |
| Speed | Slower (overhead) | Faster (no handshake) |
| Use case | Web, email, file transfer | Streaming, gaming, DNS |

**TCP**: "I need every byte, in order" (loading a webpage).
**UDP**: "I need speed, can tolerate loss" (video call, online game).


[System] You are Echidna, a helpful AI assistant. Answer accurately with clear markdown formatting when appropriate. Be thorough but concise.

[User] What is a database index and why is it important?

[Assistant]
A **database index** is like a book's index — it enables fast lookups without scanning every page:

```sql
-- Without index: scans all rows (slow on large tables)
SELECT * FROM users WHERE email = 'alice@example.com';

-- With index: B-tree lookup, finds result in O(log n)
CREATE INDEX idx_email ON users(email);
```

**Trade-offs:**
- ✅ Faster SELECT queries (especially JOINs and WHERE)
- ❌ Slower INSERT/UPDATE/DELETE (index must be updated)
- ❌ Uses additional storage

Index columns that appear in WHERE, JOIN, and ORDER BY clauses.


text:
<|im_start|>system
You are Echidna, a helpful AI assistant. Answer accurately with clear markdown formatting when appropriate. Be thorough but concise.<|im_end|>
<|im_start|>user
What is CORS and why does it exist?<|im_end|>
<|im_start|>assistant
**CORS** (Cross-Origin Resource Sharing) is a browser security feature:

By default, browsers block JavaScript from making requests to a different origin (domain/port/protocol) than the page came from. CORS headers tell the browser which cross-origin requests are allowed:

```
Access-Control-Allow-Origin: http://localhost:8080
Access-Control-Allow-Methods: GET, POST
```

This prevents malicious sites from making authenticated requests to your bank. If your frontend (port 8080) calls your backend (port 8010), you need CORS configured on the backend.<|im_end|>

[System] You are Echidna, a helpful AI assistant. Answer accurately with clear markdown formatting when appropriate. Be thorough but concise.

[User] What is CORS and why does it exist?

[Assistant]
**CORS** (Cross-Origin Resource Sharing) is a browser security feature:

By default, browsers block JavaScript from making requests to a different origin (domain/port/protocol) than the page came from. CORS headers tell the browser which cross-origin requests are allowed:

```
Access-Control-Allow-Origin: http://localhost:8080
Access-Control-Allow-Methods: GET, POST
```

This prevents malicious sites from making authenticated requests to your bank. If your frontend (port 8080) calls your backend (port 8010), you need CORS configured on the backend.


[System] You are Echidna, a helpful AI assistant. Answer accurately with clear markdown formatting when appropriate. Be thorough but concise.

[User] What is the difference between SQL injection and how to prevent it?

[Assistant]
**SQL injection** happens when user input is concatenated into SQL queries:

```python
# VULNERABLE: user enters: ' OR '1'='1
query = f"SELECT * FROM users WHERE name = '{user_input}'"
# Becomes: SELECT * FROM users WHERE name = '' OR '1'='1'
```

**Prevention:**
1. **Parameterized queries** (ALWAYS):
```python
cursor.execute("SELECT * FROM users WHERE name = ?", (user_input,))
```
2. **ORM** (SQLAlchemy, Django ORM) — auto-parameterizes
3. **Input validation** — reject unexpected characters
4. **Least privilege** — DB user should have minimal permissions


[System] You are Echidna, a helpful AI assistant. Answer accurately with clear markdown formatting when appropriate. Be thorough but concise.

[User] What is a hash function and what makes it cryptographic?

[Assistant]
A **hash function** maps arbitrary data to fixed-size output:

```
SHA256("hello") → 2cf24dba5fb0a30e26e83b2ac5b9e29e1b161e5c1fa7425e73043362938b9824
```

**Properties of cryptographic hashes:**
1. **Deterministic**: Same input → always same output
2. **One-way**: Cannot reverse hash to get original
3. **Avalanche effect**: Tiny input change → completely different hash
4. **Collision-resistant**: Hard to find two inputs with same hash

**Uses**: Password storage (hash + salt), file integrity (checksums), blockchain, Git commit identifiers.

**Not for**: Encryption (hashes can't be decrypted).


[System] You are Echidna, a helpful AI assistant. Answer accurately with clear markdown formatting when appropriate. Be thorough but concise.

[User] What is the difference between AI, ML, and Deep Learning?

[Assistant]
**AI** (Artificial Intelligence): Broad field — machines that simulate human intelligence.

**ML** (Machine Learning): Subset of AI — systems that learn from data without explicit programming.

**Deep Learning**: Subset of ML — uses multi-layer neural networks to learn hierarchical representations.

```
AI ⊃ Machine Learning ⊃ Deep Learning
```

AI includes rule-based systems (chess engines). ML includes random forests, SVMs. Deep learning powers LLMs, image recognition, speech synthesis.


text:
<|im_start|>system
You are Echidna, a helpful AI assistant. Answer accurately with clear markdown formatting when appropriate. Be thorough but concise.<|im_end|>
<|im_start|>user
What is a Transformer model?<|im_end|>
<|im_start|>assistant
The **Transformer** architecture (2017, "Attention Is All You Need") revolutionized NLP:

**Key innovation**: Self-attention mechanism processes all tokens in parallel (not sequentially like RNNs), capturing long-range dependencies.

**Components:**
- **Encoder**: Processes input (used in BERT for understanding)
- **Decoder**: Generates output (used in GPT for generation)
- **Attention**: "Which other tokens are relevant to this token?"

LLMs like GPT, Qwen, and LLaMA are decoder-only Transformers. They predict the next token given previous tokens — that simple objective, scaled up, produces remarkable capabilities.<|im_end|>

[System] You are Echidna, a helpful AI assistant. Answer accurately with clear markdown formatting when appropriate. Be thorough but concise.

[User] What is a Transformer model?

[Assistant]
The **Transformer** architecture (2017, "Attention Is All You Need") revolutionized NLP:

**Key innovation**: Self-attention mechanism processes all tokens in parallel (not sequentially like RNNs), capturing long-range dependencies.

**Components:**
- **Encoder**: Processes input (used in BERT for understanding)
- **Decoder**: Generates output (used in GPT for generation)
- **Attention**: "Which other tokens are relevant to this token?"

LLMs like GPT, Qwen, and LLaMA are decoder-only Transformers. They predict the next token given previous tokens — that simple objective, scaled up, produces remarkable capabilities.


[System] You are Echidna, a helpful AI assistant. Answer accurately with clear markdown formatting when appropriate. Be thorough but concise.

[User] What are embeddings in machine learning?

[Assistant]
**Embeddings** are dense vector representations that capture semantic meaning:

- Similar concepts → vectors close together in space
- Dimensions encode latent features (the model learns what each dimension represents)
- Typically 128-4096 dimensions

```
"king" - "man" + "woman" ≈ "queen"  (word2vec analogy)
```

**In RAG systems**: Documents are embedded, queries are embedded, and cosine similarity finds the closest matches. Embeddings enable semantic search — finding results by meaning, not just keywords.


[System] You are Echidna, a helpful AI assistant. Answer accurately with clear markdown formatting when appropriate. Be thorough but concise.

[User] What is overfitting in machine learning?

[Assistant]
**Overfitting** occurs when a model memorizes training data instead of learning general patterns:

| Behavior | Underfitting | Good Fit | Overfitting |
|:---|:---|:---|:---|
| Train accuracy | Low | High | Very high (~100%) |
| Test accuracy | Low | High | Much lower than train |

**How to detect**: Large gap between training and validation performance.

**Prevention:**
- More training data
- Regularization (L1/L2, dropout)
- Early stopping (halt when validation loss stops improving)
- Cross-validation
- Simpler model architecture


text:
<|im_start|>system
You are Echidna, a helpful AI assistant. Answer accurately with clear markdown formatting when appropriate. Be thorough but concise.<|im_end|>
<|im_start|>user
What is Docker and containerization?<|im_end|>
<|im_start|>assistant
**Docker** packages applications with all dependencies into portable containers:

```dockerfile
FROM python:3.12-slim
WORKDIR /app
COPY requirements.txt .
RUN pip install -r requirements.txt
COPY . .
EXPOSE 8000
CMD ["uvicorn", "main:app", "--host", "0.0.0.0", "--port", "8000"]
```

**Container vs VM**: Containers share the host OS kernel (lightweight, start in seconds). VMs run a full OS (heavier, better isolation).

**Benefits**: Consistent environments, easy scaling, isolation, infrastructure as code.<|im_end|>

[System] You are Echidna, a helpful AI assistant. Answer accurately with clear markdown formatting when appropriate. Be thorough but concise.

[User] What is Docker and containerization?

[Assistant]
**Docker** packages applications with all dependencies into portable containers:

```dockerfile
FROM python:3.12-slim
WORKDIR /app
COPY requirements.txt .
RUN pip install -r requirements.txt
COPY . .
EXPOSE 8000
CMD ["uvicorn", "main:app", "--host", "0.0.0.0", "--port", "8000"]
```

**Container vs VM**: Containers share the host OS kernel (lightweight, start in seconds). VMs run a full OS (heavier, better isolation).

**Benefits**: Consistent environments, easy scaling, isolation, infrastructure as code.


text:
<|im_start|>system
You are Echidna, a helpful AI assistant. Answer accurately with clear markdown formatting when appropriate. Be thorough but concise.<|im_end|>
<|im_start|>user
What does this output? `[x for x in range(10) if x % 3 == 0]`<|im_end|>
<|im_start|>assistant
`[0, 3, 6, 9]` — numbers divisible by 3 from 0-9.<|im_end|>

[System] You are Echidna, a helpful AI assistant. Answer accurately with clear markdown formatting when appropriate. Be thorough but concise.

[User] What does this output? `[x for x in range(10) if x % 3 == 0]`

[Assistant] `[0, 3, 6, 9]` — numbers divisible by 3 from 0-9.


text:
<|im_start|>system
You are Echidna, a helpful AI assistant. Answer accurately with clear markdown formatting when appropriate. Be thorough but concise.<|im_end|>
<|im_start|>user
What does `list(zip([1,2,3], ['a','b','c']))` produce?<|im_end|>
<|im_start|>assistant
`[(1, 'a'), (2, 'b'), (3, 'c')]` — pairs elements by position.<|im_end|>

[System] You are Echidna, a helpful AI assistant. Answer accurately with clear markdown formatting when appropriate. Be thorough but concise.

[User] What does `list(zip([1,2,3], ['a','b','c']))` produce?

[Assistant] `[(1, 'a'), (2, 'b'), (3, 'c')]` — pairs elements by position.


text:
<|im_start|>system
You are Echidna, a helpful AI assistant. Answer accurately with clear markdown formatting when appropriate. Be thorough but concise.<|im_end|>
<|im_start|>user
What will `bool([])` return?<|im_end|>
<|im_start|>assistant
`False` — empty collections are falsy in Python.<|im_end|>

[System] You are Echidna, a helpful AI assistant. Answer accurately with clear markdown formatting when appropriate. Be thorough but concise.

[User] What will `bool([])` return?

[Assistant] `False` — empty collections are falsy in Python.


text:
<|im_start|>system
You are Echidna, a helpful AI assistant. Answer accurately with clear markdown formatting when appropriate. Be thorough but concise.<|im_end|>
<|im_start|>user
What does `'hello'.upper()[::-1]` return?<|im_end|>
<|im_start|>assistant
`'OLLEH'` — uppercase then reverse.<|im_end|>

[System] You are Echidna, a helpful AI assistant. Answer accurately with clear markdown formatting when appropriate. Be thorough but concise.

[User] What does `'hello'.upper()[::-1]` return?

[Assistant] `'OLLEH'` — uppercase then reverse.


text:
<|im_start|>system
You are Echidna, a helpful AI assistant. Answer accurately with clear markdown formatting when appropriate. Be thorough but concise.<|im_end|>
<|im_start|>user
What is `type((1,))` vs `type((1))`?<|im_end|>
<|im_start|>assistant
`<class 'tuple'>` for `(1,)` (trailing comma makes it a tuple). `(1)` without comma is just `int`.<|im_end|>

[System] You are Echidna, a helpful AI assistant. Answer accurately with clear markdown formatting when appropriate. Be thorough but concise.

[User] What is `type((1,))` vs `type((1))`?

[Assistant] `<class 'tuple'>` for `(1,)` (trailing comma makes it a tuple). `(1)` without comma is just `int`.


text:
<|im_start|>system
You are Echidna, a helpful AI assistant. Answer accurately with clear markdown formatting when appropriate. Be thorough but concise.<|im_end|>
<|im_start|>user
What's the output of `{1, 2, 2, 3, 1}`?<|im_end|>
<|im_start|>assistant
`{1, 2, 3}` — sets eliminate duplicates, order is not guaranteed.<|im_end|>

[System] You are Echidna, a helpful AI assistant. Answer accurately with clear markdown formatting when appropriate. Be thorough but concise.

[User] What's the output of `{1, 2, 2, 3, 1}`?

[Assistant] `{1, 2, 3}` — sets eliminate duplicates, order is not guaranteed.


text:
<|im_start|>system
You are Echidna, a helpful AI assistant. Answer accurately with clear markdown formatting when appropriate. Be thorough but concise.<|im_end|>
<|im_start|>user
What does `all([True, 1, 'hello'])` return?<|im_end|>
<|im_start|>assistant
`True` — all values are truthy. `all([True, 0, 'hello'])` would be `False`.<|im_end|>

[System] You are Echidna, a helpful AI assistant. Answer accurately with clear markdown formatting when appropriate. Be thorough but concise.

[User] What does `all([True, 1, 'hello'])` return?

[Assistant] `True` — all values are truthy. `all([True, 0, 'hello'])` would be `False`.


text:
<|im_start|>system
You are Echidna, a helpful AI assistant. Answer accurately with clear markdown formatting when appropriate. Be thorough but concise.<|im_end|>
<|im_start|>user
Explain `enumerate()` with an example.<|im_end|>
<|im_start|>assistant
```python
for i, item in enumerate(['a', 'b', 'c']):
    print(i, item)
# 0 a
# 1 b
# 2 c
```
Returns (index, value) pairs. Add `start=N` to offset the index.<|im_end|>

[System] You are Echidna, a helpful AI assistant. Answer accurately with clear markdown formatting when appropriate. Be thorough but concise.

[User] Explain `enumerate()` with an example.

[Assistant]
```python
for i, item in enumerate(['a', 'b', 'c']):
    print(i, item)
# 0 a
# 1 b
# 2 c
```
Returns (index, value) pairs. Add `start=N` to offset the index.


text:
<|im_start|>system
You are Echidna, a helpful AI assistant. Answer accurately with clear markdown formatting when appropriate. Be thorough but concise.<|im_end|>
<|im_start|>user
What does `isinstance(True, int)` return?<|im_end|>
<|im_start|>assistant
`True` — in Python, `bool` is a subclass of `int`. `True == 1` and `False == 0`.<|im_end|>

[System] You are Echidna, a helpful AI assistant. Answer accurately with clear markdown formatting when appropriate. Be thorough but concise.

[User] What does `isinstance(True, int)` return?

[Assistant] `True` — in Python, `bool` is a subclass of `int`. `True == 1` and `False == 0`.


text:
<|im_start|>system
You are Echidna, a helpful AI assistant. Answer accurately with clear markdown formatting when appropriate. Be thorough but concise.<|im_end|>
<|im_start|>user
What does `dict.fromkeys(['a','b'], 0)` create?<|im_end|>
<|im_start|>assistant
`{'a': 0, 'b': 0}` — creates dict with given keys and default value.<|im_end|>

[System] You are Echidna, a helpful AI assistant. Answer accurately with clear markdown formatting when appropriate. Be thorough but concise.

[User] What does `dict.fromkeys(['a','b'], 0)` create?

[Assistant] `{'a': 0, 'b': 0}` — creates dict with given keys and default value.