Introduction of Python Constants in SciPy

Python Constant SciPy – Before moving ahead, let’s know about Python SciPy Intro.

### Constant SciPy

Since SciPy tends to be more driven by implementations of science. It provides a variety of included scientific constants.

These constants are useful in the context of Data Science.

PI is one of the examples of scientific constant.

Example – Print the constant value of PI.

```				```
from scipy import constants

print(constants.pi)

```
```

### Constant Units

Use dir() function to see the list of all units under constant module.

Example – Printing list of all units under constant.

```				```
from scipy import constants

print(dir(constants))

```
```

### Unit Categories

The units are placed under these categories:

 Metric Binary Mass Angle Time Length Pressure Volume Speed Temperature Energy Power Force

### Metric (SI) Prefixes

Returns the specified unit in meter (e.g. deka returns 10.0)

Example –

```				```
from scipy import constants

print(constants.yotta)
print(constants.zetta)
print(constants.exa)
print(constants.peta)
print(constants.tera)
print(constants.giga)
print(constants.mega)
print(constants.kilo)
print(constants.hecto)
print(constants.deka)
print(constants.deci)
print(constants.centi)
print(constants.milli)
print(constants.micro)
print(constants.nano)
print(constants.pico)
print(constants.femto)
print(constants.atto)
print(constants.zepto)

```
```

### Binary Prefixes

Returns the specified unit in bytes (e.g. gibi returns 1073741824)

Example –

```				```
from scipy import constants

print(constants.kibi)
print(constants.mebi)
print(constants.gibi)
print(constants.tebi)
print(constants.pebi)
print(constants.exbi)
print(constants.zebi)
print(constants.yobi)

```
```

### Mass

Return the specified unit in kg (e.g. carat returns 0.001)

Example –

```				```
from scipy import constants

print(constants.gram)
print(constants.metric_ton)
print(constants.grain)
print(constants.lb)
print(constants.pound)
print(constants.oz)
print(constants.ounce)
print(constants.stone)
print(constants.long_ton)
print(constants.short_ton)
print(constants.troy_ounce)
print(constants.troy_pound)
print(constants.carat)
print(constants.atomic_mass)
print(constants.m_u)
print(constants.u)

```
```

### Angle

Returns the specified unit in radians (e.g. arcsec returns 4.84813681109536e-06)

Example –

```				```
from scipy import constants

print(constants.degree)
print(constants.arcmin)
print(constants.arcminute)
print(constants.arcsec)
print(constants.arcsecond)

```
```

### Time

Returns the specified unit in seconds (e.g. minute returns 60.0)

Example –

```				```
from scipy import constants

print(constants.minute)
print(constants.hour)
print(constants.day)
print(constants.week)
print(constants.year)
print(constants.Julian_year)

```
```

### Length

Return the specified unit in meters (e.g. fermi returns 1e-15)

Example –

```				```
from scipy import constants

print(constants.inch)
print(constants.foot)
print(constants.yard)
print(constants.mile)
print(constants.mil)
print(constants.pt)
print(constants.point)
print(constants.survey_foot)
print(constants.survey_mile)
print(constants.nautical_mile)
print(constants.fermi)
print(constants.angstrom)
print(constants.micron)
print(constants.au)
print(constants.astronomical_unit)
print(constants.light_year)
print(constants.parsec)

```
```

### Pressure

Return the specified unit in pascals (e.g. bar returns 100000.0)

Example –

```				```
from scipy import constants

print(constants.atm)
print(constants.atmosphere)
print(constants.bar)
print(constants.torr)
print(constants.mmHg)
print(constants.psi)

```
```

### Area

Returns the specified unit in square meters(e.g. acre returns 4046.8564223999992)

Example –

```				```
from scipy import constants

print(constants.hectare)
print(constants.acre)

```
```

### Volume

Returns the specified unit in cubic meters (e.g. gallon_imp returns 0.00454609)

Example –

```				```
from scipy import constants

print(constants.liter)
print(constants.litre)
print(constants.gallon)
print(constants.gallon_US)
print(constants.gallon_imp)
print(constants.fluid_ounce)
print(constants.fluid_ounce_US)
print(constants.fluid_ounce_imp)
print(constants.barrel)
print(constants.bbl)

```
```

### Speed

Returns the specified unit in meters per second (e.g. kmh returns 0.2777777777777778)

Example –

```				```
from scipy import constants

print(constants.kmh)
print(constants.mph)
print(constants.mach)
print(constants.speed_of_sound)
print(constants.knot)

```
```

### Temperature

Returns the specified unit in Kelvin (e.g. degree_Fahrenheit returns 0.5555555555555556)

Example –

```				```
from scipy import constants

print(constants.zero_Celsius)
print(constants.degree_Fahrenheit)
```
```

### Energy

Returns the specified unit in joules (e.g. erg returns 1e-07)

Example –

```				```
from scipy import constants

print(constants.eV)
print(constants.electron_volt)
print(constants.calorie)
print(constants.calorie_th)
print(constants.calorie_IT)
print(constants.erg)
print(constants.Btu)
print(constants.Btu_IT)
print(constants.Btu_th)
print(constants.ton_TNT)

```
```

### Power

Returns the specified unit in watts (e.g. hp returns 745.6998715822701)

Example –

```				```
from scipy import constants

print(constants.hp)
print(constants.horsepower)

```
```

### Force

Return the specified unit in newton (e.g. dyne returns 1e-05)

Example –

```				```
from scipy import constants

print(constants.dyn)
print(constants.dyne)
print(constants.lbf)
print(constants.pound_force)
print(constants.kgf)
print(constants.kilogram_force)

```
```

If you find anything incorrect in the above-discussed topic and have any further questions, please comment below.

Like us on

Share on