Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
A
AP-Dahmane-lynda
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
Lynda Dahmane
AP-Dahmane-lynda
Commits
6475d0c6
Commit
6475d0c6
authored
1 year ago
by
Dahmane Lynda
Browse files
Options
Downloads
Patches
Plain Diff
tp3 fin séance
parent
b31f94b1
Branches
Branches containing commit
No related tags found
No related merge requests found
Changes
4
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
Tp3/ap_decorators.py
+0
-0
0 additions, 0 deletions
Tp3/ap_decorators.py
Tp3/fibonacci.py
+32
-0
32 additions, 0 deletions
Tp3/fibonacci.py
Tp3/fractals.py
+46
-0
46 additions, 0 deletions
Tp3/fractals.py
Tp3/tracing_recurcing.py
+44
-1
44 additions, 1 deletion
Tp3/tracing_recurcing.py
with
122 additions
and
1 deletion
Tp3/
Recursion/fractales/
ap_decorators.py
→
Tp3/ap_decorators.py
+
0
−
0
View file @
6475d0c6
File moved
This diff is collapsed.
Click to expand it.
Tp3/fibonacci.py
0 → 100644
+
32
−
0
View file @
6475d0c6
#Q1:
# on calcul les nombres de fibonacci jusqu'à n=10:
#f_0=0 etf_1=1
#f_2=f_1+f_0=1+0=1....f_9=f_8+f_7=21+13=24, et f_10=f_9+f_8=34+21=55
from
ap_decorators
import
count
@count
def
fibo
(
n
:
int
)
->
int
:
"""
renvoie les termes de la suite Fibonacci
Précondition :
Exemple(s) :
$$$ fibo(10)
55
$$$ fibo(8)
21
$$$ fibo(1)
1
"""
if
n
<=
1
:
return
n
else
:
return
fibo
(
n
-
1
)
+
fibo
(
n
-
2
)
#fibo(40) donne : 102334155 , que f_40 est assez grand , donc les nombres de la suite fibonacci
#peuvent devenir grands à mesure que n augmente.
\ No newline at end of file
This diff is collapsed.
Click to expand it.
Tp3/fractals.py
0 → 100644
+
46
−
0
View file @
6475d0c6
import
turtle
def
zigzag
():
"""
à_remplacer_par_ce_que_fait_la_fonction
Précondition :
Exemple(s) :
$$$
"""
if
turtle
.
left
(
45
)
turtle
.
forward
(
50
)
turtle
.
rieght
(
100
)
turtle
.
forward
(
45
)
turtle
.
left
(
45
)
turtle
.
forward
(
50
)
turtle
.
rieght
(
100
)
turtle
.
forward
(
45
)
turtle
.
left
(
45
)
turtle
.
forward
(
50
)
turtle
.
rieght
(
100
)
turtle
.
forward
(
45
)
turtle
.
left
(
45
)
turtle
.
forward
(
50
)
turtle
.
rieght
(
100
)
turtle
.
forward
(
45
)
turtle
.
left
(
45
)
turtle
.
forward
(
50
)
turtle
.
rieght
(
100
)
turtle
.
forward
(
45
)
This diff is collapsed.
Click to expand it.
Tp3/tracing_recurcing.py
+
44
−
1
View file @
6475d0c6
#Dahmane lynda
#TP3
#31/01/2024
from
ap_decorators
import
trace
@trace
def
somme
(
a
:
int
,
b
:
int
)
->
int
:
"""
renvoie la somme des deux entiers a et b
...
...
@@ -16,4 +19,44 @@ def somme(a:int,b:int)->int:
res
=
b
else
:
res
=
somme
(
a
-
1
,
b
+
1
)
return
res
\ No newline at end of file
return
res
@trace
def
binomial
(
n
:
int
,
k
:
int
)
->
int
:
"""
renvoie le coefficient binomial ,qui represente le nombre de façon
de choisir k elements parmis un ensemble de n elements.
Précondition :
Exemple(s) :
$$$ binomial(7,3)
35
"""
if
k
==
0
or
k
==
n
:
return
1
else
:
return
binomial
(
n
-
1
,
k
-
1
)
+
binomial
(
n
-
1
,
k
)
@trace
def
is_palindromic
(
mot
:
str
)
->
bool
:
"""
renvoie True si le mot est un palindromic sinon renvoie False
Précondition :
Exemple(s) :
$$$ is_palindromic(
"
radar
"
)
True
$$$ is_palindromic(
"
hello
"
)
False
"""
if
len
(
mot
)
<=
1
:
return
True
elif
mot
[
0
]
==
mot
[
-
1
]:
return
is_palindromic
(
mot
[
1
:
-
1
])
else
:
return
False
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