0

What is the square of i?

n = int(input()) insects = [n*2**i for i in range(12)] print(insects)

21st Aug 2022, 6:57 PM
Josué Varela
Josué Varela - avatar
4 Respostas
+ 6
Oro Collares , not quite claer what your question or what your issue is. can you give some more details?
21st Aug 2022, 7:36 PM
Lothar
Lothar - avatar
+ 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
21st Aug 2022, 9:11 PM
A͢J
A͢J - avatar
+ 2
PS. ** is not call square, it is raise power to i, or i as exponent.
21st Aug 2022, 9:56 PM
abpatrick catkilltsoi
abpatrick catkilltsoi - avatar
+ 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
21st Aug 2022, 8:28 PM
Josué Varela
Josué Varela - avatar