String indexing and slicing: Class 11 practice
s[i] gives one character (index from 0; negative indices count from the end). The quick answer and an example come first; then the method, worked examples and six graded questions.
String indexing and slicing: quick answer
s[i] gives one character (index from 0; negative indices count from the end). s[a:b] gives characters a up to but not including b; s[a:b:k] steps by k, and s[::-1] reverses.
Example: s = "ALGORITHM". What is s[1:9]? Answer: "LGORITHM".
- Where it is taught: "Strings in Python", Class 11 Computer Science.
- On this page: the method, 3 worked examples and 6 graded questions with a full answer key.
How to use this page (about 30 minutes)
- Read the method once, then cover the worked examples and try them yourself before reading the steps.
- Do the two Basic questions without notes. If either is wrong, re-read the matching worked example.
- Do the Standard and Challenge questions, then check every line of working against the answer key — not only the final answer.
- Write down the mistake behind each wrong answer and redo that question the next day.
What you should know first
- Strings
The idea behind string indexing and slicing
s[i] gives one character (index from 0; negative indices count from the end). s[a:b] gives characters a up to but not including b; s[a:b:k] steps by k, and s[::-1] reverses.
Step-by-step method
- Write the indices under each character.
- Include start, exclude stop.
- Apply the step (negative steps go right to left).
Worked example 1 (Basic)
s = "ALGORITHM". What is s[1:9]?
- Indices 1 to 8
- = "LGORITHM"
- Answer: "LGORITHM"
Worked example 2 (Standard)
s = "ALGORITHM". What is s[2::3]?
- Start at 2, step 3
- = "GIM"
- Answer: "GIM"
Worked example 3 (Challenge)
s = "SCIENCE". What is s[-2:] + s[:2][::-1]?
- s[-2:] = "CE"
- s[:2][::-1] = "CS"
- Answer: "CECS"
Common mistakes and misconceptions
- Including the stop index
- Counting from 1
Practice questions
- (Basic) s = "NETWORKS". What is s[2:5]?
- (Basic) s = "KEYBOARD". What is s[0:6]?
- (Standard) s = "COMPUTER". What is s[0::3]?
- (Standard) s = "COMPUTER". What is s[2::2]?
- (Challenge) s = "NETWORKS". What is s[-5:] + s[:0][::-1]?
- (Challenge) s = "ALGORITHM". What is s[-3:] + s[:2][::-1]?
Answer key with full working
- Q1: Indices 2 to 4 → = "TWO" → Answer: "TWO"
- Q2: Indices 0 to 5 → = "KEYBOA" → Answer: "KEYBOA"
- Q3: Start at 0, step 3 → = "CPE" → Answer: "CPE"
- Q4: Start at 2, step 2 → = "MUE" → Answer: "MUE"
- Q5: s[-5:] = "WORKS" → s[:0][::-1] = "" → Answer: "WORKS"
- Q6: s[-3:] = "THM" → s[:2][::-1] = "LA" → Answer: "THMLA"
Which textbook this practice follows
This skill is taught under "Strings in Python" in Class 11 Computer Science. Check your own textbook's contents page — CBSE, ICSE/ISC and state boards order chapters differently.
Answers on this page are generated and automatically re-checked by a second, independent calculation. They have not been reviewed by a teacher — if you spot a problem, tell us on WhatsApp.
Still stuck after the answer key?
If the same step in string indexing and slicing keeps going wrong, a short live 1 on 1 class can find the exact gap. The first demo class is free; send the class, board and chapter on WhatsApp (+91 9379416374).
Related practice and notes
More Class 11 Computer Science practice
Continue with this syllabus
Frequently asked questions
Which chapter is string indexing and slicing in?
This skill is taught under "Strings in Python" in Class 11 Computer Science. Check your own textbook's contents page — CBSE, ICSE/ISC and state boards order chapters differently.
Which question should I start with?
Start with the Basic questions. Move to Standard only when both Basic answers match the key with the same working; the Challenge questions combine this skill with earlier ones.
How were the answers checked?
Answers on this page are generated and automatically re-checked by a second, independent calculation. They have not been reviewed by a teacher — if you spot a problem, tell us on WhatsApp.
Is this only for CBSE?
The skill names follow NCERT/CBSE, but the method is the same for ICSE, state boards, IGCSE and IB. Only the chapter name and order differ.
Can I get live help with this topic?
Yes. RG's E-Learning teaches live 1 on 1 online classes; the first demo class is free and fees are shared after it.