School Revise · Class 11 Computer Science · Chapter 8
Code 083, Class 11. A string is text in quotes. Here we index and slice strings, join and repeat them, and use handy string methods.
|
|
A string is a sequence of characters written in quotes. In this chapter we read parts of a string, join and repeat strings, and use built-in string methods.
Each character has an index, starting at 0. s[0] is the first character and s[-1] is the last. A slice s[a:b] gives characters from a up to, but not including, b.
|
s = “Python” print(s[0], s[-1]) print(s[0:3]) Output: P n Pyt |
The + sign joins (concatenates) strings and the * sign repeats a string. len(s) gives the number of characters.
Strings have useful methods: upper() and lower() change case, replace(x, y) swaps text, split() breaks a sentence into words, and strip() removes spaces at the ends. Strings are immutable, so a method returns a new string.
Explore the idea by tapping. The interactive opens right here in the lesson.
Write and run real Python right here in the lesson, then work through the practice problems with answers.
Type each one into the code lab above, then open the card to see the worked solution and its output.
SOLUTION
OUTPUT
SOLUTION
OUTPUT
SOLUTION
OUTPUT
SOLUTION
OUTPUT
SOLUTION
OUTPUT
SOLUTION
OUTPUT
SOLUTION
OUTPUT
SOLUTION
OUTPUT
SOLUTION
OUTPUT
SOLUTION
OUTPUT
0.
abab.
upper().
No, strings are immutable, so methods return a new string.
|
A string is text in quotes. Indexing starts at 0, and s[-1] is the last character; a slice s[a:b] stops before b. The + sign joins strings and * repeats them, and len() counts characters. Methods like upper(), lower(), replace(), split() and strip() return new strings, because strings are immutable. |
| Open the Virtual Lab |
These free Class 11 Computer Science notes explain strings, indexing and slicing, concatenation and repetition, and string methods with worked Python programs and practice, for CBSE students across India and the Gulf including the UAE, Saudi Arabia, Qatar, Oman, Kuwait and Bahrain.
© 2026 School Revise. All rights reserved. Original content aligned to the CBSE and NCERT Class 11 Computer Science syllabus. Unauthorised copying is not permitted.