'abcdefg'[2:5] का output क्या होगा?
What is the output of 'abcdefg'[2:5]?
A
cde
B
def
C
bcd
D
cd
Explanation
Python में slicing का syntax होता है:
यहाँ:
-
startindex से शुरू होता है (include होता है), -
लेकिन
endindex तक नहीं जाता (exclude होता है)।
उदाहरण:
-
Index 2 →
'c' -
Index 3 →
'd' -
Index 4 →
'e' -
Index 5 → excluded
इसलिए output होगा: 'cde'
Correct Answer: A) cde