0

Whats the logic of this function?

scores = [90,75,55,80,57,60] def func (list): for i in range(len(list)): if list[i] >=55 and list[i] <= 59: list[i] = 60 return list print(func (scores) Why the above function know to pick the numbers which not include on the condition( if list[i] >=55 and list[i] <= 59:, list[i] = 60)?

11th Nov 2020, 2:57 PM
Joe Ma
Joe Ma - avatar
3 Réponses
+ 4
I guess there is no logic behind it as the returned list is the following [90,75,60,80,60,60] and I can't see any special pattern ,the only thing it seems to do is checking for scores from 55 to 59 and replacing them with 60
11th Nov 2020, 3:02 PM
Abhay
Abhay - avatar
+ 3
Joe Ma even I can't understand based on this small piece of code The only assumption I can make is that there is some condition in other part of code according to which any score between those values should be converted to 60
11th Nov 2020, 3:09 PM
Abhay
Abhay - avatar
0
Abhay I dont understand why 90,75 and 80 are listed out?
11th Nov 2020, 3:06 PM
Joe Ma
Joe Ma - avatar