NIELIT M3-R5 Python MCQ Free Practice

NIELIT M3-R5 Python MCQ Free Practice

391.Write a list comprehension to produce the list: [1, 2, 4, 8, 16……212]
सूची बनाने के लिए एक सूची लिखें: [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)]

392.What is the list comprehension equivalent for?
सूची की समझ किसके लिए समान है?
{x : x is a whole number less than 20, 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)] ✔️

393.What will be the output of the following Python list comprehension?
निम्नलिखित पायथन सूची समझ का उत्पादन क्या होगा?
[j for i in range(2,8) for j in range(i*2, 50, 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

394.What will be the output of the following Python code?
निम्नलिखित पायथन कोड का आउटपुट क्या होगा?
l=[“good”, “oh!”, “excellent!”, “#450”]
[n for n in l if n.isalpha() or n.isdigit()]
A) [‘good’, ‘oh’, ‘excellent’, ‘450’ ]
B) [‘good’] ✔️
C) [‘good’, ‘#450’]
D) [‘oh!’, ‘excellent!’, ‘#450’]

395.Which of the following matrices will throw an error in Python?
पायथन में निम्नलिखित में से कौन सा मैट्रीक त्रुटि देगा?
A) A = [[1, 2, 3],
[4, 5, 6],
[7, 8, 9]]
B) B = [[3, 3, 3] ✔️
[4, 4, 4]
[5, 5, 5]]
C) C = [(1, 2, 4),
(5, 6, 7),
(8, 9, 10)]
D) D = [2, 3, 4,
3, 3, 3,
4, 5, 6]

396.What will be the output of the following Python code?
निम्नलिखित पायथन कोड का आउटपुट क्या होगा?
A = [[1, 2, 3],
[4, 5, 6],
[7, 8, 9]]
A[1]

A) [4, 5, 6] ✔️
B) [3, 6, 9]
C) [1, 4, 7]
D) [1, 2, 3]

397.Which of the following Python statements will result in the output: 6?
निम्नलिखित में से कौन सा पायथन कथन आउटपुट में परिणाम देगा: 6?
A = [[1, 2, 3],
[4, 5, 6],
[7, 8, 9]]
A) A[2][3]
B) A[2][1]
C) A[1][2] ✔️
D) A[3][2]

398.What will be the output of the following Python code?
निम्नलिखित पायथन कोड का आउटपुट क्या होगा?
A = [[1, 2, 3],
[4, 5, 6],
[7, 8, 9]]
[A[row][1] for row in (0, 1, 2)]

A) [7, 8, 9]
B) [4, 5, 6]
C) [2, 5, 8] ✔️
D) [1, 4, 7]

399.What will be the output of the following Python code?
निम्नलिखित पायथन कोड का आउटपुट क्या होगा?
A = [[1, 2, 3],
[4, 5, 6],
[7, 8, 9]]
[A[i][i] for i in range(len(A))]

A) [1, 5, 9] ✔️
B) [3, 5, 7]
C) [4, 5, 6]
D) [2, 5, 8]

400.What will be the output of the following Python code?
निम्नलिखित पायथन कोड का आउटपुट क्या होगा?
l=[[1, 2, 3], [4, 5, 6]]
for i in range(len(l)):
for j in range(len(l[i])):
l[i][j]+=10
print(l)

A) No output
B) Error
C) [[1, 2, 3], [4, 5, 6]]
D) [[11, 12, 13], [14, 15, 16]] ✔️

401.What will be the output of the following Python code?
निम्नलिखित पायथन कोड का आउटपुट क्या होगा?
A = [[1, 2, 3],
[4, 5, 6],
[7, 8, 9]]
[[col + 10 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]

402.What will be the output of the following Python code?
निम्नलिखित पायथन कोड का आउटपुट क्या होगा?
A = [[1, 2, 3],
[4, 5, 6],
[7, 8, 9]]
[A[i][len(A)-1-i] for i in range(len(A))]

A) [1, 5, 9]
B) [4, 5, 6]
C) [3, 5, 7] ✔️
D) [2, 5, 8]

