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.
 
 
 
 
 
 

19 lines
609 B

  1. # Exercice: se débarrasser des ifs imbriqués
  2. def controlle_conducteur(*, sobre, accompagné, permis):
  3. if sobre:
  4. if permis:
  5. return True
  6. else:
  7. if accompagné:
  8. return True
  9. else:
  10. return False
  11. else:
  12. return False
  13. assert controlle_conducteur(sobre=True, accompagné=False, permis=True)
  14. assert controlle_conducteur(sobre=True, accompagné=True, permis=False)
  15. assert not controlle_conducteur(sobre=True, accompagné=False, permis=False)
  16. assert not controlle_conducteur(sobre=False, accompagné=False, permis=True)