Exercice H
This commit is contained in:
parent
0b254de788
commit
e1b01ced86
|
@ -76,4 +76,20 @@ def bhaut(n: int):
|
||||||
"""
|
"""
|
||||||
if n == 0: return # Si n est égal a 0 on ne fais rien
|
if n == 0: return # Si n est égal a 0 on ne fais rien
|
||||||
print("*" * n) # On affiche n points
|
print("*" * n) # On affiche n points
|
||||||
bhaut(n-1) # On fait appel à la fonction avec n-1 points pour afficher la ligne suivante
|
bhaut(n-1) # On fait appel à la fonction avec n-1 points pour afficher la ligne suivante
|
||||||
|
|
||||||
|
def pair(n: int) -> bool:
|
||||||
|
"""
|
||||||
|
Fonction récursive qui renvoie True si n est pair et False sinon.
|
||||||
|
"""
|
||||||
|
if n == 0: # Si n est égal a 0 alors
|
||||||
|
return True # On renvoie True pour dire que c'est pair
|
||||||
|
return impair(n-1) # Sinon on fait appel à la fonction impair avec n-1
|
||||||
|
|
||||||
|
def impair(n: int) -> bool:
|
||||||
|
"""
|
||||||
|
Fonction récursive qui renvoie True si n est impair et False sinon.
|
||||||
|
"""
|
||||||
|
if n == 0: # Si n est égal a 0 alors
|
||||||
|
return False # On renvoie False pour dire que cc n'est pas impair
|
||||||
|
return pair(n-1) # Sinon on fait appel à la fonction pair avec n-1
|
Loading…
Reference in a new issue