MCQ Answer

<p>What will be the output of the following Python code?</p><pre><span style="font-size: 14px;">a= [1, 2, 3, 4, 5]<br></span><span style="font-size: 14px;">for i in range(1, 5):<br></span><span style="font-size: 14px;">&nbsp; &nbsp; a[i-1] = a[i]<br></span><span style="font-size: 14px;">for i in range(0, 5):<br></span><span style="font-size: 14px;">&nbsp; &nbsp; print(a[i],end = " ")</span></pre><div><br></div>

What will be the output of the following Python code?

a= [1, 2, 3, 4, 5]
for i in range(1, 5):
    a[i-1] = a[i]
for i in range(0, 5):
    print(a[i],end = " ")



निम्नलिखित Python कोड का आउटपुट क्या होगा?

a= [1, 2, 3, 4, 5]
for i in range(1, 5):
    a[i-1] = a[i]
for i in range(0, 5):
    print(a[i],end = " ")
Topic : Sequence data types in python

A. 5 5 1 2 3

B. 5 1 2 3 4

C. 2 3 4 5 1

D. 2 3 4 5 5




Correct Answer is :

D. 2 3 4 5 5



Explanation
The items having indexes from 1 to 4 are shifted forward by one index due to the first for-loop and the item of index four is printed again because of the second for-loop.
Online Exam Quiz for One day Exam Online Typing Test CCC Online Test 2026 Best Computer Training Institute in Prayagraj (Allahabad) Best Java Training Institute in Prayagraj (Allahabad) Best Python Training Institute in Prayagraj (Allahabad) O Level Online Test in Hindi Best Website and Software Company in Allahabad