Skip to main content

Just a test calculator package

Project description

🧮 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

python -m venv venv
source venv/bin/activate

📦 2. Install Dependencies

pip install -r requirements.txt

▶️ 3. Run the Calculator

Make main.py executable:

chmod +x main.py

Now run:

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

🔬 Running Tests

Make sure you add PYTHONPATH or use conftest.py.

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)

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.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

ark_calculator-0.1.1.tar.gz (2.7 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

ark_calculator-0.1.1-py3-none-any.whl (3.1 kB view details)

Uploaded Python 3

File details

Details for the file ark_calculator-0.1.1.tar.gz.

File metadata

  • Download URL: ark_calculator-0.1.1.tar.gz
  • Upload date:
  • Size: 2.7 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.10.12

File hashes

Hashes for ark_calculator-0.1.1.tar.gz
Algorithm Hash digest
SHA256 25cbf500d029a81d2cb736dbf7178b85bdff68114c8e9963721a18ff2d0542b0
MD5 44825f8bff024e1bb2295e5d3b12949d
BLAKE2b-256 6b879a59406b1c92fa48abc8136c15558a458e0f5ec08ba89ac5432336aee8e6

See more details on using hashes here.

File details

Details for the file ark_calculator-0.1.1-py3-none-any.whl.

File metadata

  • Download URL: ark_calculator-0.1.1-py3-none-any.whl
  • Upload date:
  • Size: 3.1 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.10.12

File hashes

Hashes for ark_calculator-0.1.1-py3-none-any.whl
Algorithm Hash digest
SHA256 3cb229bf972f4512e07893f29693cd9b02f1f75eb5507c9c22ee032ba4d9d7f5
MD5 3364cb4b28bc22652bba941d06b8e876
BLAKE2b-256 ff9da997f75894982967e5996047bc081780cefc18089e3ef97090dbdfac55ba

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page