Syntax:
`scipy.constants`

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
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')
print(res)
``````

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

## Units:

Syntax:

``````scipy.constants.unit
``````

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

Example:

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

The above code gives following output on the console:
`Kg`

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
Mass
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
Time
minute One minute in seconds
Hour One hour in seconds
day One day in a seconds
year One year in seconds
Length
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
Pressure
atm Standard atmosphere in pascals
Bar One bar in pascalsn
Torr One torr in pascals
Area
acre One acre in square meters
Hectare One hectare in square meters
Volume
liter One liter in cubic meters
gallon One gallon in cubic meters
Speed
kmh Kilometers per hour in meters per seconds
mph Miles per hour in meters per seconds
Temperature
Degree fahrenheit One fahrenheit in kelvins
Energy
eV One electron volt in joules
Power
hp One horse power in watts
Force
dyn One dyne in newtons
Angle

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)
``````

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