Chapter 4: SciPy Constants

What actually is scipy.constants? (plain English version)

It’s a module inside SciPy that gives you:

  • A huge collection of well-known physical constants (speed of light, Planck’s constant, electron mass, etc.)
  • Important mathematical constants (π, golden ratio)
  • A bunch of conversion factors & units (eV to Joules, Celsius to Kelvin, atm to Pa, light-year in meters, etc.)
  • All values are in SI units by default (except where it makes no sense, like angles in degrees)
  • Values come from the official CODATA recommendations — currently (SciPy 1.17.x in 2026) based on CODATA 2022

Why is this helpful? Because instead of writing

Python

…you just do

Python

→ No typos, no version confusion, everyone in your team/lab uses exactly the same value.

Two main ways to use it

Way 1: Direct attributes (fastest & cleanest for common constants)

Many frequently used constants are available as attributes (top-level variables):

Python

Also handy short aliases: const.golden, const.degree, const.minute, const.hour, const.day, const.year, const.atm, const.bar, const.eV, const.calorie, etc.

Way 2: The full dictionary physical_constants (when you need uncertainty or search)

For maximum precision + traceability, use:

Python

Many exact constants (since 2019 SI redefinition) have uncertainty = 0.0.

Helper functions (very practical)

  • find(substring) → search for constants by name
Python
  • value(key), unit(key), precision(key)
Python

Real-life examples (the kind you actually write in research/lab)

Example 1: Blackbody peak wavelength (Wien’s law)

Python

Example 2: Thermal energy kT at room temperature

Python

Example 3: de Broglie wavelength of an electron accelerated by 100 V

Python

Example 4: Convert temperature scales (built-in helper)

Python

Example 5: Quick search when you forgot the name

Python

Quick summary table — most loved constants

What you want Code Typical value (2022 CODATA)
Speed of light const.c 299792458 m/s (exact)
Planck constant const.h 6.62607015 × 10⁻³⁴ J Hz⁻¹ (exact)
Reduced Planck (ħ) const.hbar ≈ 1.0545718 × 10⁻³⁴ J s
Elementary charge const.e 1.602176634 × 10⁻¹⁹ C (exact)
Boltzmann constant const.k / const.kB 1.380649 × 10⁻²³ J/K (exact)
Avogadro number const.N_A 6.02214076 × 10²³ mol⁻¹ (exact)
Gas constant const.R 8.314462618 J mol⁻¹ K⁻¹
Gravitational constant const.G 6.67430 × 10⁻¹¹ m³ kg⁻¹ s⁻²
Electron mass const.m_e 9.1093837 × 10⁻³¹ kg
Proton mass const.m_p 1.6726219 × 10⁻²⁷ kg
Fine-structure constant const.alpha ≈ 1/137.035999
Stefan–Boltzmann constant const.sigma 5.670374419 × 10⁻⁸ W m⁻² K⁻⁴

Final teacher tips (2026 edition)

  • Always import scipy.constants as const — short & conventional
  • Prefer direct attributes (const.c) over dictionary for speed & readability
  • Use physical_constants[…] only when you need uncertainty or traceability (publications)
  • Values are frozen to CODATA 2022 in SciPy 1.14–1.17 → very unlikely to change until next CODATA (probably 2026+)
  • If you see ConstantWarning → you’re using an old/outdated name — just update the key

Got a calculation in mind where you need one of these? Blackbody radiation? Bohr radius? Compton wavelength? Something astrophysical? Tell me and we’ll build a small realistic example together right now. 😊

You may also like...

Leave a Reply

Your email address will not be published. Required fields are marked *