-
Notifications
You must be signed in to change notification settings - Fork 6
Expand file tree
/
Copy pathsolution_mini_db.py
More file actions
32 lines (30 loc) · 1016 Bytes
/
solution_mini_db.py
File metadata and controls
32 lines (30 loc) · 1016 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
def consultation():
while 1:
nom = input("Entrez le nom (ou <enter> pour terminer) : ")
if nom == "":
break
print(nom)
if nom in dico: # le nom est-il répertorié ?
item = dico[nom] # consultaion proprement dite
age, taille = item[0], item[1]
print ("Nom : %s - âge : %s ans - taille : %s m."\
% (nom, age, taille))
else:
print("*** nom inconnu ! ***")
def remplissage():
while 1:
nom = input("Entrez le nom (ou <enter> pour terminer) : ")
if nom == "":
break
age = int(input("Entrez l'âge (nombre entier !) : "))
taille = float(input("Entrez la taille (en mètres) : "))
dico[nom] = (age, taille)
dico ={}
while 1:
choix = input("Choisissez : (R)emplir - (C)onsulter - (T)erminer : ")
if choix.upper() == 'T':
break
elif choix.upper() == 'R':
remplissage()
elif choix.upper() == 'C':
consultation()