403.What will be the output of the following Python code?
निम्नलिखित पायथन कोड का आउटपुट क्या होगा?
A = [[1, 2, 3],
[4, 5, 6],
[7, 8, 9]]
B = [[3, 3, 3],
[4, 4, 4],
[5, 5, 5]]
[B[row][col]*A[row][col] for row in range(3) for
col in range(3)]

A) [3, 6, 9, 16, 20, 24, 35, 40, 45] ✔️
B) Error
C) [0, 30, 60, 120, 160, 200, 300, 350, 400]
D) 0

404.What will be the output of the following Python code?
निम्नलिखित पायथन कोड का आउटपुट क्या होगा?
r = [11, 12, 13, 14, 15, 16, 17, 18, 19]
A = [[0, 10, 20],
[30, 40, 50],
[60, 70, 80]]
for row in A:
for col in row:
r.append(col+10)
print(r)
A) [11, 12, 13, 14, 15, 16, 17, 18, 19, 10, 20, 30, 40,50, 60, 70, 80, 90] ✔️
B) [10, 20, 30, 40, 50, 60, 70, 80, 90]
C) [11, 12, 13, 14, 15, 16, 17, 18, 19]
D) [0, 10, 20, 30, 40, 50, 60, 70, 80]

405.What will be the output of the following Python code?
निम्नलिखित पायथन कोड का आउटपुट क्या होगा?
A = [[1, 2, 3],
[4, 5, 6],
[7, 8, 9]]
B = [[3, 3, 3],
[4, 4, 4],
[5, 5, 5]]
[[col1 * col2 for (col1, col2) in zip(row1, 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

406.What will be the output of the following Python code?
निम्नलिखित पायथन कोड का आउटपुट क्या होगा?
l1=[1,2,3]
l2=[4,5,6]
[x*y for x in l1 for y in l2]

A) [4, 8, 12, 5, 10, 15, 6, 12, 18]
B) [4, 10, 18]
C) [4, 5, 6, 8, 10, 12, 12, 15, 18] ✔️
D) [18, 12, 6, 15, 10, 5, 12, 8, 4]

407.Write the list comprehension to pick out only negative integers from a given list ‘l’.
दी गई सूची ‘l’ से केवल नकारात्मक पूर्णांक निकालने के लिए सूची की समझ लिखें।
A) [x<0 in l]
B) [x for x<0 in l]
C) [x in l for x<0]
D) [x for x in l if x<0] ✔️

408.What will be the output of the following Python code?
निम्नलिखित पायथन कोड का आउटपुट क्या होगा?
s=[“pune”, “mumbai”, “delhi”]
[(w.upper(), len(w)) for w in s]
A) Error
B) [‘PUNE’, 4, ‘MUMBAI’, 6, ‘DELHI’, 5]
C) [PUNE, 4, MUMBAI, 6, DELHI, 5]
D) [(‘PUNE’, 4), (‘MUMBAI’, 6), (‘DELHI’, 5)] ✔️

409.What will be the output of the following Python code?
निम्नलिखित पायथन कोड का आउटपुट क्या होगा?
l1=[2,4,6]
l2=[-2,-4,-6]
for i in zip(l1, l2):
print(i)

A) 2, -2
4, -4
6, -6
B) [(2, -2), (4, -4), (6, -6)]
C) (2, -2) ✔️
(4, -4)
(6, -6)
D) [-4, -16, -36]

410.What will be the output of the following Python code?
निम्नलिखित पायथन कोड का आउटपुट क्या होगा?
l1=[10, 20, 30]
l2=[-10, -20, -30]
l3=[x+y for x, y in zip(l1, l2)]
l3
A) Error
B) 0
C) [-20, -60, -80]
D) [0, 0, 0] ✔️

