Constants & Basic Utilities
scipy.constants ships with a long list of physical constants — already looked up and typed correctly, so you never have to hunt down the exact value of the speed of light or Avogadro's number yourself.
Physical constants
Each constant is just an attribute on the module, holding a plain float:
from scipy import constants print(constants.c) # speed of light, m/s print(constants.g) # standard gravity, m/s^2 print(constants.Avogadro) # Avogadro's number, per mole
299792458.0 9.80665 6.02214076e+23
Beyond the famous ones, scipy.constants also has a searchable dictionary of hundreds more — masses of specific particles, conversion factors, and so on — accessible through constants.physical_constants, though the handful of named attributes like the ones above cover most everyday needs.
constants.g is meters per second squared, not some other gravity unit. Mixing units without converting first is the single easiest way to get a wrong answer here.Unit prefixes
SciPy also provides the standard metric prefixes as plain multipliers, useful for converting into or out of SI units without hardcoding magic numbers:
from scipy import constants distance_km = 5 distance_m = distance_km * constants.kilo print(distance_m)
5000.0
constants.kilo is simply 1000.0 — multiplying by it converts kilometers to meters, the same way constants.milli (0.001) or constants.micro would convert other prefixed units. It's a small thing, but it makes the conversion read clearly at the call site instead of leaving a bare 1000 for someone else to puzzle over later.
Temperature conversion
Temperature doesn't fit the simple multiply-by-a-constant pattern, since the Celsius, Fahrenheit, and Kelvin scales all have different zero points — so SciPy gives it a dedicated function instead:
from scipy import constants print(constants.convert_temperature(100, 'Celsius', 'Fahrenheit')) print(constants.convert_temperature(100, 'Celsius', 'Kelvin'))
212.0 373.15
convert_temperature takes a value and two scale names, and handles each scale's offset correctly — 100°C really is both 212°F and 373.15 K, boiling point on all three scales.