Skip to main content

A simple CLI calculator for quick math.

Project description

Mathematical Expression Evaluator (math-evaluate)

By mhasanali2010

PyPI project link

https://pypi.org/project/math-evaluate

About the project

A simple command-line calculator for quick math without leaving the terminal.

Installation

Install using:

pip install math-evaluate

Usage

Example usage:

math --eval "10*(5-2)^2 / 3"

Output: RESULT: 30

Testing

  • Unittests have been included in ./tests.py
  • Running tests:
    1. Clone the repository:
      git clone https://github.com/mhasanali2010/math-evaluate
      
    2. Navigate to the repository:
      cd math-evaluate
      
    3. Run the tests:
      python tests.py
      

Notes

  • This evaluator follows BODMAS/PEMDAS.
  • Division and multiplication are evaluated left to right, same for addition and subtraction.
  • Exponent associativity is supported.
  • Use brackets () if you want to force evaluation order.
  • Requires Python 3.10 or later.
  • Argument Parsing might glitch when using zsh if you try to evaluate an expression which contains -(.
    • If this happens then run the script using:
      math --eval="<expression>"
      
  • The CLI command is installed as math.

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

math_evaluate-0.1.1.tar.gz (4.2 kB view details)

Uploaded Source

Built Distribution

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

math_evaluate-0.1.1-py3-none-any.whl (5.0 kB view details)

Uploaded Python 3

File details

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

File metadata

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

File hashes

Hashes for math_evaluate-0.1.1.tar.gz
Algorithm Hash digest
SHA256 a9915af1bc2c1451d66a973fb52b0c7047ab3c551b3da5b1f4048d04e1164297
MD5 090f28f9f8d38df0bbe7a2efa0eb15df
BLAKE2b-256 cf818ffa82d97f8f06873644792c0d8bf8702f799d0de579494cb10cbe7efeb6

See more details on using hashes here.

File details

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

File metadata

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

File hashes

Hashes for math_evaluate-0.1.1-py3-none-any.whl
Algorithm Hash digest
SHA256 4ce2bb9e51223a7ec58746f97ebdf529125230424445c0c62e9fea1a21dd3aba
MD5 c6f78d6000c63a4d1f7a6d9dca027e4f
BLAKE2b-256 9e518a6fb5564c68f29fc6c8b2244c5ad39a3459f50f59f47ffa257df004e5a4

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