0
Почему 6?
def func (x): res=0 for i in range (x): res+=i return res print(func(4))
1 ответ
+ 2
range(4) is 0, 1, 2, 3
so res =
0 + 0 = 0
0 + 1 = 1
1 + 2 = 3
3 + 3 = 6
so returned 6
def func (x): res=0 for i in range (x): res+=i return res print(func(4))