The scipy.constants package contains several commonly used constants in the scientific computations. A few of them are listed below:

Constant Description
pi pi
golden Golden ratio

To use a constant in your Python code, you would use the following syntax:

import scipy
from scipy import constants
print ('The value of constant pi equals', constants.pi)
print ('The value of constant golden ratio equals', constants.pi)

The above code gives following output on the console:

The value of constant pi equals 3.141592653589793
The value of constant golden ratio equals 1.618033988749895

Physical Constants :

The scipy.constant package provides the number of physical constants. The most commonly used physical constants are the following:

Physical Constants Description
c Speed of light in vacuum
G Standard acceleration of gravity
E Elementary discharge
R Molar gas constant
Alpha Fine structure constant
N_A Avogadro constant
K Boltzmann constant
sigma Stefan-Boltzmann constant σ
m_e Electron mass
m_p Proton mass
m_n Neutron mass
H Planck constant

It is a bit difficult to remember all these constants. But SciPy helps us to find any constant using its find function, Syntax for the same is scipy.constants.find(). We have to pass a string as parameter and the function will return a list of physical constant keys containing our passed string,

For example:

import scipy.constants
res = scipy.constants.find('boltzmann')

['Boltzmann constant', 'Boltzmann constant in Hz/K', 'Boltzmann constant in eV/K', 'Boltzmann constant in inverse meter per kelvin', 'Stefan-Boltzmann constant']




This syntax is used for finding the unit of a constant.


from scipy import constants
Res = constants.unit(‘proton mass’)

The above code gives following output on the console:

Units Value
milli o.oo1
micro 1e - 06
Kilo 1000

Above table has the list of SI units These units range from yotta , zetta , exa , peta , tera to Kilo , hector , nano, pico then zepto .

Other important Constants :

Units Value
Gram One gram in Kilogram
Grain One grain in Kilogram
Pound One pound in Kilogram
Ounce One ounce in Kilogram
atomic_mass Atomic mass constant in Kilogram
minute One minute in seconds
Hour One hour in seconds
day One day in a seconds
year One year in seconds
inch One inch in meters
micron One micron in meters
Foot One foot in meters
Yard One yard in meters
pt One point in meters
Light year One light year in a meters
atm Standard atmosphere in pascals
Bar One bar in pascalsn
Torr One torr in pascals
acre One acre in square meters
Hectare One hectare in square meters
liter One liter in cubic meters
gallon One gallon in cubic meters
kmh Kilometers per hour in meters per seconds
mph Miles per hour in meters per seconds
Degree fahrenheit One fahrenheit in kelvins
eV One electron volt in joules
hp One horse power in watts
dyn One dyne in newtons
Degree Degree in radians

To use a above constant in your Python code, you would use the following syntax:

import scipy
from scipy import constants
print ('The value of an hour in seconds', constants.hour)
print ('The value of gram in Kilogram', constants.gram)
print ('The value of inch in meter', constants.inch)

The value of an hour in seconds 3600.0
The value of gram in Kilogram 0.001
The value of inch in meter 0.0254

Likewise you can find values of all constants using this syntax.

The complete list of constants can be found in the SciPy documentation.

Index | previous | Next