Top 1000+ Solved Problem Solving and Python Programming MCQ Questions Answer
Q. Write a list comprehension for number and its cube for l=[1, 2, 3, 4, 5, 6, 7, 8, 9].
a. [x**3 for x in l]
b. [x^3 for x in l]
c. [x**3 in l]
d. [x^3 in l]
Q. Write a list comprehension for producing a list of numbers between 1 and 1000 that are divisible by 3.
a. [x in range(1, 1000) if x%3==0]
b. [x for x in range(1000) if x%3==0]
c. [x%3 for x in range(1, 1000)]
d. [x%3=0 for x in range(1, 1000)]
Q. 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)]
Q. , x is even} (including zero)
a. [x for x in range(1, 20) if (x%2==0)]
b. [x for x in range(0, 20) if (x//2==0)]
c. [x for x in range(1, 20) if (x//2==0)]
d. [x for x in range(0, 20) if (x%2==0)]
Q. , i)]
a. a list of prime numbers up to 50
b. a list of numbers divisible by 2, up to 50
c. a list of non prime numbers, up to 50
d. error
Q. for col in row] for row in A]
a. [[11, 12, 13], [14, 15, 16], [17, 18, 19]]
b. error
c. [11, 12, 13], [14, 15, 16], [17, 18, 19]
d. [11, 12, 13, 14, 15, 16, 17, 18, 19]
Q. , row2)] for (row1, row2) in zip(A, B)]
a. [0, 30, 60, 120, 160, 200, 300, 350, 400]
b. [[3, 6, 9], [16, 20, 24], [35, 40, 45]]
c. no output
d. error
Q. >>>[t[i] for i in range(0, len(t), 2)]
a. [2, 3, 9]
b. [1, 2, 4, 3, 8, 9]
c. [1, 4, 8]
d. (1, 4, 8)