Questions extraites du site genumsi.inria.fr qui propose des QCM d'entraînement.
On définit ainsi une liste t puis une liste r : Combien la liste r contient-elle d'éléments ?t = [ {'id':1, 'age':23, 'sejour':'PEKIN'},
{'id':2, 'age':27, 'sejour':'ISTANBUL'},
{'id':3, 'age':53, 'sejour':'LONDRES'},
{'id':4, 'age':41, 'sejour':'ISTANBUL'},
{'id':5, 'age':62, 'sejour':'RIO'},
{'id':6, 'age':28, 'sejour':'ALGER'} ]
r = [ c for c in t if c['age']>30 and c['sejour']=='ISTANBUL' ]
0
1
2
3
La réponse est : B