You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
This repo is archived. You can view files and clone it, but cannot push or open issues/pull-requests.
 
 
 
 
 
 

21 lines
524 B

  1. # Exercice: rendre la fonction peut_voter() plus lisible
  2. # et plus explicite
  3. class Personne:
  4. def __init__(self, age, nationalité, inscrite):
  5. self.age = age
  6. self.nationalité = nationalité
  7. self.inscrite = inscrite
  8. def peut_voter(personne):
  9. return (
  10. personne.age >= 18 and personne.nationalité == "Française" and personne.inscrite
  11. )
  12. martine = Personne(42, "Française", True)
  13. assert peut_voter(martine)
  14. kevin = Personne(12, "Française", True)
  15. assert not peut_voter(kevin)