# M3-R5 Python Basics MCQ with Answers

M3-R5 Python Basics MCQ with Answers

331.What will be the output of the following Python code?
निम्नलिखित पायथन कोड का आउटपुट क्या होगा?
values = [[3, 4, 5, 1], [33, 6, 1, 2]]
v = values[0][0]
for row in range(0, len(values)):
for column in range(0, len(values[row])):
if v < values[row][column]:
v = values[row][column]
print(v)
A) 3
B) 5
C) 6
D) 33 ✔️

332.What will be the output of the following Python code?
निम्नलिखित पायथन कोड का आउटपुट क्या होगा?
values = [[3, 4, 5, 1], [33, 6, 1, 2]]
v = values[0][0]
for lst in values:
for element in lst:
if v > element:
v = element
print(v)
A) 1 ✔️
B) 3
C) 5
D) 6

333.What will be the output of the following Python code?
निम्नलिखित पायथन कोड का आउटपुट क्या होगा?
values = [[3, 4, 5, 1 ], [33, 6, 1, 2]]
for row in values:
row.sort()
for element in row:
print(element, end = ” “)
print()
A) The program prints two rows 3 4 5 1 followed by 33 6 1 2
B) The program prints on row 3 4 5 1 33 6 1 2
C) The program prints two rows 3 4 5 1 followed by 33 6 1 2
D) The program prints two rows 1 3 4 5 followed by 1 2 6 33 ✔️

334.What will be the output of the following Python code?
matrix = [[1, 2, 3, 4],
[4, 5, 6, 7],
[8, 9, 10, 11],
[12, 13, 14, 15]]
for i in range(0, 4):
print(matrix[i][1], end = ” “)
A) 1 2 3 4
B) 4 5 6 7
C) 1 3 8 12
D) 2 5 9 13 ✔️

335.What will be the output of the following Python code?
निम्नलिखित पायथन कोड का आउटपुट क्या होगा?
def m(list):
v = list[0]
for e in list:
if v < e: v = e
return v
values = [[3, 4, 5, 1], [33, 6, 1, 2]]
for row in values:
print(m(row), end = ” “)
A) 3 33
B) 1 1
C) 5 6
D) 5 33 ✔️

336.What will be the output of the following Python code?
निम्नलिखित पायथन कोड का आउटपुट क्या होगा?
data = [[[1, 2], [3, 4]], [[5, 6], [7, 8]]]
print(data[1][0][0])
A) 1
B) 2
C) 4
D) 5 ✔️

337.What will be the output of the following Python code?
निम्नलिखित पायथन कोड का आउटपुट क्या होगा?
data = [[[1, 2], [3, 4]], [[5, 6], [7, 8]]]
def ttt(m):
v = m[0][0]
for row in m:
for element in row:
if v < element: v = element
return v
print(ttt(data[0]))
A) 1
B) 2
C) 4 ✔️
D) 5

338.What will be the output of the following Python code?
निम्नलिखित पायथन कोड का आउटपुट क्या होगा?
points = [[1, 2], [3, 1.5], [0.5, 0.5]]
points.sort()
print(points)
A) [[1, 2], [3, 1.5], [0.5, 0.5]]
B) [[3, 1.5], [1, 2], [0.5, 0.5]]
C) [[0.5, 0.5], [1, 2], [3, 1.5]] ✔️
D) [[0.5, 0.5], [3, 1.5], [1, 2]]

339.What will be the output of the following Python code?
निम्नलिखित पायथन कोड का आउटपुट क्या होगा?
a=[10,23,56,[78]]
b=list(A)
a[3][0]=95
a[1]=34
print(B)
A) [10,34,56,[95]]
B) [10,23,56,[78]]
C) [10,23,56,[95]] ✔️
D) [10,34,56,[78]]

340.What will be the output of the following Python code?
निम्नलिखित पायथन कोड का आउटपुट क्या होगा?
print(list(zip((1,2,3),(‘a’),(‘xxx’,’yyy’))))
print(list(zip((2,4),(‘b’,’c’),(‘yy’,’xx’))))

