0
What is the square of i?
n = int(input()) insects = [n*2**i for i in range(12)] print(insects)
4 Antworten
+ 6
Oro Collares ,
not quite claer what your question or what your issue is. can you give some more details?
+ 4
Oro Collares
** has high preference than * so
n*2**i = n*(2**i)
range(12)= [0,1,2,3,4,5,6,7,8,9,10,11]
n => 2
2 * (2**0) = 2 * 1
2 * (2**1) = 2 * 2
2 * (2**2) = 2 * 4
2 * (2**11) = 2 * 2048
+ 2
PS. ** is not call square, it is raise power to i, or i as exponent.
+ 1
@Lothar I wanted to know what the square of "**y" was because I thought that for example:
2*2**i i in iteration 3 = 4**3 = 64
but i guess it is:
2*(2**i) i iter 3 = 4*2 = 8