Skip to content
/ scicalc Public

A scientific calculator for terminal emulators. Contains several scientific and statistic methods.

Notifications You must be signed in to change notification settings

xyzpw/scicalc

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

37 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

calculator.py

GitHub Downloads (all assets, all releases)

A scientific calculator for your terminal emulator.

calculator_py-preview

Installing Dependancies

Some modules will need to be installed for this application to work properly. See the codeblock below for an example on installing dependencies.

# install dependencies
$ pip3 install -U -r requirements.txt

# run calculator.py
$ python3 calculator.py

Features

The calculator.py script contains several features, the showhelp function is useful because it displays usage info about a given function.

To use the showhelp function, type showhelp() inside the script. Optionally, you can display specific info about a given function by passing the function name in as an argument, e.g. showhelp(log), this will display usage information about the log function.

Note

The round function uses Bankers rounding. Python uses this rounding method by default, so this is used to avoid confusion. If you want to round 5 up, use the round5up function, this is the most common rounding method.**

Viewing History

History can be displayed with the hist command. Alternatively, the command history will do the same.
Optionally, you can view the last n equations, or even a range between two specified points in your history.

Optional History Arguments

Viewing the last n equations in your history.

hist n

Viewing the history range from the xth to nth point in history.

hist xth nth

note: history is displayed from oldest to latest

Previous Answer

The ans variable is equivalent to your previous expressions answer, therefor you do not have to type in your previous expression.

π = 3.141592653589793
ans == π = true

Constants

You can view the list of built-in constants with the const command. This will display the following output:

c = Speed of light 299,792,458 m/s
g = Standard gravity 9.80665 m/s²
G = Gravitational constant 6.6743e-11 N·m²·kg⁻²
h = Planck constant 6.62607015e-34 J·Hz⁻¹
kb = Boltzmann constant 1.380649e-23 J·K⁻¹
phi = Golden ratio 1.618033988749895
NA = Avogadro constant 6.02214076e+23 mol⁻¹
ke = Coulomb constant 8987551792.3 N·m²·C⁻²
e0 = Electric constant 8.8541878128e-12 F·m⁻¹
R = Gas constant 8.31446261815324 J·K⁻¹·mol⁻¹

Functions

Examples for several, but not all functions.

Mathematical

root(4, 16)
# output: 2
log(9, 81)
# output: 2

Imaginary Numbers

sqrt(-1)
# output: i

Statistics

binomial(0.25, 5, 2)
# output: 0.263671875
uncertainty([3, 19, 20, 5])
# output: 8.5

Converting Units

temperature(68, 'f', 'c')
# output: 20
volume(1, 'gal', 'c')
# output: 16

Contributing

Pull requests are unlikely to be merged, but fixes such as typos or grammar/spelling mistakes are more likely to be merged.

Bug Reports

Bugs can be reported via creating a new issue.