Différences
Ci-dessous, les différences entre deux révisions de la page.
Les deux révisions précédentes Révision précédente Prochaine révision | Révision précédente | ||
python:fonctions [2019/10/20 15:51] – physix | python:fonctions [2020/07/24 03:31] (Version actuelle) – modification externe 127.0.0.1 | ||
---|---|---|---|
Ligne 3: | Ligne 3: | ||
===== Créer une fonction ===== | ===== Créer une fonction ===== | ||
- | < | + | < |
def parabole(x): | def parabole(x): | ||
return x ** 2 - 3 | return x ** 2 - 3 | ||
Ligne 13: | Ligne 13: | ||
Pour l' | Pour l' | ||
- | < | + | < |
parabole(4) | parabole(4) | ||
Ligne 20: | Ligne 20: | ||
===== Importer une fonction ===== | ===== Importer une fonction ===== | ||
- | < | + | < |
from math import cos, pi | from math import cos, pi | ||
Ligne 31: | Ligne 31: | ||
donne | donne | ||
- | < | + | < |
3.141592653589793 | 3.141592653589793 | ||
Ligne 38: | Ligne 38: | ||
</ | </ | ||
- | < | + | ---- |
+ | |||
+ | < | ||
import math | import math | ||
- | math.cos( math.pi / 3. ) | + | print(math.cos( math.pi / 3. )) |
+ | |||
+ | </ | ||
+ | |||
+ | donne | ||
+ | |||
+ | < | ||
+ | 0.5000000000000001 | ||
+ | |||
+ | </ | ||
+ | |||
+ | |||
+ | |||
+ | <code python> | ||
+ | import math as m | ||
+ | |||
+ | print(m.cos ( m.pi / 3. )) | ||
</ | </ |