Exemples d'Instanciation de Types de Données :
Exemple :
1
# int
2
a = 25
3
4
# float
5
temperature = 98.6
6
7
# str
8
filiere = "MIP"
9
10
# bool
11
valide = True
12
13
# list
14
L = [25, "MIP", "FPBM"]
15
16
# tuple
17
T = (13, 'BCG', 2023)
18
19
# dict
20
personne = {"nom": "John", "age": 30, "ville": "New York"}
21
22
# set
23
S = {25, 45, 11, 25} # S contiendra {11, 25, 45}
24
25
# NoneType
26
resultat = None
27
28
# complex
29
# Utilisation de complex()
30
z1 = complex(3, 4) # 3 + 4j
31
# Utiliser le suffixe j
32
z2 = 1 + 2j
33
print(z2.real, z2.imag) # Affiche: 1.0 2.0