Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
A
ap-Tanoh mbah ange pascal
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Package registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
M'Bah Ange Pascal Tanoh
ap-Tanoh mbah ange pascal
Commits
d257a706
Commit
d257a706
authored
1 year ago
by
Tanoh Mbah-ange-pascal
Browse files
Options
Downloads
Patches
Plain Diff
fibo + fractal
parent
006931d6
No related branches found
No related tags found
No related merge requests found
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
TP3/Recursion/fibonacci.py
+25
-0
25 additions, 0 deletions
TP3/Recursion/fibonacci.py
TP3/Recursion/fractals.py
+41
-0
41 additions, 0 deletions
TP3/Recursion/fractals.py
TP3/Recursion/recursivité.py
+24
-2
24 additions, 2 deletions
TP3/Recursion/recursivité.py
with
90 additions
and
2 deletions
TP3/Recursion/fibonacci.py
0 → 100644
+
25
−
0
View file @
d257a706
#/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
This diff is collapsed.
Click to expand it.
TP3/Recursion/fractals.py
0 → 100644
+
41
−
0
View file @
d257a706
#/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
This diff is collapsed.
Click to expand it.
TP3/Recursion/recursivité.py
+
24
−
2
View file @
d257a706
#/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
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment