# 🧮 Calculator Package (Sample Python Project)

This is a **sample project for creating a package in Python**. It demonstrates how to structure a simple Python project, add CLI support, write tests with `pytest`, and run it like a command-line tool.

---

## 📁 Project Structure

```
calculator_package/
│
├── calculator/               # Package source code
│   ├── __init__.py
│   ├── core.py               # Calculator logic
│   └── cli.py                # CLI interface
│
├── tests/                    # Unit tests
│   ├── __init__.py
│   ├── test_core.py
│   └── conftest.py           # Adds package to PYTHONPATH for tests
│
├── main.py                   # Entry point (CLI executable)
├── pyproject.toml
├── requirements.txt
├── setup.py
└── README.md
```

---

## 🚀 Usage

### 🧪 1. Setup Virtual Environment

```bash
python -m venv venv
source venv/bin/activate
```

### 📦 2. Install Dependencies

```bash
pip install -r requirements.txt
```

### ▶️ 3. Run the Calculator

Make `main.py` executable:

```bash
chmod +x main.py
```

Now run:

```bash
./main.py add 2 3
# Output: Result: 5.0
```

---

## 🔬 Running Tests

Make sure you add `PYTHONPATH` or use `conftest.py`.

```bash
pytest
```

---

## 🛠 Calculator Functions

- `add(a, b)`
- `subtract(a, b)`
- `multiply(a, b)`
- `divide(a, b)` → raises error on divide by zero

---

## 🎁 Optional: Install as a Package (Editable Mode)

```bash
pip install -e .
```

Now you can use it anywhere in the virtual environment.

---

## ✅ License

MIT License

---

## 🧪 Educational Purpose

This project is designed for **learning and testing** how to properly create and structure a Python package with CLI and tests.
