Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
A
AP-WALLOT-Angy
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
Angy Wallot
AP-WALLOT-Angy
Commits
0bcb1fa5
Commit
0bcb1fa5
authored
1 year ago
by
Angy Wallot
Browse files
Options
Downloads
Patches
Plain Diff
tp.4
parent
023fb434
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
tp.4/etudiants/.~lock.etudiants.csv#
+1
-0
1 addition, 0 deletions
tp.4/etudiants/.~lock.etudiants.csv#
tp.4/etudiants/etudiant.py
+0
-63
0 additions, 63 deletions
tp.4/etudiants/etudiant.py
tp.4/etudiants/gestion_promo_etudiants.py
+75
-0
75 additions, 0 deletions
tp.4/etudiants/gestion_promo_etudiants.py
with
76 additions
and
63 deletions
tp.4/etudiants/.~lock.etudiants.csv#
0 → 100644
+
1
−
0
View file @
0bcb1fa5
,angy.wallot.etu,118p26,07.02.2024 11:36,file:///home/l1/angy.wallot.etu/.config/libreoffice/4;
\ No newline at end of file
This diff is collapsed.
Click to expand it.
tp.4/etudiants/etudiant.py
+
0
−
63
View file @
0bcb1fa5
...
@@ -87,69 +87,6 @@ class Etudiant:
...
@@ -87,69 +87,6 @@ class Etudiant:
def
charge_fichier_etudiants
(
fname
:
str
)
->
list
[
Etudiant
]:
"""
Renvoie la liste des étudiants présents dans le fichier dont
le nom est donné en paramètre.
précondition: le fichier est du bon format.
"""
res
=
[]
with
open
(
fname
,
'
r
'
)
as
fin
:
fin
.
readline
()
ligne
=
fin
.
readline
()
while
ligne
!=
''
:
nip
,
nom
,
prenom
,
naissance
,
formation
,
groupe
=
ligne
.
strip
().
split
(
'
;
'
)
y
,
m
,
d
=
naissance
.
split
(
'
-
'
)
date_naiss
=
Date
(
int
(
d
.
lstrip
(
'
0
'
)),
int
(
m
.
lstrip
(
'
0
'
)),
int
(
y
))
res
.
append
(
Etudiant
(
nip
,
nom
,
prenom
,
date_naiss
,
formation
,
groupe
))
ligne
=
fin
.
readline
()
return
res
L_ETUDIANTS
=
charge_fichier_etudiants
(
"
etudiants.csv
"
)
COURTE_LISTE
=
L_ETUDIANTS
[:
10
]
def
est_liste_d_etudiants
(
x
)
->
bool
:
"""
Renvoie True si ``x`` est une liste de d
'
étudiant, False dans le cas contraire.
Précondition: aucune
Exemples:
$$$ est_liste_d_etudiants(COURTE_LISTE)
True
$$$ est_liste_d_etudiants(
"
Timoleon
"
)
False
$$$ est_liste_d_etudiants([(
'
12345678
'
,
'
Calbuth
'
,
'
Raymond
'
,
'
Danse
'
,
'
12
'
) ])
False
"""
res
=
isinstance
(
x
,
list
)
if
res
==
True
:
for
el
in
x
:
res
=
isinstance
(
el
,
Etudiant
)
return
res
NBRE_ETUDIANTS
=
len
(
L_ETUDIANTS
)
NIP
=
"
42312037
"
def
s
(
n
):
"""
à_remplacer_par_ce_que_fait_la_fonction
Précondition :
Exemple(s) :
$$$ s(49423558)
'
Marcel Rocher
'
$$$ s(49452026)
'
Laetitia Sanchez
'
$$$ s(NIP)
'
non
'
"""
for
el
in
L_ETUDIANTS
:
if
el
.
nip
==
str
(
n
):
return
el
.
prenom
+
"
"
+
el
.
nom
return
"
non
"
if
(
__name__
==
"
__main__
"
):
if
(
__name__
==
"
__main__
"
):
...
...
This diff is collapsed.
Click to expand it.
tp.4/etudiants/gestion_promo_etudiants.py
+
75
−
0
View file @
0bcb1fa5
...
@@ -2,6 +2,9 @@
...
@@ -2,6 +2,9 @@
#gestion_promo_etudiants
#gestion_promo_etudiants
#07/02/24
#07/02/24
from
date
import
Date
from
etudiant
import
Etudiant
def
pour_tous
(
seq_bool
:
bool
)
->
bool
:
def
pour_tous
(
seq_bool
:
bool
)
->
bool
:
"""
"""
Renvoie True ssi `seq_bool` ne contient pas False
Renvoie True ssi `seq_bool` ne contient pas False
...
@@ -38,3 +41,75 @@ def il_existe(seq_bool: bool) -> bool:
...
@@ -38,3 +41,75 @@ def il_existe(seq_bool: bool) -> bool:
if
el
==
True
:
if
el
==
True
:
return
el
return
el
return
False
return
False
def
charge_fichier_etudiants
(
fname
:
str
)
->
list
[
Etudiant
]:
"""
Renvoie la liste des étudiants présents dans le fichier dont
le nom est donné en paramètre.
précondition: le fichier est du bon format.
"""
res
=
[]
with
open
(
fname
,
'
r
'
)
as
fin
:
fin
.
readline
()
ligne
=
fin
.
readline
()
while
ligne
!=
''
:
nip
,
nom
,
prenom
,
naissance
,
formation
,
groupe
=
ligne
.
strip
().
split
(
'
;
'
)
y
,
m
,
d
=
naissance
.
split
(
'
-
'
)
date_naiss
=
Date
(
int
(
d
.
lstrip
(
'
0
'
)),
int
(
m
.
lstrip
(
'
0
'
)),
int
(
y
))
res
.
append
(
Etudiant
(
nip
,
nom
,
prenom
,
date_naiss
,
formation
,
groupe
))
ligne
=
fin
.
readline
()
return
res
L_ETUDIANTS
=
charge_fichier_etudiants
(
"
etudiants.csv
"
)
COURTE_LISTE
=
L_ETUDIANTS
[:
10
]
def
est_liste_d_etudiants
(
x
)
->
bool
:
"""
Renvoie True si ``x`` est une liste de d
'
étudiant, False dans le cas contraire.
Précondition: aucune
Exemples:
$$$ est_liste_d_etudiants(COURTE_LISTE)
True
$$$ est_liste_d_etudiants(
"
Timoleon
"
)
False
$$$ est_liste_d_etudiants([(
'
12345678
'
,
'
Calbuth
'
,
'
Raymond
'
,
'
Danse
'
,
'
12
'
) ])
False
"""
res
=
isinstance
(
x
,
list
)
if
res
==
True
:
for
el
in
x
:
res
=
isinstance
(
el
,
Etudiant
)
return
res
NBRE_ETUDIANTS
=
len
(
L_ETUDIANTS
)
NIP
=
"
42312037
"
def
s
(
n
):
"""
à_remplacer_par_ce_que_fait_la_fonction
Précondition :
Exemple(s) :
$$$ s(49423558)
'
Marcel Rocher
'
$$$ s(49452026)
'
Laetitia Sanchez
'
$$$ s(NIP)
'
non
'
"""
for
el
in
L_ETUDIANTS
:
if
el
.
nip
==
str
(
n
):
return
el
.
prenom
+
"
"
+
el
.
nom
return
"
non
"
def
li
(
l
):
res
=
[]
for
i
in
range
(
len
(
l
)):
s
=
f
"
{
l
[
i
].
naissance
.
jour
}
-
{
l
[
i
].
naissance
.
mois
}
-
{
l
[
i
].
naissance
.
annee
}
"
if
s
<
2
-
2
-
2003
:
res
.
append
(
l
[
i
].
prenom
)
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