CBSE Class 12 Computer Science Python Worksheet

Access the latest CBSE Class 12 Computer Science Python Worksheet. We have provided free printable Class 12 Computer Science worksheets in PDF format, specifically designed for Python. These practice sets are prepared by expert teachers following the 2025-26 syllabus and exam patterns issued by CBSE, NCERT, and KVS.

Python Computer Science Practice Worksheet for Class 12

Students should use these Class 12 Computer Science chapter-wise worksheets for daily practice to improve their conceptual understanding. This detailed test papers include important questions and solutions for Python, to help you prepare for school tests and final examination. Regular practice of these Class 12 Computer Science questions will help improve your problem-solving speed and exam accuracy for the 2026 session.

Download Class 12 Computer Science Python Worksheet PDF

1. Strings A sequence of characters is called string.
Strings are used by programming languages to manipulate text such as words and sentences.
Strings literal in Python are enclosed by double quotes or single quotes. String literals can be span multiple lines, to write these strings triple quotes ‘‘‘ ’’’ are used.

(i) Accessing Values in Strings Each individual character in a string can be assessed using a technique called indexing. The index specifies the character to be accessed in the string and is written in square brackets [].

(ii) String Slicing To access some part of a string or substring, we use a method called slicing.
This can be done by specifying an index range.
Slice operation is performed on string with the use of colon (:). string_name [start : stop]

(iii) Traversing a String Traversing is a technique to iterate the character of string, one character at a time. It just means to process every character in a string, usually from left end to right end.

(iv) String Operators

(a) Basic Operators

• String Concatenation Operator (+) String concatenation is the technique of combining two strings. The ‘+’ operator is used for string concatenation.

• String Replication Operator (*)Python allows us to repeat the given string using repetition operator which is denoted by symbol (*). Asterisk sign (*) when used with numeric data type it performs multiplication operation, but when this sign is used with one string and one number, it performs string replication operation.

(b) Comparison Operators These operators are also called relational operators in Python that compare the values of two string operands and return True or False based on whether the condition is met.
Python string comparison can be performed using comparison operators (= =, >, <, !=, < =, >=).

(c) Membership Operators These operators are used to validate the membership of a value in a string. These operators are used to find out whether a value is a member of a string or not.
There are two membership operators for strings in Python as follows

• in Operator This operator is used to check if a value exists in a sequence or not. It evaluates True if it finds a variable in the specified sequence and False otherwise.

• not in Operator This operator is the opposite of ‘in’ operator. So, if a value does not exist in the sequence, then it will return a True else it will return a False.

(d) Identity Operator In Python, identity operators are used to determine whether a value is of a certain class or type.

There are two types of identity operators as

• is Operator This operator returns True if both the operands point to same memory location.

• is not Operator This operator returns True if both the operands point to different memory location.

2. Lists In Python, list is an ordered sequence, which is used to store multiple data at the same time.
List contains a sequence of heterogeneous elements which store integer, string as well as object.
In Python, lists can be created to put the elements separated by the comma ( ,) in square brackets [ ].

(i) Accessing Lists To access the list’s elements, index number is used. Use the index operator [ ] to access the elements of a list. The index should be an integer. Index 0 refers to first element, 1 refers to second element and so on.
While the index of -1 refers to the last element, -2 refers to the second last element and so on.

(ii) Traversing a List Traversing a list is a technique to access an individual element of that list. It is also called iterate over a list.

3. Tuples A tuple is an ordered sequence of elements of different data types, such as integer, float, string, list or even a tuple. Tuple holds a sequence of heterogeneous elements, it stores a fixed set of elements and do not allow changes. 

• To create a tuple in Python, put all the elements in a parentheses ( ), separated by commas. We can have tuple of same type of data items as well as mixed type of data items.

• A tuple can contain sub-tuple which in turn can contain sub-tuples themselves and so on. This is known as nested tuple.

• Packing and Unpacking Tuples In Python, tuples are collection of elements which are separated by commas. It packs elements or value together so, this is called packing. In other way, it is called unpacking of a tuple of values into a variable. In packing, we put values together into a new tuple while in unpacking we extract those values into a single variable.

4. Dictionary In Python, dictionary is an unordered collection of data values that store the key : value pair instead of single value as an element. Keys of a dictionary must be unique and of immutable data types such as strings, tuples etc.

• To create a dictionary in Python, key : value pair is used. Dictionary is list in curly brackets, inside these curly brackets, keys and values are declared.

