Python: map, zip, input, sum
N, X = map(int, input().split())
maps two space-separated integers which represent the total number of students and total number of subjects. So, 5 3
indicates that five students participated in three subjects. In this case, N, X
becomes 5, 3
.
marks = []
stores space-separated grade point values, e.g. 89 90 94 88 95
. marks.append(map(float, input().split()))
is then used to append grade point values to the empty marks
list, which loops three times, according to the value assigned to X
, which is 3
.
Finally, the second for
loop, iterates through each row. Dividing the sum total of each column by the length of each column.
if __name__ == '__main__':
indicates that the script above will run only as a __main__
or stand-alone program. In other words: only when it is directly executed. So the script above can not be imported into another program as a module, e.g. import map_zip_grades
.