Explanation: the required list comprehension will print the numbers from 1 to 12, each raised to 2. the required answer is thus, [(2**x) for x in range(0, 13)].
Q. Write a list comprehension to produce the list: [1, 2, 4, 8, 16……212].
β
Correct Answer: (A)
[(2**x) for x in range(0, 13)]
Explanation by: Mr. Dubey
the required list comprehension will print the numbers from 1 to 12, each raised to 2. the required answer is thus, [(2**x) for x in range(0, 13)].
Discussion
Question Analytics
317
Total Visits
2 y ago
Published
Mr. Dubey
Publisher
92%
Success Rate