5. Debugging Programs The process of identifying and removing such mistakes (also known as bugs or errors) from a program is called debugging.

(i) Error An error is a flaw, fault or failure in a computer program that causes it to produce an incorrect or unexpected result or to behave in unintended ways.

Some common form of program errors are as given below

(a) Compile-time Errors All the errors that are detected and displayed by the compiler or interpreter are known as compile-time errors.
There are two categories of compile-time errors as follows

• Syntax Error When a formal set of rules defined for writing a program in a particular language, is not followed then error raised is known as syntax error.

• Semantic Error A programming error that arises from a misunderstanding of the meaning or effect of some construct in a programming language is known as semantic error.

(b) Run-time Errors In a program, a run-time error is an error that occurs while program is running after being successfully compiled. It is caused by some illegal operations taking place or inavailability of desired or required conditions for the execution of program.

(c) Logical Errors Logical errors occur when the program does not give any error but still gives an incorrect output. These errors occur due to mistakes of the programmer.

(ii) Python Exception An exception can be defined as an abnormal condition in a program resulting in the disruption to the flow of the program.

(iii) Exception Handling Exception handling is a construct in some programming languages to handle or deal with errors automatically.
 

Direction (Q. Nos. 1-15) Each of the question has four options out of which only one is correct.

Select the correct option as your answer.

1. Which of the following is/are example(s) of logical error?
(a) Identing a block to the wrong level
(b) Getting operator precedence wrong
(c) Making a mistake in a boolean expression
(d) All of these
Answer : D

2. Which of the following is false?
(a) String is mutable.
(b) capitalize() function in string is used to return a string by converting first character of
the string into uppercase.
(c) lower() function in string is used to return a string by converting the whole given string
into lowercase.
(d) None of the above
Answer : A

3. Choose the correct option with respect to Python.
(a) Both tuples and lists are immutable.
(b) Tuples are immutable while lists are mutable.
(c) Both tuples and lists are mutable.
(d) Tuples are mutable while lists are immutable.
Answer : B

4. Which of the following will result in an error?
str1=“hello”
(a) print(str1[1])
(b) str1[2]=“a”
(c) print(str1[0:7])
(d) Both (b) and (c)
Answer : B

5. Syntax error in python is detected by................. at .............. .
(a) compiler, compile time
(b) interpreter, run-time
(c) compiler, run-time
(d) interpreter, compile time
Answer : B

6. Suppose list1 is [2, 33, 222, 14, 25], what is list1[−1] ?
(a) Error
(b) None
(c) 25
(d) 2
Answer : C

7. Suppose list1 is [3,5, 25, 1, 3], what is min(list1) ?
(a) 3
(b) 5
(c) 25
(d) 1
Answer : D

8. Which of the following option will not result in an error when performed on tuple in
Python, where tup1=(5, 6, 8, 9)?
(a) tup1[1]=12
(b) tup1.append(2)
(c) tup=tup1+tup1
(d) tup1.sort()
Answer : C

9. dic1={“A”:15,“B”:16,“C”:17}
print(dic1[1])
What will be the output of above Python code?
(a) B
(b) 16
(c) {“B”:16}
(d) Error
Answer : D

10. What will be the output of below Python code?
tup1=(1, 2, 3)
tup=tup1*2
print(tup)
(a) (2,4,6)
(b) (1,2,3,1,2,3)
(c) (1,1,2,2,3,3)
(d) Error
Answer : B

11. Which of the following two Python codes will give same output?
If tup1=(1, 2, 3, 4, 5)
(i) print(tup1[:-1]) (ii) print(tup1[0:5])
(iii) print(tup1[0:4]) (iv) print(tup1[-4:])
(a) i, ii
(b) ii, iv
(c) ii, v
(d) i, iii
Answer : B

12. What will be the output of the following Python code?
x=[1, 3, 6, [18]]
y=list(x)
x[3][0]=15
x[1]=12
print(y)
(a) [1,3,6, [15]]
(b) [1,3,6,[12]]
(c) [1,3,15,[18]]
(d) [1,12,15,[18]]
Answer : A

13. What will be the output of the following Python code?
num = { }
num[(1,3,5)] = 18
num[(5,3,1)] = 16
num|(1,3)] = 22
sum = 0
for i in num:
sum += num[i]
print(len(num) + sum)
(a) 54
(b) 38
(c) 33
(d) 59
Answer : D

