Worksheets › Class 11 › Strings

Class 11 · Computer Science worksheet

Strings

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.

Open a printable sample sheet

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. 1.

    Strings in Python are:

    1. stored as numbers only
    2. limited to 255 characters
    3. mutable like lists
    4. immutable: their characters cannot be changed in place
    Answer

    (d) immutable: their characters cannot be changed in place

  2. 2.

    What does this program print? s = 'banana' print(s[-5:])

    1. banana
    2. aa
    3. nana
    4. anana
    Answer

    (d) anana

    start is included, stop is not; a negative index counts from the end

  3. 3.

    What does this program print? s = 'lamp Data' print(s.upper())

    1. lamp Data
    2. lamp data
    3. Lamp data
    4. LAMP DATA
    Answer

    (d) LAMP DATA

    upper() changes every letter to a capital

Section B · short answer

  1. 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:].

  2. 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

  1. 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.

More Class 11 Computer Science