Skip to main content

What is simplecalc?

A simple calculator, able to parse quite complex expressions:

>>> from simplecalc import calc
>>> calc("2 + 3.5")
'5.5'
>>> calc("2 * log(100)")
'4'
>>> calc("sin(pi / 2)")
'1'
>>> calc("3 * 5!")
'360'
>>> calc("3 * 5! + ceil(sqrt(123) / ln(10))")
'368'
>>> calc("3**e  * 5! + ceil(sqrt(123) * ln(10))")
'2394.55888943'

Note that these expressions are NOT evaluated by eval() or anything like that, so it should be safe to get the expressions from untrusted sources. Use at your own risk, of course.

It can also be used as a script:

$ simplecalc "3 * cos(pi)"
-3

Project’s history

Code here comes from other internal Canonical’s project, this part was opensourced in 2018:

https://launchpad.net/simple-calc

I forked that to bring it to GitHub, migrate it to Python 3, shape it more like a project (have a setup.py, etc.), and do some releases.

Download files

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

Source Distribution

pysimplecalc-1.tar.gz (8.7 kB view details)

Uploaded Source

File details

Details for the file pysimplecalc-1.tar.gz.

File metadata

  • Download URL: pysimplecalc-1.tar.gz
  • Upload date:
  • Size: 8.7 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.1.1 pkginfo/1.5.0.1 requests/2.23.0 setuptools/39.0.1 requests-toolbelt/0.9.1 tqdm/4.43.0 CPython/3.6.9

File hashes

Hashes for pysimplecalc-1.tar.gz
Algorithm Hash digest
SHA256 f711689a6c0aaec1f6c0254bd627e8ecdc52176e34e9fe80adab7f159d07dd6d
MD5 1eaa7b9db66df582f4e4a8788b574be9
BLAKE2b-256 045dd6ffc42352b38075ce718c40be6ec8550942a3d9539c61be55c286156ee4

See more details on using hashes here.

Release history Release notifications | RSS feed

This release

1 This release

1 file

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