14. What will be the output of following Python code?
list1=[1,2,3,4,5]
str1=“6”
for i in list1:
str1=str1+i
print(str1)
(a) 654321
(b) 123456
(c) 123645
(d) Error
Answer : D

15. What will be the output of following Python code?
dict1={“A”:15,“B”:23,“C”:21}
str1=“ ”
for i in dict1:
str1=str1+str(dict1[i])+“ ”
str2=str1[:−1]
print(str2[::−1])
(a) 12 32 51
(b) 12 32 15
(c) 32 21 15
(d) Error
Answer : A

 

Multiple Choice Questions

Question. Which of the following is not a keyword?
a) Eval
b) assert
c) nonlocal
d) pass
Answer. A

Question. What is the order of precedence in python?
(i) Parentheses
ii) Exponential
iii) Multiplication
iv) Division
v) Addition
vi) Subtraction
a) i,ii,iii,iv,v,vi
b) ii,i,iii,iv,v,vi
c) ii,i,iv,iii,v,vi
d) i,ii,iii,iv,vi,v
Answer. A

Question. What error occurs when you execute the following Python code snippet? apple = mango
a) SyntaxError
b) NameError
c) ValueError
d) TypeError
Answer. B

Question. Find the output.
def example
(a): a = a+2
a=a*2
return a
>>>example("hello")
a. indentation Error
b. cannot perform mathematical operation on strings
c. hello2
d. hello2hello2
Answer. A

Question. What will be the value of X in the following Python expression? X = 2+9*((3*12)-8)/10
a) 30.0
b) 30.8
c) 28.4
d) 27.2
Answer. D

Question. Select all options that print. hello-how-are-you
a. print(‘hello’, ‘how’, ‘are’, ‘you’)
b. print(‘hello’, ‘how’, ‘are’, ‘you’ + ‘-‘ * 4)
c. print(‘hello-‘ + ‘how-are-you’)
d. print(‘hello’ + ‘-‘ + ‘how’ + ‘-‘ + ‘are’ + ‘you’)
Answer. C

Question. Which of the following can be used as valid variable identifier(s) in Python?
a. total
b. 7Salute
c. Que$tion
d. global
Answer. A

Question. Which of the following statement is correct for an AND operator?
a) Python only evaluates the second argument if the first one is False
b) Python only evaluates the second argument if the first one is True
c) Python only evaluates True if any one argument is True
d) Python only evaluates False if any one argument is False
Answer. B

Question. Which of the following forces an expression to be converted into specific type?
a) Implicit type casting
b) Mutable type casting
c) Immutable type casting
d) Explicit type casting
Answer. D

Question. Which point can be considered as difference between string and list?
a. Length
c. Indexing and Slicing
b. Mutability
d. Accessing individual elements
Answer. B

Question. Which of the following statement is true for extend () list method?
a) adds element at last
c) adds multiple elements at last
b) adds element at specified index
d) adds elements at random index
Answer. B

Question. The statement del l[1:3] do which of the following task?
a) delete elements 2 to 4 elements from the list b) delete 2nd and 3rd element from the list c)deletes 1st and 3rd element from the list d)deletes 1st, 2nd and 3rd element from the list 13.If l=[11,22,33,44], then output of print(len(l)) will be
a)4
b)3
c) 8
d) 6
Answer. B

Question. Which of the following method is used to delete element from the list?
a) del()
b) delete()
c) pop()
d) All of these
Answer. A

Question. The step argument in range() function .
a. indicates the beginning of the sequence
b. indicates the end of the sequence
c. indicates the difference between every two consecutive numbers in the sequence
d. generates numbers up to a specified value
Answer. D


Very Short Answer Type Questions

Question. Give the output of the following
Sum = 0
for k in range(5):
Sum = Sum+k
print(Sum)
Answer. 10

Question. Give the output of the following
Sum = 0
for k in range(10 , 1, -2):
Sum = Sum+k
print(Sum)
Answer. 30

Question. Give the output of the following
for k in range(4):
for j in range(k):
print(‘*’, end = ‘ ‘) print()
Answer. 
*
* *
* * *

Question. Give the output of the following 
for k in range(5,0, -1):
for j in range(k):
print(‘*’, end=’ ‘) print()
Answer. 
* * * * *
* * * *
* * *
* *
*

Question. How many times the following loop will execute?
Justify your answer
A = 0 while True:
print(A)
A =A+1
Answer. infinite loop. Condition / test expression is always Ture.

