2020 */
2121'''
2222
23+ from functools import reduce
24+ from datetime import datetime
25+
2326"""
2427Ejercicio
2528"""
@@ -61,7 +64,7 @@ def is_even(n):
6164print (sorted (numbers , key = lambda x : - x ))
6265
6366# reduce
64- from functools import reduce
67+
6568def sum (x , y ):
6669 return x + y
6770
@@ -71,3 +74,38 @@ def sum(x, y):
7174Extra
7275"""
7376
77+ students = [
78+ {"name" : "Rigo" , "birthdate" : "25-05-1993" , "grades" : [10 , 9 , 10 , 7 , 10 ]},
79+ {"name" : "Mary" , "birthdate" : "24-08-1988" , "grades" : [9 , 9 , 5 , 7 , 6 ]},
80+ {"name" : "Robe" , "birthdate" : "06-05-1986" , "grades" : [8 , 8 , 8 , 7 , 6 ]}
81+ ]
82+
83+ def average (grades ):
84+ return sum (grades )/ len (grades )
85+
86+ # Promedio calificaciones
87+ print (
88+ list (map (lambda student :
89+ {"name" : student ["name" ],
90+ "average" : average (student ["grades" ])}, students ))
91+ )
92+
93+ # Mejores estudiantes
94+ print (
95+ list (
96+ map (lambda student :
97+ student ["name" ],
98+ filter (lambda student : average (student ["grades" ]) >= 9 , students ))
99+ )
100+ )
101+
102+ # Nacimiento
103+ print (
104+ list (
105+ sorted (students , key = lambda student : datetime .strptime (student ["birthdate" ], "%d-%m-%Y" ), reverse = True )
106+ )
107+ )
108+
109+ # Mayor calificacion
110+
111+ print (max (map (lambda student : max (student ["grades" ]), students )))
0 commit comments