Worksheets › Class 12 › Python Revision

Class 12 · Computer Science worksheet

Python Revision

CBSE Computer Science. Strings and slicing, string methods, list, tuple and dictionary operations, loops over strings and nested lists, traced to the exact output. 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.

    Which of these Python types is immutable?

    1. dictionary
    2. set
    3. list
    4. tuple
    Answer

    (d) tuple

  2. 2.

    What does this print? s = 'SCHEDULE' print(s[3:])

    1. ELUDE
    2. SCHEDU
    3. EDULE
    4. EUE
    Answer

    (c) EDULE

    count indices from 0; the stop index is not included

  3. 3.

    What does this print? s = 'data never sleeps at night' print(s.capitalize())

    1. Data never sleeps at night
    2. DATA NEVER SLEEPS AT NIGHT
    3. data never sleeps at night
    4. Data Never Sleeps At Night
    Answer

    (a) Data never sleeps at night

    capitalize() changes only the first character of the string

Section B · short answer

  1. 4.

    What is the difference between a list and a tuple?

    Answer

    A list is mutable (its items can be changed, added or removed) and is written in [ ]; a tuple is immutable and is written in ( ).

  2. 5.

    What does this print? s = 'MOUNTAIN' print(s[3::2])

    Answer

    NAN

    count indices from 0; the stop index is not included

Section C · long answer

  1. 6.

    Explain indexing and slicing of strings with examples, including negative indices.

    Answer

    Characters are numbered from 0 at the left and from −1 at the right. s[i] gives one character; s[a:b] gives the characters from a up to b − 1; s[a:b:k] takes every kth one; s[::−1] reverses. For s = 'PYTHON', s[1:4] is 'YTH', s[−2:] is 'ON'.

    indices, slices with start/stop/step, negative indices, examples

Fresh sheets for your child

In the app, every Python Revision 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 12 Computer Science