Nevar pievienot vairāk kā 25 tēmas Tēmai ir jāsākas ar burtu vai ciparu, tā var saturēt domu zīmes ('-') un var būt līdz 35 simboliem gara.
Repozitorijs ir arhivēts. Tam var aplūkot failus un to var klonēt, bet nevar iesūtīt jaunas izmaiņas, kā arī atvērt jaunas problēmas/izmaiņu pieprasījumus.
 
 
 
 
 
 

713 B

% Programmation avec Python (chapitre 7) % Dimitri Merejkowsky

\center \huge Rappels sur les classes

Définition d’une classe

Construire la classeCounter avec un attribut count:

class Counter:
    def __init__(self):
        self.count = 0

Instantiation

Construire une nouvelle instance de Counter

>>> counter = Counter()
>>> counter.count
0

Méthode

Ajouter une méthode pour incrémenter le compteur:

class Counter:
    def __init__(self):
        self.count = 0

    def increment(self):
    	self.count += 1

Apeller une méthode

>>> counter = Counter()
>>> counter.count
0
>>> counter.increment()
>>> counter.count
1