Orbital Period

Source: Dec 2024, Task 2 (DTU 02002/02003). Study solution — not an official answer key.

Problem

Kepler’s third law: T2 = (4π2 / (G M)) * a3 with G = 6.6743e-11.

Write orbital_period(a, M) returning period T in seconds.

Example
>>> orbital_period(1.5 * 10**11, 2.0 * 10**30)
31593584.1373

Approach

Compute T = sqrt((4 * pi2 * a3) / (G * M)) using math.sqrt and math.pi.

Solution

Show solution Hide solution
Solution
import math

G = 6.6743e-11

def orbital_period(a, M):
    return math.sqrt((4 * math.pi ** 2 * a ** 3) / (G * M))