Question. Give the output of the following.
Also find how many times the loop will execute.
A = 0
while A<10:
print(A, ‘ , ‘)
A =A+1
Answer. 0,1,2,3,4,5,6,7,8,9

Question. Give the output of the following. Also find how many times the loop will execute.
A = 0 while
A<10:
print(A, ‘ , ‘)
A =A+1
print(‘\n’, A)
Answer. 0,1,2,3,4,5,6,7,8,9
10

Question. Give the output of the following
T = (5) T =
T*2
print(T)
Answer. 10 Note: here T is an integer

9. Give the output of the following
T = (5, )
T = T*2
print(T)
Answer. (5, 5), Note: here T is tuple

Question. What kind of error message will be generated if the following code is executed
A = 5
B = ‘hi’
d = A+B
print(D)
Answer. TypeError

Question. Give the output of the following
L = [1,2,3,4,5,6,7,8,9]
print(L[:])
Answer. [1,2,3,4,5,6,7,8,9]

Question. Give the output of the following
L = [1,2,3,4,5,6,7,8,9]
print(L[: -1])
Answer. [1,2,3,4,5,6,7,8]

Question. Find the output of the following
S = ‘abcdefgh’
L = list(S)
print(L[1:4])
Answer. ['b', 'c', 'd']

Question. Give the output of the following
L = [1,2,3,4,5,6,7,8,9]
print(L.count(2))
print(L.index(2)
Answer. 
1
1

Question. Write python code to sort the list, L, in descending order.
Answer. L.sort(reverse= True)

Question. Give the output of the following
x=[4,5,66,9]
y=tuple(x)
print( y)
Answer. (4, 5, 66, 9)

 
LAB WORKSHEET 
 
1 Create a dictionary containing names of competition winner students as keys and number of their wins as values.
 
2 Write a python code that prints the longest word in a list of words.
 
3 Write a python program that creates a tuple storing first 15 terms of Fibonacci series.
 
4 Write a program to sort a list in ascending order using bubble sort and sort a list in descending order using insertion sort
 
5 Write a program to show entered string is a palindrome or not
 
6 Write a program to show statistics of characters in the given line(to counts the number of alphabets ,digits, uppercase,lowercase,spaces and other characters)
 
7 WAP to remove all odd numbers from the given list.
 
8 Write a program to display frequencies of all the element of a list
 
9 Write a program to display those string which are starting with ‘A’ from the given list.
 
10 Write a program to find and display the sum of all the values which are ending with 3 from a list

 

Please click on below link to download CBSE Class 12 Computer Science Python Worksheet

Python CBSE Class 12 Computer Science Worksheet

Students can use the Python practice sheet provided above to prepare for their upcoming school tests. This solved questions and answers follow the latest CBSE syllabus for Class 12 Computer Science. You can easily download the PDF format and solve these questions every day to improve your marks. Our expert teachers have made these from the most important topics that are always asked in your exams to help you get more marks in exams.

NCERT Based Questions and Solutions for Python

Our expert team has used the official NCERT book for Class 12 Computer Science to create this practice material for students. After solving the questions our teachers have also suggested to study the NCERT solutions  which will help you to understand the best way to solve problems in Computer Science. You can get all this study material for free on studiestoday.com.

Extra Practice for Computer Science

To get the best results in Class 12, students should try the Computer Science MCQ Test for this chapter. We have also provided printable assignments for Class 12 Computer Science on our website. Regular practice will help you feel more confident and get higher marks in CBSE examinations.

Where can I download latest CBSE Practice worksheets for Class 12 Computer Science Python

You can download the CBSE Practice worksheets for Class 12 Computer Science Python for the latest session from StudiesToday.com

Are the Class 12 Computer Science Python Practice worksheets available for the latest session

Yes, the Practice worksheets issued for Python Class 12 Computer Science have been made available here for the latest academic session

Is there any charge for the Practice worksheets for Class 12 Computer Science Python

There is no charge for the Practice worksheets for Class 12 CBSE Computer Science Python you can download everything free

How can I improve my scores by solving questions given in Practice worksheets in Python Class 12 Computer Science

Regular revision of practice worksheets given on studiestoday for Class 12 subject Computer Science Python can help you to score better marks in exams

Are there any websites that offer free Practice test papers for Class 12 Computer Science Python

Yes, studiestoday.com provides all the latest Class 12 Computer Science Python test practice sheets with answers based on the latest books for the current academic session