Question

1.
2.
3.
4.
Answer (Detailed Solution Below)

Option 2 : [20, 30, 40, 50] 4 / [20, 30, 40, 50] 4

Advertisement

Detailed Solution

सही उत्तर [20, 30, 40, 50] 4 / [20, 30, 40, 50] 4 है।

Key Points
Helpful?
PrepSnapprepsnap.in • Part -A

Question:

Consider the following Python code. What is the output? / निम्नलिखित Python कोड पर विचार करें। आउटपुट क्या होगा? nums = [10, 20, 30, 40, 50] out = nums[1:4] + nums[-1:] print(out, len(out))

1.
[20, 30, 40] 3 / [20, 30, 40] 3
2.
[20, 30, 40, 50] 4 / [20, 30, 40, 50] 4
3.
[10, 20, 30, 40] 4 / [10, 20, 30, 40] 4
4.
IndexError / IndexError

Correct Answer: [20, 30, 40, 50] 4 / [20, 30, 40, 50] 4

nums[1:4] is [20, 30, 40] and nums[-1:] is [50]; concatenation gives [20, 30, 40, 50] with length 4. / nums[1:4] = [20, 30, 40] और nums[-1:] = [50] है; जोड़ने पर [20, 30, 40, 50] मिलता है जिसकी लंबाई 4 है।

Downloaded from PrepSnap (prepsnap.in)