Modules | Sololearn: Learn to code for FREE!



How output is 6 for below : def func(x): res = 0 for i in range(x): res += i return res print (func(4))

6/20/2020 4:36:55 PM

Sahana MK

1 Answer

New Answer


What does this have to do with Modules? Please try to find a fitting title for your questions. func is called with 4. range(4) becomes 0, 1, 2, 3. If you add all these numbers to res, it's six.