Python: set(), map(), input(), sum(), len()
Input integers:
161 182 161 154 176 170 167 171 170 174
Script calculates average:
169.375
input()
appends space-separated values to list of strings:
['161', '182', '161', '154', '176', '170', '167', '171', '170', '174']
map()
them maps strings to integers:
<map object at 0x7f89f547a2e8>
set()
then converts map object to set of integers:
{161, 167, 170, 171, 174, 176, 182, 154}
The expression sum(ns) / len(ns)
calculates the average. sum(ns)
adds the numbers in the set. len(ns)
becomes the length of the set, or the divisor. 1355.0 / 8:
169.375