calcalc: a toy calculator
This is a calculator for evaluating string expressions (e.g. '2*sin(3/5)', 'mass of the sun in kg'). The statement can be computed either locally or through querying WolframAlpha.
To install using pip: pip install calcalc-toy. To install via GitHub: https://github.com/yanglyu902/UCB-AY250-HW/tree/main/hw_3/my_package.
There are two ways to interact with the package:
Usage 1: from command line
Examples (inside the CalCalc folder):
This command evaluate a simple expression locally with the -s argument:
$ python CalCalc.py -s '2*sin(3)'
0.2822400161197344
This command calculates the mass of the moon through Wolfram with the -w argument. The result is displayed as a plain text:
$ python CalCalc.py -w 'mass of the moon in kg'
7.3459×10^22 kg (kilograms)
If we want to display a float instead, use the --float flag:
$ python CalCalc.py -w 'mass of the moon in kg' --float
7.3459e+22
Usage 2: inside python script/ipython
After pip install, import the calculator like this:
from calcalc.CalCalc import calculate
We can evaluate a simple expression locally:
In [1]: calculate('2*sin(3/5)+log(7)')
Out[2]: 3.075195095845384
We can evalute a Wolfram query using local=False:
In [1]: calculate('mass of the moon in kg', local=False)
Out[2]: 7.3459e+22
The default Wolfram output using python script/ipython is converted float to facilitate further computations (opposite to the command line behavior described above). To display a string instead, use return_float=False:
In [1]: calculate('mass of the moon in kg', local=False, return_float=False)
Out[2]: '7.3459×10^22 kg (kilograms)'
Metadata
Release files for calcalc-toy 1.8
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | Actions |
|---|---|---|---|---|
| calcalc-toy-1.8.tar.gz | 8.7 kB | Without provenance | Details for calcalc-toy-1.8.tar.gz |
Release files / calcalc-toy-1.8.tar.gz
| Download URL | calcalc-toy-1.8.tar.gz |
|---|---|
| Size | 8.7 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
716a6171856cdede3401168949243735bc22cf5ea3cb5acfd449273eead3ef9f
|
|
BLAKE2b-256 checksum How to use checksums |
ecd7a8c022b47d009b1d12c8bed1ebfa523d0da1c2a2943e11cbc1c0187aef18
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/3.8.0 pkginfo/1.8.2 readme-renderer/32.0 requests/2.27.1 requests-toolbelt/0.9.1 urllib3/1.26.8 tqdm/4.32.2 importlib-metadata/4.11.0 keyring/23.5.0 rfc3986/2.0.0 colorama/0.4.4 CPython/3.7.1
|
Security for calcalc-toy 1.8
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.