A)[(1,2,3),(‘a’),(‘xxx’,’yyy’)]
[(2,4),(‘b’,’c’),(‘yy’,’xx’)]
B)[(1, ‘a’, ‘xxx’),(2,’ ‘,’yyy’),(3,’ ‘,’ ‘)]
[(2, ‘b’, ‘yy’), (4, ‘c’, ‘xx’)]
C) Syntax error
D)[(1, ‘a’, ‘xxx’)] ✔️
[(2, ‘b’, ‘yy’), (4, ‘c’, ‘xx’)]

341.What will be the output of the following Python code?
निम्नलिखित पायथन कोड का आउटपुट क्या होगा?
import copy
a=[10,23,56,[78]]
b=copy.deepcopy(A)
a[3][0]=95
a[1]=34
print(B)
A) [10,34,56,[95]]
B) [10,23,56,[78]] ✔️
C) [10,23,56,[95]]
D) [10,34,56,[78]]

342.What will be the output of the following Python code?
निम्नलिखित पायथन कोड का आउटपुट क्या होगा?
s=”a@b@c@d”
a=list(s.partition(“@”))
print(A)
b=list(s.split(“@”,3))
print(B)

A)[‘a’,’b’,’c’,’d’]
[‘a’,’b’,’c’,’d’]
B)[‘a’,’@’,’b’,’@’,’c’,’@’,’d’]
[‘a’,’b’,’c’,’d’]
C)[‘a’,’@’,’b@c@d’] ✔️
[‘a’,’b’,’c’,’d’]
D)[‘a’,’@’,’b@c@d’]
[‘a’,’@’,’b’,’@’,’c’,’@’,’d’]

343.What will be the output of the following Python code?
निम्नलिखित पायथन कोड का आउटपुट क्या होगा?
a=[1,2,3,4]
b=[sum(a[0:x+1]) for x in range(0,len(A))]
print(B)
A) 10
B) [1,3,5,7]
C) 4
D) [1,3,6,10] ✔️

344.What will be the output of the following Python code?
निम्नलिखित पायथन कोड का आउटपुट क्या होगा?
a=”hello”
b=list((x.upper(),len(x)) for x in A)
print(B)
A) [(‘H’, 1), (‘E’, 1), (‘L’, 1), (‘L’, 1), (‘O’, 1)] ✔️
B) [(‘HELLO’, 5)]
C) [(‘H’, 5), (‘E’, 5), (‘L’, 5), (‘L’, 5), (‘O’, 5)]
D) Syntax error

345.What will be the output of the following Python code?
निम्नलिखित पायथन कोड का आउटपुट क्या होगा?
a=[1,2,3,4]
b=[sum(a[0:x+1]) for x in range(0,len(A))]
print(B)
A) 10
B) [1,3,5,7]
C) 4
D) [1,3,6,10] ✔️

346.What will be the output of the following Python code?
निम्नलिखित पायथन कोड का आउटपुट क्या होगा?
myList = [1, 2, 3, 4, 5, 6]
for i in range(1, 6):
myList[i – 1] = myList[i]
for i in range(0, 6):
print(myList[i], end = ” “)
A) 2 3 4 5 6 1
B) 6 1 2 3 4 5
C) 2 3 4 5 6 6 ✔️
D) 1 1 2 3 4 5

347.What will be the output of the following Python code?
निम्नलिखित पायथन कोड का आउटपुट क्या होगा?
>>>list1 = [1, 3]
>>>list2 = list1
>>>list1[0] = 4
>>>print(list2)
A) [1, 3]
B) [4, 3] ✔️
C) [1, 4]
D) [1, 3, 4]

348.What will be the output of the following Python code?
निम्नलिखित पायथन कोड का आउटपुट क्या होगा?
def f(values):
values[0] = 44
v = [1, 2, 3]
f(v)
print(v)
A) [1, 44]
B) [1, 2, 3, 44]
C) [44, 2, 3] ✔️
D) [1, 2, 3]

349.What will be the output of the following Python code?
निम्नलिखित पायथन कोड का आउटपुट क्या होगा?
def f(i, values = []):
values.append(i)
return values
f(1)
f(2)
v = f(3)
print(v)
A) [1] [2] [3]
B) [1] [1, 2] [1, 2, 3]
C) [1, 2, 3] ✔️
D) 1 2 3

