निम्नलिखित कोड का परिणाम क्या है ?
What is the output of the following code ?
ms = ('A', 'D', 'H', 'U', 'N', 'I', 'C')
print(ms[1:4])
A)
B)
C)
D)
Explanation:
Sure! Here's a quick breakdown:
-
Tuple
ms
:ms = ('A', 'D', 'H', 'U', 'N', 'I', 'C')
It contains 7 elements:
'A', 'D', 'H', 'U', 'N', 'I', 'C'
. -
Slicing
ms[1:4]
:- This gets elements from index 1 to 3 (the 4th element is excluded).
- Index 1 =
'D'
- Index 2 =
'H'
- Index 3 =
'U'
So, ms[1:4]
gives ('D', 'H', 'U')
.
Answer: (A) ('D', 'H', 'U').