Skip to main content

A command-line calculator tool that can perform basic arithmetic operations

Project description

HLCalculator

A powerful command-line calculator that supports basic arithmetic, scientific operations, and mathematical constants. The package also provides reusable modules for mathematical operations and data models.

Components

  • CLI Tool: Command-line calculator interface (hlcal)
  • Models: Data structures and business logic (models package)
  • Utilities: Common mathematical and string operations (utils package)

Features

  • Basic arithmetic operations:

    • Addition (+)
    • Subtraction (-)
    • Multiplication (*)
    • Division (/)
    • Power (^)
  • Scientific operations:

    • Square root (sqrt)
    • Logarithm (log)
    • Trigonometric functions (sin, cos, tan)
    • Factorial
  • Mathematical constants:

    • π (pi)
    • e
    • τ (tau)

Installation

Using pip:

pip install hlcalculator

Using Poetry:

poetry add hlcalculator

Usage

The calculator provides two main commands:

  • hlcal calc: For calculations
  • hlcal const: For mathematical constants

Basic Operations

hlcal calc 5 + 3         # Addition: 8.0
hlcal calc 10 - 4        # Subtraction: 6.0
hlcal calc 3 '*' 4       # Multiplication: 12.0 (use quotes for *)
hlcal calc 15 / 3        # Division: 5.0
hlcal calc 2 ^ 3         # Power: 8.0

Scientific Operations

hlcal calc 16 sqrt       # Square root: 4.0
hlcal calc 100 log 10    # Log base 10: 2.0
hlcal calc 0.5 sin       # Sine (in radians): 0.479
hlcal calc 5 factorial   # Factorial: 120.0

Mathematical Constants

hlcal const pi           # π: 3.141592653589793
hlcal const e            # e: 2.718281828459045
hlcal const tau          # τ: 6.283185307179586

Library Usage

In addition to the CLI tool, you can use HLCalculator's modules in your Python code:

# Using utility functions
from utils.math_utils import calculate_factorial
from utils.string_utils import format_number

result = calculate_factorial(5)
formatted = format_number(result)

# Using models
from models.product import Product
from models.user import User

# Your business logic here

Development

Project Structure

hlcalculator/     # CLI tool implementation
  ├── __init__.py
  ├── cli.py      # Command line interface
  ├── calculator.py
  └── parser.py
  
models/           # Data models
  ├── __init__.py
  ├── product.py
  └── user.py
  
utils/            # Utility functions
  ├── __init__.py
  ├── math_utils.py
  └── string_utils.py

Requirements

  • Python 3.12 or higher
  • Poetry for dependency management

Setup Development Environment

  1. Clone the repository
git clone https://github.com/hailv/hlcalculator.git
cd hlcalculator
  1. Install dependencies
poetry install
  1. Activate virtual environment
poetry shell

Code Quality Tools

The project uses several code quality tools:

  • black: Code formatting
  • flake8: Style guide enforcement
  • mypy: Static type checking
  • isort: Import sorting

Run all code quality checks:

poetry run black .
poetry run flake8 .
poetry run mypy .
poetry run isort .

License

This project is licensed under the MIT License - see the LICENSE file for details.

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

hlcalculator-0.1.2.tar.gz (7.5 kB view details)

Uploaded Source

Built Distribution

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

hlcalculator-0.1.2-py3-none-any.whl (9.3 kB view details)

Uploaded Python 3

File details

Details for the file hlcalculator-0.1.2.tar.gz.

File metadata

  • Download URL: hlcalculator-0.1.2.tar.gz
  • Upload date:
  • Size: 7.5 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: poetry/1.8.5 CPython/3.12.9 Darwin/24.4.0

File hashes

Hashes for hlcalculator-0.1.2.tar.gz
Algorithm Hash digest
SHA256 6621cafe99cc21645b229d4977ecd6db9f6c3875a9354c2c7db260747c56c0c5
MD5 879e57a71b5cdc9157ae491bb04fa21e
BLAKE2b-256 4aea9e360f52490216d4243ca9fe358c37ace18ed602c0b9a2dad6e5ebc3d204

See more details on using hashes here.

File details

Details for the file hlcalculator-0.1.2-py3-none-any.whl.

File metadata

  • Download URL: hlcalculator-0.1.2-py3-none-any.whl
  • Upload date:
  • Size: 9.3 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: poetry/1.8.5 CPython/3.12.9 Darwin/24.4.0

File hashes

Hashes for hlcalculator-0.1.2-py3-none-any.whl
Algorithm Hash digest
SHA256 c85c8702bd02967393e864504d4237e503d0f66eea3617f4d47668f6f2240f6f
MD5 bd45c755aca7b1c16f5bc57706465826
BLAKE2b-256 eb6a8574a067a682539a677219d1e1509544f5246a675bdf09e90dfa8fced30a

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