0
Hello everyone! could somebody interpret this code?
x = 2 for i in range(3): x/2 print(x)
3 ответов
+ 2
x = 2 # assigns 2 to x
Your loop runs 3 times from i=0 to 2
but x/2 does not effect anything.
print(x) prints 2
if you want use x/2 in effect stores it's value may back in x like x=x/2
#run this code and observe output
x = 2
for i in range(3):
x = x/2
print("i=", i, "x=", x)
print(x)
Hope it helps..
+ 1
interesting. okay, let me do that.
+ 1
woah! prints three times. starts from starting from 1 = 0 to i = 2. i see it .