0

Help me understand this code

Hello Would you please help me understand this code: student=["Mike ","Jason","frank"] midterm=[90,82,78] final=[88,93,77] final_grade={t[0] : max(t[1] , t[2]) for t in zip (student,midterm,final)} print(final_grade) Output shows the best score of each person in dictionary format But what does t[0] : max(t[1] , t[2] do?and why?

1st Sep 2021, 2:47 PM
Fram
Fram - avatar
1 Answer
+ 5
t is assigned a tuple of 3 values("Mike", 90,88) on each iteration . Max chooses maximum of 90 and 88 . Key is "Mike" Here and value is maximum of (90 and 80). Mike , 90,88 are values in first iteration.
1st Sep 2021, 2:56 PM
Abhay
Abhay - avatar