Modules | Sololearn: Learn to code for FREE!

0

Modules

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

+2

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.