0
why 6 is displayed
3 ответов
+ 5
Hello Ulmas
range(4) starts at 0 and ends at 3.
0 + 1 + 2 + 3 = 6
In general:
range(a,b,c)
a = start (default = 0)
b = end (exclusive)
c = step (default = 1)
0
#see output:Ulmas it explains :
def print_num(x):
res=0
print("res+i")
for i in range(x):
#res+=i
print(res,'+',i,'=>',"res=" ,res:=res+i)
return res
print (print_num (4))
0
Ulmas I<4. This is followed I<=4 is not followed