initiation_a_python
Différences
Ci-dessous, les différences entre deux révisions de la page.
Les deux révisions précédentesRévision précédenteProchaine révision | Révision précédenteProchaine révisionLes deux révisions suivantes | ||
initiation_a_python [2021/08/21 13:25] – serge | initiation_a_python [2021/08/21 13:27] – [Les class permettent de créer des objets] serge | ||
---|---|---|---|
Ligne 478: | Ligne 478: | ||
print(b.kind) | print(b.kind) | ||
- | class Contact: | ||
- | |||
- | def __init__(self, | ||
- | self.name = name | ||
- | self.phone = None | ||
- | | ||
- | def set_phone(phone): | ||
- | self.phone = phone | ||
- | | ||
- | def get_phone(self): | ||
- | return self.phone | ||
- | |||
- | c = Contact(" | ||
- | print(c.get_phone()) | ||
- | |||
- | copains = [" | ||
- | mon_carnet = {} | ||
- | for copain in copains: | ||
- | mon_carnet[copain] = Contact(copain) | ||
- | | ||
- | print(" | ||
</ | </ | ||
- | [[https:// | ||
=====Excercices===== | =====Excercices===== | ||
====Numéro 1==== | ====Numéro 1==== |
initiation_a_python.txt · Dernière modification : 2021/08/21 13:41 de serge