411.Write a list comprehension for number and its cube for l=[1, 2, 3, 4, 5, 6, 7, 8, 9].
संख्या और उसके घन के लिए एक सूची लिखें 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]

412.What will be the output of the following Python code?
निम्नलिखित पायथन कोड का आउटपुट क्या होगा?
l=[[1 ,2, 3], [4, 5, 6], [7, 8, 9]]
[[row[i] for row in l] for i in range(3)]

A) Error
B) [[1, 4, 7], [2, 5, 8], [3, 6, 9]] ✔️
C) 1 4 7
2 5 8
3 6 9
D) (1 4 7)
(2 5 8)
(3 6 9)

413.What will be the output of the following Python code?
निम्नलिखित पायथन कोड का आउटपुट क्या होगा?
import math
[str(round(math.pi)) for i in range (1, 6)]
A) [‘3’, ‘3’, ‘3’, ‘3’, ‘3’, ‘3’]
B) [‘3.1’, ‘3.14’, ‘3.142’, ‘3.1416’, ‘3.14159’,’3.141582′]
C) [‘3’, ‘3’, ‘3’, ‘3’, ‘3’] ✔️
D) [‘3.1’, ‘3.14’, ‘3.142’, ‘3.1416’, ‘3.14159’]

414.What will be the output of the following Python code?
निम्नलिखित पायथन कोड का आउटपुट क्या होगा?
l1=[1,2,3]
l2=[4,5,6]
l3=[7,8,9]
for x, y, z in zip(l1, l2, l3):
print(x, y, z)

A) 1 4 7 ✔️
2 5 8
3 6 9
B) (1 4 7)
(2 5 8)
(3 6 9)
C) [(1, 4, 7), (2, 5, 8), (3, 6, 9)]
D) Error

415.Read the information given below carefully and write a list comprehension such that the output is:
नीचे दी गई जानकारी को ध्यान से पढ़ें और एक सूची लिखें जैसे कि आउटपुट है:
[‘e’, ‘o’]
w=”hello”
v=(‘a’, ‘e’, ‘i’, ‘o’, ‘u’)
A) [x for w in v if x in v]
B) [x for x in w if x in v] ✔️
C) [x for x in v if w in v]
D) [x for v in w for x in w]

416.What will be the output of the following Python code?
निम्नलिखित पायथन कोड का आउटपुट क्या होगा?
[ord(ch) for ch in ‘abc’]
A) [97, 98, 99] ✔️
B) [’97’, ’98’, ’99’]
C) [65, 66, 67]
D) Error

417.What will be the output of the following Python code?
निम्नलिखित पायथन कोड का आउटपुट क्या होगा?
t=32.00
[round((x-32)*5/9) for x in t]
A) [0]
B) 0
C) [0.00]
D) Error ✔️

418.Write a list comprehension for producing a list of numbers between 1 and 1000 that are divisible by 3.
1 और 1000 के बीच संख्याओं की सूची बनाने के लिए एक सूची की समझ लिखें जो 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)]

419.Write a list comprehension equivalent for the Python code shown below.
नीचे दिखाए गए पायथन कोड के बराबर एक सूची समझ लिखें।
for i in range(1, 101):
if int(i*0.5)==i*0.5:
print(i)
A) [i for i in range(1, 100) if int(i*0.5)==(i*0.5)]
B) [i for i in range(1, 101) if int(i*0.5)==(i*0.5)] ✔️
C) [i for i in range(1, 101) if int(i*0.5)=(i*0.5)]
D) [i for i in range(1, 100) if int(i*0.5)=(i*0.5)]

420.What is the list comprehension equivalent
for: list(map(lambda x:x**-1, [1, 2, 3]))?
A) [1|x for x in [1, 2, 3]]
B) [-1**x for x in [1, 2, 3]]
C) [x**-1 for x in [1, 2, 3]] ✔️
D) [x^-1 for x in range(4)]

Relate Link