Skip to main content

🧮 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.

Metadata

Release files for ark-calculator 0.1.1

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for ark-calculator 0.1.1
File Size Uploaded Provenance
ark_calculator-0.1.1.tar.gz 2.7 kB Without provenance Details

Built distribution (wheel)

Table of built distributions (wheels) for ark-calculator 0.1.1
File Interpreter ABI Platform
ark_calculator-0.1.1-py3-none-any.whl Python 3 none any Details

Total release size: 5.8 kB

Release files / ark_calculator-0.1.1.tar.gz

Download URL ark_calculator-0.1.1.tar.gz
Size 2.7 kB
Tags Source
SHA-256 checksum
How to use checksums
25cbf500d029a81d2cb736dbf7178b85bdff68114c8e9963721a18ff2d0542b0
BLAKE2b-256 checksum
How to use checksums
6b879a59406b1c92fa48abc8136c15558a458e0f5ec08ba89ac5432336aee8e6
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.1.0 CPython/3.10.12

Release files / ark_calculator-0.1.1-py3-none-any.whl

Download URL ark_calculator-0.1.1-py3-none-any.whl
Size 3.1 kB
Tags Python 3
SHA-256 checksum
How to use checksums
3cb229bf972f4512e07893f29693cd9b02f1f75eb5507c9c22ee032ba4d9d7f5
BLAKE2b-256 checksum
How to use checksums
ff9da997f75894982967e5996047bc081780cefc18089e3ef97090dbdfac55ba
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.1.0 CPython/3.10.12

Security for ark-calculator 0.1.1

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

No provenance found

None of the files in this release were uploaded with provenance metadata.

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

Release history Release notifications | RSS feed

This release

0.1.1 This release

2 release files No provenance

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page