+ 1
for range()
can anyone help with explanation. why answer is 8? for i in range (5): i=i+i print (i)
8 Answers
+ 2
and what about this?
j=0
for z in range (100):
j=j+j
print (j)
output:0
I can't just see difference between this and above example. Plus in cases j=j+1, j=j+2, etc answers respectively are 100, 200 etc. why?
+ 2
anyway thanks, I will review again.
+ 1
i is 0
i is 1
i is 1+1
i is 2+2
i is 3+3
i is 4+4
i is 8!
Note:
The range() function will not reach 5! It stops one before.
This is very important!!
+ 1
sorry I edited my post. look again please
0
b is 0. B is never changed.
You do
for j!!
do for b in range...
0
That doesn't output 0.
0
J will either be 198 or 398 (if you use range(100) or range(200)
0
ok