Worksheets › Class 11 › Strings
Class 11 · Computer Science worksheetStrings
CBSE Computer Science. Indexing and slicing, concatenation, repetition and membership, traversal, and the string methods from len() and title() to partition() and split(). Every sheet has 20 questions in three sections and an answer key, and the questions change every time.
Sample questions
Real questions from this chapter, as the app sets them. Tap Answer to see the answer and working.
Section A · multiple choice
- 1.
Strings in Python are:
- stored as numbers only
- limited to 255 characters
- mutable like lists
- immutable: their characters cannot be changed in place
Answer
(d) immutable: their characters cannot be changed in place
- 2.
What does this program print? s = 'banana' print(s[-5:])
- banana
- aa
- nana
- anana
Answer
(d) anana
start is included, stop is not; a negative index counts from the end
- 3.
What does this program print? s = 'lamp Data' print(s.upper())
- lamp Data
- lamp data
- Lamp data
- LAMP DATA
Answer
(d) LAMP DATA
upper() changes every letter to a capital
Section B · short answer
- 4.
What is meant by saying that strings are immutable? Give an example.
Answer
A string cannot be changed in place: s[0] = 'X' is a TypeError; a new string must be made, e.g. s = 'X' + s[1:].
- 5.
What does this program print? Give (a) the first line (b) the second. s = 'science' print(s[:-4]) print(s[::-1])
Answer
(a) sci; (b) ecneics
index: s0 c1 i2 e3 n4 c5 e6
Section C · long answer
- 6.
Explain the string operations of concatenation, repetition, membership and slicing with an example of each.
Answer
'ab' + 'cd' = 'abcd'; 'ab' * 2 = 'abab'; 'b' in 'abc' is True; 'python'[1:4] = 'yth'.
Fresh sheets for your child
In the app, every Strings sheet is new: the app remembers the questions your child has already had and leaves them out. Print the sheet as a PDF, or use notebook mode and write the answers in a notebook.
Coming soon for Android and iPhone.