sum(i*i) for i in range(10) in python code example Example: how to use sum with range python res = sum(x for x in range(100, 2001) if x % 3 == 0)