Report Bug

Qus

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)  r
Qusनिम्नलिखित Python कोड का आउटपुट क्या होगा?


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]


Solution
A. [11, 12, 13, 14, 15, 16, 17, 18, 19, 10, 20, 30, 40, 50, 60, 70, 80, 90]



Explanation
The code shown above adds 10 to each element of the matrix and prints the output row-wise. Since the list l already contains some elements, the new elements are appended to it. Hence the output of this code is: [11, 12, 13, 14, 15, 16, 17, 18, 19, 10, 20, 30, 40, 50, 60, 70, 80, 90].
CCC Online Test Python Programming Tutorials Best Computer Training Institute in Prayagraj (Allahabad) Online Exam Quiz O Level NIELIT Study material and Quiz Bank SSC Railway TET UPTET Question Bank career counselling in allahabad Best Website and Software Company in Allahabad Website development Company in Allahabad