adplus-dvertising
frame-decoration

Question

Write a list comprehension to produce the list: [1, 2, 4, 8, 16……212].

a.

[(2**x) for x in range(0, 13)]

b.

[(x**2) for x in range(1, 13)]

c.

[(2**x) for x in range(1, 13)]

d.

[(x**2) for x in range(0, 13)]

Posted under Python

Answer: (a).[(2**x) for x in range(0, 13)]

Engage with the Community - Add Your Comment

Confused About the Answer? Ask for Details Here.

Know the Explanation? Add it Here.

Q. Write a list comprehension to produce the list: [1, 2, 4, 8, 16……212].

Similar Questions

Discover Related MCQs

Q. What is the list comprehension equivalent for: list(map(lambda x:x**-1, [1, 2, 3]))

Q. Write a list comprehension for producing a list of numbers between 1 and 1000 that are divisible by 3.

Q. Write a list comprehension for number and its cube for l=[1, 2, 3, 4, 5, 6, 7, 8, 9].

Q. Write the list comprehension to pick out only negative integers from a given list ‘l’.

Q. Which of the following is the same as list(map(lambda x: x**-1, [1, 2, 3]))?

Q. Which of the following is the correct expansion of list_1 = [expr(i) for i in list_0 if func(i)] ?

Q. To which of the following the “in” operator can be used to check if an item is in it?

Q. Suppose listExample is [3, 4, 5, 20, 5, 25, 1, 3], what is list1 after listExample.pop()?

Q. Suppose listExample is [3, 4, 5, 20, 5, 25, 1, 3], what is list1 after listExample.pop(1) ?

Q. Suppose listExample is [3, 4, 5, 20, 5, 25, 1, 3], what is list1 after listExample.extend([34, 5]) ?

Q. Suppose list1 is [3, 4, 5, 20, 5, 25, 1, 3], what is list1 after list1.reverse() ?

Q. Suppose list1 is [1, 3, 2], What is list1 * 2 ?

Q. Suppose list1 is [2, 33, 222, 14, 25], What is list1[:-1] ?

Q. Suppose list1 is [2, 33, 222, 14, 25], What is list1[-1] ?

Q. Suppose list1 is [4, 2, 2, 4, 5, 2, 1, 0], Which of the following is correct syntax for slicing operation ?

Q. To shuffle the list(say list1) what function do we use ?

Q. Suppose list1 is [1, 5, 9], what is sum(list1) ?

Q. Suppose list1 is [3, 5, 25, 1, 3], what is min(list1) ?

Q. Suppose list1 is [2445,133,12454,123], what is max(list1) ?

Q. Suppose listExample is [‘h’,’e’,’l’,’l’,’o’], what is len(listExample)?