G appears in Newton's law of universal gravitation, relating the gravitational force between two masses to their masses and the distance between them. Unlike the speed of light or the Planck constant, G is not an exactly defined value — it's determined experimentally and remains one of the least precisely known fundamental physical constants, since gravity is extremely weak compared to other fundamental forces, making it difficult to measure with high precision in a lab setting.
1Understanding constants.G
G appears in Newton's law of universal gravitation, relating the gravitational force between two masses to their masses and the distance between them. Unlike the speed of light or the Planck constant, G is not an exactly defined value — it's determined experimentally and remains one of the least precisely known fundamental physical constants, since gravity is extremely weak compared to other fundamental forces, making it difficult to measure with high precision in a lab setting.
Unlike constants.c or constants.h, constants.G is a measured value with real experimental uncertainty attached, not an exact defined constant — if working precision matters for gravitational calculations, check scipy.constants.physical_constants for its associated uncertainty value.
from scipy import constants
print(constants.G)2Practical Example
Here is a real-world application of constants.G showing how it is used in production SciPy code.
from scipy import constants
earth_mass = 5.972e24
sun_mass = 1.989e30
distance = 1.496e11
force = constants.G * earth_mass * sun_mass / distance ** 2
print(f"{force:.3e} newtons")3Best Practices
Follow these guidelines when working with constants.G:
1. Use constants.G directly in gravitational force/orbital mechanics calculations rather than hardcoding its numeric value
2. Remember G carries real measurement uncertainty, unlike some other physical constants that are exactly defined, if precision matters for your specific calculation
3. Keep consistent SI units, meters, kilograms, seconds, throughout any calculation using G, since mixing unit systems is a common source of errors with this constant specifically
Tip: Unlike constants.c or constants.h, constants.G is a measured value with real experimental uncertainty attached, not an exact defined constant — if working precision matters for gravitational calculations, check scipy.constants.physical_constants for its associated uncertainty value.
from scipy import constants
print(constants.G)