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))

20th Jun 2020, 4:36 PM
Sahana MK
Sahana MK - avatar
1 ответ
+ 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.
20th Jun 2020, 4:42 PM
HonFu
HonFu - avatar