63 fonctions Python intégrées (Built-in Functions)
Ce document regroupe 63 fonctions intégrées du langage Python 3. Toutes les fonctions listées
sont réelles, officielles et vérifiables dans la documentation Python.
print() – Affiche un message
print("Bonjour")
input() – Lit une entrée utilisateur
nom = input("Nom : ")
len() – Longueur d’un objet
len("Python")
type() – Type d’une variable
type(10)
int() – Conversion en entier
int("5")
float() – Conversion en flottant
float("3.14")
str() – Conversion en chaîne
str(25)
bool() – Conversion booléenne
bool(1)
help() – Aide intégrée
help(print)
id() – Identifiant mémoire
id(x)
abs() – Valeur absolue
abs(-5)
round() – Arrondir
round(3.6)
pow() – Puissance
pow(2, 3)
sum() – Somme
sum([1,2,3])
max() – Maximum
max(1,5)
min() – Minimum
min(1,5)
divmod() – Quotient et reste
divmod(7,2)
list() – Créer une liste
list("abc")
tuple() – Créer un tuple
tuple([1,2])
set() – Créer un ensemble
set([1,1,2])
dict() – Créer un dictionnaire
dict(a=1)
sorted() – Trier
sorted([3,1,2])
reversed() – Inverser
list(reversed([1,2,3]))
enumerate() – Index + valeur
enumerate(["a","b"])
zip() – Combiner
zip([1,2],[3,4])
range() – Suite de nombres
range(5)
all() – Tous vrais ?
all([True,True])
any() – Au moins un vrai ?
any([False,True])
filter() – Filtrer
filter(lambda x: x>0, [-1,2])
map() – Transformer
map(lambda x: x*2, [1,2])
next() – Élément suivant
next(iter([1,2]))
iter() – Créer itérateur
iter([1,2])
isinstance() – Vérifier type
isinstance(5,int)
issubclass() – Vérifier héritage
issubclass(bool,int)
hasattr() – Attribut existe ?
hasattr(obj,"x")
getattr() – Obtenir attribut
getattr(obj,"x")
setattr() – Définir attribut
setattr(obj,"x",5)
delattr() – Supprimer attribut
delattr(obj,"x")
dir() – Lister attributs
dir(obj)
open() – Ouvrir fichier
open("[Link]")
eval() – Évaluer expression
eval("2+3")
exec() – Exécuter code
exec("a=5")
compile() – Compiler code
compile("a=1","","exec")
globals() – Variables globales
globals()
locals() – Variables locales
locals()
callable() – Est appelable ?
callable(print)
hash() – Valeur de hachage
hash("abc")
memoryview() – Vue mémoire
memoryview(b"abc")
format() – Formatage
format(10,"b")
chr() – Code → caractère
chr(65)
ord() – Caractère → code
ord("A")
ascii() – ASCII
ascii("é")
repr() – Représentation officielle
repr("test")
slice() – Découpage
slice(1,3)
bin() – Binaire
bin(10)
oct() – Octal
oct(10)
hex() – Hexadécimal
hex(10)
bytes() – Type bytes
bytes("abc","utf-8")
bytearray() – Bytes modifiables
bytearray(5)
frozenset() – Set immuable
frozenset([1,2])
property() – Propriété de classe
property()
staticmethod() – Méthode statique
staticmethod(func)
classmethod() – Méthode de classe
classmethod(func)
Source officielle : Python Software Foundation – Built-in Functions
[Link]