Pendulum Period

Source: May 2026, Task 1 (DTU 02002/02003). Study solution — not an official answer key.

Problem

Period of a simple pendulum: T = 2π √(L / g) with g = 9.81 m/s2.

Write pendulum_period(length) returning T in seconds.

Example
>>> pendulum_period(1.5)
2.456919878869914

Approach

Use math.sqrt and math.pi with g = 9.81.

Solution

Show solution Hide solution
Solution
import math

def pendulum_period(length):
    return 2 * math.pi * math.sqrt(length / 9.81)