Open In App

SciPy - Constants

Last Updated : 05 Jul, 2025
Summarize
Comments
Improve
Suggest changes
Share
Like Article
Like
Report

In scientific and mathematical calculations, universal constants such as π (pi) or the gravitational constant G are frequently needed. Whether it's determining the area of a circle or calculating gravitational force, having reliable constants readily available helps streamline the process.

Scipy.constants module in SciPy allows users to access collection of mathematical, physical and unit conversion constants effortlessly with a single line of code.

Accessing Constants

Constants can be accessed using the format:

scipy.constants.CONSTANT_NAME

Below listed constants are commonly used:

Python
import scipy.constants as const

print("Pi:", const.pi)
print("Golden ratio:", const.golden_ratio)
print("Speed of light:", const.c)
print("Gravitational constant:", const.G)
print("Gas constant (R):", const.R)
print("Boltzmann constant:", const.k)
print("Proton mass:", const.proton_mass)

Output

accessConstants_output
Accessing Constants Output

Finding Constants

Use the find() method to search for constants by keyword.

Python
import scipy
res = scipy.constants.find("electron")
print(res, end='\n')

Output

findConstant_output
Finding Constants Output

Physical Constants: Value, Unit and Uncertainty

Not only the value but also the corresponding unit and the degree of uncertainty of a physical constant can be retrieved using physical_constants dictionary from scipy.constants.

scipy.constants.physical_constants['name']

Python
import scipy.constants as const
# This return a tuple(vslue, unit, uncertainty)
print(const.physical_constants['alpha particle mass'])

Output

(6.644657345e-27, 'kg', 2.1e-36)

Example: Sample Use Cases

Python
import scipy.constants as const

# Area of a circle using pi
def area_of_circle(r):
    return const.pi * r * r

# Gravitational force
def force_gravity(M, m, dist):
    return (const.G * M * m) / (dist ** 2)

print("Area of Circle:", area_of_circle(5))
print("Gravitational Force:", force_gravity(10, 5, 1))

Output

UseCase_Constants
Sample Use Case Output

Commonly Used Constants in SciPy

ConstantsDescription
pi

Mathematical constant π

golden_ratio

Golden ratio

c or speed_of_lightSpeed of light in vacuum
GGravitational constant
EElementary charge
R

Molar gas constant

alphaFine-structure constant
N_AAvogadro constant
kBoltzmann constant
sigmaStefan-Boltzmann constant σ
m_eElectron mass
m_pProton mass
m_nNeutron Mass
h or PlanckPlanck Constant

Unit Conversion Constants

Mass Units:

UnitDescription
gramOne gram in kilograms.
grainOne grain in kilograms.
poundOne Pound in kilograms.
ounceOne Ounce in kilograms.
automic_massAtomics mass constant in kilograms.

Time Units:

UnitDescription
minuteOne minute in seconds.
hourOne hour in seconds.
dayOne day in seconds.
yearOne year in seconds.

Length Units:

UnitsDescription
inchOne inch in meters.
footOne foot in meters.
yardOne yard in meters.
ptOne point in meters.
micronOne Micron in meters.

Pressure Units:

UnitsDescription
atm/atmosphereThe standard atmosphere in pascals.
barOne bar in Pascals.
torrOne torr(mmHg) in pascals.

Area Units:

UnitsDescription
hectareOne hectare in square meters.
acreOne acre in square meters.

Speed Units:

UnitsDescription
kmhKilometer per hour in meter per second.
mphMiles per hour in meter per second.
machOne Match in meter per second.

Related Articles:


Article Tags :
Practice Tags :

Similar Reads