350.What will be the output of the following Python code?
निम्नलिखित पायथन कोड का आउटपुट क्या होगा?
names1 = [‘Amir’, ‘Bala’, ‘Chales’]
if ‘amir’ in names1:
print(1)
else:
print(2)
A) None
B) 1
C) 2 ✔️
D) Error

351.What will be the output of the following Python code?
निम्नलिखित पायथन कोड का आउटपुट क्या होगा?
names1 = [‘Amir’, ‘Bala’, ‘Charlie’]
names2 = [name.lower() for name in names1]
print(names2[2][0])
A) None
B) a
C) b
D) c ✔️

352.To which of the following the “in” operator can be used to check if an item is in it?
निम्न में से किसके लिए “इन” ऑपरेटर का उपयोग यह जांचने के लिए किया जा सकता है कि कोई वस्तु उसमें है?
A) Lists
B) Dictionary
C) Set
D) All of the mentioned ✔️

353.What will be the output of the following Python code?
निम्नलिखित पायथन कोड का आउटपुट क्या होगा?
list1 = [1, 2, 3, 4]
list2 = [5, 6, 7, 8]
print(len(list1 + list2))
A) 2
B) 4
C) 5
D) 8 ✔️

354.What will be the output of the following Python code?
निम्नलिखित पायथन कोड का आउटपुट क्या होगा?
listParam += [1]
mylist = [1, 2, 3, 4]
print(len(mylist))
A) 1
B) 4
C) 5 ✔️
D) 8

355.What will be the output of the following Python code?
निम्नलिखित पायथन कोड का आउटपुट क्या होगा?
def increment_items(L, increment):
i = 0
while i < len(L):
L[i] = L[i] + increment
i = i + 1
values = [1, 2, 3]
print(increment_items(values, 2))
print(values)

A) None ✔️
[3, 4, 5]
B) None
[1, 2, 3]
C) [3, 4, 5]
[1, 2, 3]
D) [3, 4, 5]
None

356.What will be the output of the following Python code?
निम्नलिखित पायथन कोड का आउटपुट क्या होगा?
def example(L):
”’ (list) -> list
”’
i = 0
result = []
while i < len(L):
result.append(L[i])
i = i + 3
return result
A) Return a list containing every third item from L starting at index 0 ✔️
B) Return an empty list
C) Return a list containing every third index from L starting at index 0
D) Return a list containing the items from L starting from index 0, omitting every third item

357.What will be the output of the following Python code?
निम्नलिखित पायथन कोड का आउटपुट क्या होगा?
veggies = [‘carrot’, ‘broccoli’, ‘potato’, ‘asparagus’]
veggies.insert(veggies.index(‘broccoli’), ‘celery’)
print(veggies)
A) [‘carrot’, ‘celery’, ‘broccoli’, ‘potato’, ‘asparagus’] Correct 1.00 ✔️
B) [‘carrot’, ‘celery’, ‘potato’, ‘asparagus’]
C) [‘carrot’, ‘broccoli’, ‘celery’, ‘potato’, ‘asparagus’]
D) [‘celery’, ‘carrot’, ‘broccoli’, ‘potato’, ‘asparagus’]

358.What will be the output of the following Python code?
निम्नलिखित पायथन कोड का आउटपुट क्या होगा?
>>>m = [[x, x + 1, x + 2] for x in range(0, 3)]
A) [[1, 2, 3], [4, 5, 6], [7, 8, 9]]
B) [[0, 1, 2], [1, 2, 3], [2, 3, 4]] ✔️
C) [1, 2, 3, 4, 5, 6, 7, 8, 9]
D) [0, 1, 2, 1, 2, 3, 2, 3, 4]

359.How many elements are in m?
m = [[x, y] for x in range(0, 4) for y in range(0, 4)]
A) 8
B) 12
C) 16 ✔️
D) 32

360.What will be the output of the following Python code?
निम्नलिखित पायथन कोड का आउटपुट क्या होगा?
numbers = [1, 2, 3, 4]
numbers.append([5,6,7,8])
print(len(numbers))
A) 4
B) 5 ✔️
C) 8
D) 12