x = [4, 3, 4, 1]
x
[4, 3, 4, 1]
sum(x)
12
sum(x)/len(x)
3.0
x
[4, 3, 4, 1]
sorted(x)
[1, 3, 4, 4]
%timeit sorted(x, reverse=True)
sorted(x, reverse=True)
The slowest run took 4.72 times longer than the fastest. This could mean that an intermediate result is being cached. 100000 loops, best of 3: 2.09 µs per loop
[4, 4, 3, 1]