🚀 LEVEL UP TO SENIOR:Unlock 500+ Advanced Practical Challenges & Exercises.
🎓 COURSERA PARTNER:Earn professional Google, Meta, and IBM certificates to supercharge your resume.
REFERENCEscipy

scipy Documentation

LOADING ENGINE...

constants.G

AI & DATA SCIENCE // constants-g

scipy.constants.G is the Newtonian gravitational constant, in cubic meters per kilogram per second squared, used in the formula for gravitational force between two masses.

Syntax

from scipy import constants
constants.G

Deep Dive Course

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.

editor.html
from scipy import constants

print(constants.G)
localhost:3000

2Practical Example

Here is a real-world application of constants.G showing how it is used in production SciPy code.

editor.html
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")
localhost:3000

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.

editor.html
from scipy import constants

print(constants.G)
localhost:3000

Examples

Example 01Basic Usage
from scipy import constants

print(constants.G)
Example 02Advanced Example
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")

Best Practices

  • Use constants.G directly in gravitational force/orbital mechanics calculations rather than hardcoding its numeric value
  • Remember G carries real measurement uncertainty, unlike some other physical constants that are exactly defined, if precision matters for your specific calculation
  • 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

Interview Question

Why is the gravitational constant G known with much less precision than constants like the speed of light or the Planck constant?

Hint: Think about the relative strength of gravity compared to other fundamental forces, and what that means for measuring it in a lab.

Gravity is by far the weakest of the four fundamental forces, many orders of magnitude weaker than electromagnetism, which makes measuring the gravitational attraction between two masses in a controlled laboratory setting extremely difficult, since the gravitational signal is easily swamped by other, much stronger environmental influences and experimental noise. The speed of light and Planck constant, by contrast, are no longer measured experimentally at all — they've been fixed by definition as part of the modern SI unit system — while G remains one of the few fundamental constants that genuinely still has to be measured, and those measurements have historically been difficult to reconcile precisely between different experimental setups.

Exercises

MediumPractice using constants.G in a real scenario.
View Solution
from scipy import constants

print(constants.G)

Frequently Asked Questions

Why is the gravitational constant G known with much less precision than constants like the speed of light or the Planck constant?

Gravity is by far the weakest of the four fundamental forces, many orders of magnitude weaker than electromagnetism, which makes measuring the gravitational attraction between two masses in a controlled laboratory setting extremely difficult, since the gravitational signal is easily swamped by other, much stronger environmental influences and experimental noise. The speed of light and Planck constant, by contrast, are no longer measured experimentally at all — they've been fixed by definition as part of the modern SI unit system — while G remains one of the few fundamental constants that genuinely still has to be measured, and those measurements have historically been difficult to reconcile precisely between different experimental setups.

Related Functions

constants-cconstants-pinp-sqrt