0

OUTPUT EXPLANATION

I am playing in the playground but I am not 100% sure why the output is like that byte=1 for a in range(6) byte*=2 print(byte) why the output is 64? I can see that 2 on 8 2x2x2x2x2 - but what is the role here of =3? byte=2 for a in range(4) byte*=1 print(byte) output 2 ?

21st Nov 2019, 9:16 AM
THEGreatGatsby
THEGreatGatsby - avatar
2 Respostas
+ 1
byte=1 for a in range(6): byte*=2 print(byte) #this for loop is for range(6),which iterates from 0 to 5 #byte=byte*2 1*2 = 2 #for loop : for 0 2*2 = 4 # for 1 4*2 = 8 # for 2 8*2 = 16 # for 3 16*2 = 32 # for 4 32*2 = 64 # for 5 #this is why the answer is 64. And same explanation goes for your second question as well.
21st Nov 2019, 1:19 PM
Firdous Khan
0
sorry this was from another test, I changed it now
21st Nov 2019, 9:48 AM
THEGreatGatsby
THEGreatGatsby - avatar