Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- class File:
- def __init__(self):
- self.valeurs=[]
- def enfiler(self,valeur):
- self.valeurs.append(valeur)
- def defiler(self):
- if self.valeurs:
- return self.valeurs.pop(0)
- def estVide(self):
- return self.valeurs==[]
- def longueur(self):
- return len(self.valeurs)
- def __str__(self):
- ch="\n Etat de la file: \n"
- for x in self.valeurs:
- ch+= str(x)+""
- return ch
- q=File()
- q.enfiler(9)
- q.enfiler(2)
- q.enfiler(5)
- print(q)
- q.defiler()
- q.enfiler(7)
- print ("la file est-t-elle vide:",q.estVide())
- print(q)
- print("Longuer de la file: ", q.longueur)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement