Base de connaissancesCentre d’examen
FRFrançais
Choisir la langue13

CKTIS / Python

math.pi

Fournit sous forme de float une approximation du rapport circonférence sur diamètre.

Version : Python 3.14; repository image, production runtime not attested

Syntaxe

math.pi

Fournit sous forme de float une approximation du rapport circonférence sur diamètre.

Le rayon 3 donne un diamètre de 6 et une circonférence de 6π, soit 18,85 après arrondi. Un demi-tour mesure π radians ou 180 degrés.

L’arrondi intervient à l’affichage.

import math
assert round(2 * math.pi * 3, 3) == 18.85
assert math.degrees(math.pi) == 180.0

Exemples

import math
print(round(2 * math.pi * 3, 3))
print(round(math.degrees(math.pi), 1))

Résultat

18.85
180.0

L’arrondi intervient à l’affichage.

Sources