Worksheets › Class 12 › Python Revision
Class 12 · Computer Science worksheetPython 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.
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.
Which of these Python types is immutable?
- dictionary
- set
- list
- tuple
Answer
(d) tuple
- 2.
What does this print? s = 'SCHEDULE' print(s[3:])
- ELUDE
- SCHEDU
- EDULE
- EUE
Answer
(c) EDULE
count indices from 0; the stop index is not included
- 3.
What does this print? s = 'data never sleeps at night' print(s.capitalize())
- Data never sleeps at night
- DATA NEVER SLEEPS AT NIGHT
- data never sleeps at night
- 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
- 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 ( ).
- 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
- 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.