Test Index
CBSE Class 12 Computer Science 2026 Paper Compartment
© examsnet.com
Question : 7 of 37
Marks:
+1,
-0
Which of the following statements will return the substring
"STR" (i.e. the first 3 characters) from the string "STRING" ?
Solution:
Concept:Slice
s[start:stop:step] takes characters from start up to, but not including, stop. Negative indices count from the end (-1 is the last character).Explanation:Indices of "STRING": S=0, T=1, R=2, I=3 (or -3), N=4, G=5.(A) [:-3] = indices 0 to 2 → "STR" ✔(B) [-3::-1] starts at I and goes backwards → "IRTS"(C) [3:] → "ING"(D) startswith() needs a string argument; startswith(3) gives a TypeError (and it would only return True/False).Answer:Option A ("STRING"[:-3])© examsnet.com
Go to Question: