Skip to content
Snippets Groups Projects
Commit d257a706 authored by Tanoh Mbah-ange-pascal's avatar Tanoh Mbah-ange-pascal
Browse files

fibo + fractal

parent 006931d6
No related branches found
No related tags found
No related merge requests found
#/TANOH/bin/python3 PASCAL
#31/01/2024
#TP3 GROUPE 15
def fibo(n:int)->int:
"""renvoie le terme de la suite de Fibonacci.
Précondition :
Exemple(s) :
$$$ fibo(10)
55
$$$ fibo(4)
3
"""
res = 0
if n == 0:
res = 0
elif 0 < n <=2:
res = res + 1
else:
res = fibo(n-1) + fibo(n-2)
return res
\ No newline at end of file
#/TANOH/bin/python3 PASCAL
#31/01/2024
#TP3 GROUPE 15
import turtle
def zig_zag():
"""dessine un Zig zag
Précondition : None
Exemple(s) :
$$$
"""
for i in range(5):
turtle.left(45)
turtle.forward(40)
turtle.right(90)
turtle.forward(40)
turtle.left(45)
def vonkoch(l:int|float, n:int):
"""à_remplacer_par_ce_que_fait_la_fonction
Précondition :
Exemple(s) :
$$$
"""
turtle.speed("fast")
if n == 0:
turtle.forward(l)
else:
vonkoch(l/3, n-1)
turtle.left(60)
vonkoch(l/3, n-1)
turtle.right(120)
vonkoch(l/3, n-1)
turtle.left(120)
vonkoch(l/3, n-1)
return turtle
\ No newline at end of file
#/TANOH/bin/python3 PASCAL
#31/01/2024
#TP3 GROUPE 15
def somme_de_deux_nombres(a:int, b:int)->int:
"""Renvoie la sommes des entiers
""" Renvoie la sommes des entiers
Précondition : aucune
Exemple(s) :
......@@ -13,7 +16,7 @@ def somme_de_deux_nombres(a:int, b:int)->int:
else:
res = somme_de_deux_nombres(a-1, b+1)
return res
#@trace
def binomial(n:int, p:int)->float:
"""à_remplacer_par_ce_que_fait_la_fonction
......@@ -32,4 +35,22 @@ def binomial(n:int, p:int)->float:
res = binomial(n-1,p) + binomial(n-1, p-1)
return res
def is_palindromic(mot:str)->bool:
"""à_remplacer_par_ce_que_fait_la_fonction
Précondition : Aucune
Exemple(s) :
$$$ is_palindromic('assa')
True
$$$ is_palindromic('papa')
False
"""
mot = mot.lower()
if 0<=len(mot)<=1:
res = True
else :
res = mot[0] == mot[-1] and is_palindromic(mot[1:-1])
return res
\ No newline at end of file
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment