Read and download free pdf of CBSE Class 12 Computer Science Python Worksheet. Download printable Computer Science Class 12 Worksheets in pdf format, CBSE Class 12 Computer Science Python Worksheet has been prepared as per the latest syllabus and exam pattern issued by CBSE, NCERT and KVS. Also download free pdf Computer Science Class 12 Assignments and practice them daily to get better marks in tests and exams for Class 12. Free chapter wise worksheets with answers have been designed by Class 12 teachers as per latest examination pattern
Python Computer Science Worksheet for Class 12
Class 12 Computer Science students should refer to the following printable worksheet in Pdf in Class 12. This test paper with questions and solutions for Class 12 Computer Science will be very useful for tests and exams and help you to score better marks
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)
Please click on below link to download CBSE Class 12 Computer Science Python Worksheet
CBSE Class 12 Computer Science Python Worksheet
The above practice worksheet for Python has been designed as per the current syllabus for Class 12 Computer Science released by CBSE. Students studying in Class 12 can easily download in Pdf format and practice the questions and answers given in the above practice worksheet for Class 12 Computer Science on a daily basis. All the latest practice worksheets with solutions have been developed for Computer Science by referring to the most important and regularly asked topics that the students should learn and practice to get better scores in their examinations. Studiestoday is the best portal for Printable Worksheets for Class 12 Computer Science students to get all the latest study material free of cost.
Worksheet for Computer Science CBSE Class 12 Python
Teachers of studiestoday have referred to the NCERT book for Class 12 Computer Science to develop the Computer Science Class 12 worksheet. If you download the practice worksheet for the above chapter daily, you will get better scores in Class 12 exams this year as you will have stronger concepts. Daily questions practice of Computer Science printable worksheet and its study material will help students to have a stronger understanding of all concepts and also make them experts on all scoring topics. You can easily download and save all revision Worksheets for Class 12 Computer Science also from www.studiestoday.com without paying anything in Pdf format. After solving the questions given in the practice sheet which have been developed as per the latest course books also refer to the NCERT solutions for Class 12 Computer Science designed by our teachers
Python worksheet Computer Science CBSE Class 12
All practice paper sheet given above for Class 12 Computer Science have been made as per the latest syllabus and books issued for the current academic year. The students of Class 12 can be assured that the answers have been also provided by our teachers for all test paper of Computer Science so that you are able to solve the problems and then compare your answers with the solutions provided by us. We have also provided a lot of MCQ questions for Class 12 Computer Science in the worksheet so that you can solve questions relating to all topics given in each chapter. All study material for Class 12 Computer Science students have been given on studiestoday.
Python CBSE Class 12 Computer Science Worksheet
Regular printable worksheet practice helps to gain more practice in solving questions to obtain a more comprehensive understanding of Python concepts. Practice worksheets play an important role in developing an understanding of Python in CBSE Class 12. Students can download and save or print all the printable worksheets, assignments, and practice sheets of the above chapter in Class 12 Computer Science in Pdf format from studiestoday. You can print or read them online on your computer or mobile or any other device. After solving these you should also refer to Class 12 Computer Science MCQ Test for the same chapter.
Worksheet for CBSE Computer Science Class 12 Python
CBSE Class 12 Computer Science best textbooks have been used for writing the problems given in the above worksheet. If you have tests coming up then you should revise all concepts relating to Python and then take out a print of the above practice sheet and attempt all problems. We have also provided a lot of other Worksheets for Class 12 Computer Science which you can use to further make yourself better in Computer Science
You can download the CBSE Practice worksheets for Class 12 Computer Science Python for the latest session from StudiesToday.com
Yes, you can click on the links above and download chapter-wise Practice worksheets in PDFs for Class 12 for Computer Science Python
Yes, the Practice worksheets issued for Python Class 12 Computer Science have been made available here for the latest academic session
You can easily access the links above and download the Class 12 Practice worksheets Computer Science for Python
There is no charge for the Practice worksheets for Class 12 CBSE Computer Science Python you can download everything free
Regular revision of practice worksheets given on studiestoday for Class 12 subject Computer Science Python can help you to score better marks in exams
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
Yes, studiestoday provides worksheets in Pdf for Python Class 12 Computer Science in mobile-friendly format and can be accessed on smartphones and tablets.
Yes, practice worksheets for Class 12 Computer Science Python are available in multiple languages, including English, Hindi