import cmath
import math


def tidy(value):
    """Arrondit à trois décimales ; le + 0.0 change le -0.0 laissé par l'arrondi en 0.0."""
    return round(value, 3) + 0.0


# e puissance iθ, calculé par Python, à côté du point (cos θ, sin θ) de la leçon 0.2
angles = [("0", 0), ("π/4", math.pi / 4), ("π/3", math.pi / 3), ("π/2", math.pi / 2), ("π", math.pi), ("3π/2", 3 * math.pi / 2)]
for name, theta in angles:
    u = cmath.exp(1j * theta)
    print(f"θ = {name:5} e^(iθ) : real = {tidy(u.real):6.3f}  imag = {tidy(u.imag):6.3f}   cos θ = {tidy(math.cos(theta)):6.3f}  sin θ = {tidy(math.sin(theta)):6.3f}   abs = {abs(u):.3f}")
