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 "10*(5-2)^2 / 3"

Output: 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

  • Supported operators: +, -, *, /, (, ), ^
  • 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.6.tar.gz (4.5 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.6-py3-none-any.whl (5.6 kB view details)

Uploaded Python 3

File details

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

File metadata

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

File hashes

Hashes for math_evaluate-0.1.6.tar.gz
Algorithm Hash digest
SHA256 73cf3744035bf35a8413e0776bb169dcc38e7968bad36fd466b66cac2c2a7e38
MD5 c1e7b44f953385ab85ee136a9aefa15f
BLAKE2b-256 755f4a8f4d8b9fa7f6379fd8ccd130183e8df1daf4361e37d3bcd6f72a62a667

See more details on using hashes here.

File details

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

File metadata

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

File hashes

Hashes for math_evaluate-0.1.6-py3-none-any.whl
Algorithm Hash digest
SHA256 fc7d5f7254320a138e0bd99d95d36f82001be5a5a9d4d8555293ec5bfba0c817
MD5 d882c8a4516b6016f2f5c42c223db02b
BLAKE2b-256 6c391761dd63966be184e4eebb917c0c317e74eb4051a9c65c9f43d2ec210699

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