Computer Science Class 12th (XII) Sample Exam Paper 1
Computer Science Class 12th (XII) Sample Exam Paper 1
General Instructions:
Please check this question paper contains 35 questions.
The paper is divided into 5 Sections- A, B, C, D and E.
Section A, consists of 18 questions (1 to 18). Each question carries 1 Mark.
Section B, consists of 7 questions (19 to 25). Each question carries 2 Marks.
Section C, consists of 5 questions (26 to 30). Each question carries 3 Marks.
Section D, consists of 2 questions (31 to 32). Each question carries 4 Marks.
Section E, consists of 3 questions (33 to 35). Each question carries 5 Marks.
All programming questions are to be answered using Python Language only.
a. per%marks
b. _for
c. While
d. true
2 What is the correct way to add an element to the end of a list in 1
Python?
a. list.add(element)
b. list.append(element)
c. list.insert(element)
d. list.extend(element)
3 What will be the output of 1
print("Welcome To My Blog"[2:6] + "Welcome To My
Blog"[5:9])
a. Lcomme
b. lcomme T
c. lcomme To
d. lcomme
4 Which of the following statements is false? 1
a. Statement 1
b. Statement 2
c. Statement 3
d. Statement 4
6 Which pickle module method is used to write a Python object to a 1
binary file?
a. save()
b. serialize()
c. store()
d. dump()
7 Given the following dictionaries 1
dict_student = {"rno" : "53", "name" : 'Rajveer Singh'}
dict_marks = {"Accts" : 87, "English" : 65}
a. dict_student + dict_marks
b. dict_student.add(dict_marks)
c. dict_student.merge(dict_marks)
d. dict_student.update(dict_marks)
8 Which of the following is not a component of the math module in 1
Python?
a. ceil()
b. mean()
c. fabs()
d. pi
9 What will be the output of the following code? 1
L=["One , Two", "Three", "Four"]
print(len(L)/2*len(L[0]))
a. 6.5
b. 13
c. 13.5
d. 6.0
10 Expand the following terms: 1
(i) PPP
(ii) VoIP
11 Which SQL operator performs pattern matching? 1
a. BETWEEN operator
b. LIKE operator
c. EXISTS operator
d. =
2
12 Which Python function is used for displaying only one result set from 1
SQL table in a database?
a. fetch1()
b. fetchno()
c. fetchall()
d. fetchone()
13 Which of the following file opening mode in Python, generates an 1
error if the file does not exist?
a. a
b. r
c. w
d. w+
14 The correct syntax of seek() is: 1
a. file_object.seek(offset [, reference_point])
b. seek(offset [, reference_point])
c. seek(offset, file_object)
d. seek.file_object(offset)
15 Which of the following statements is false? 1
a. FTP
b. PPP
c. Telnet
d. SMTP
Q17 and 18 are ASSERTION AND REASONING based questions.
Mark the correct choice as
(a) Both A and R are true and R is the correct explanation for A
(b) Both A and R are true and R is not the correct explanation for A
(c) A is True but R is False
(d) A is false but R is True
17 Assertion (A): For changes made to a variable defined within a 1
function to be visible outside the function, it should be declared as
global.
Reasoning (R): Variables defined within a function are local to that
function by default, unless explicitly specified with the global
keyword.
18 Assertion (A): A binary file in python is used to store collection 1
objects like lists and dictionaries that can be later retrieved in their
original form using pickle module.
3
Reasoning (A): Binary files are just like normal text files and can be
read using a text editor like Notepad.
Q No. Questions Marks
Section-B (14 Marks)
19 Write two advantages and two disadvantages of circuit switching. 2
OR
Differentiate between Web server and web browser. Write the names
of any two web browsers.
20 Rewrite the following code in Python after removing all the syntax 2
errors. Underline each correction done in the code.
L = [5,10,15,1]
G = 4
def Change(X):
global G
N=len(X)
for i in range(N):
X[i] += G
Change(L)
for i in L:
print(i,end='$')
4
23 Write a suitable Python statement for each of the following tasks 2
using built-in functions/methods only:
i To delete an element Mumbai:50 from Dictionary D.
ii To display words in a string S in the form of a list
OR
Write a Python Program to display alternate characters of a string
my_str.
For example, if my_str = "Computer Science"
The output should be Cmue cec
24 Differentiate between % (percentage) and _(underscore) characters 2
used with the LIKE operator in SQL with appropriate examples.
OR
Differentiate between DROP and DELETE commands in SQL with
appropriate examples.
25 Consider the following two commands with reference to a table, 2
named Employee having a column named Department:
(a) Select count(Department) from Employee;
(b) Select count(*) from Employee;
TABLE : BOOK
CODE BNAME TYPE
F101 The priest Fiction
L102 Easy Python Programming
C101 Juman Ji Thriller
F102 Untold Story Fiction
C102 War Stories Comic
Table: MEMBER
MNO MNAME CODE ISSUEDATE
M101 SNEH SINHA L102 2022-10-13
M103 SARTHAK F102 2021-02-23
M102 SARA KHAN C101 2022-06-12
(b) Write the output of the queries (i) to (iv) based on the table
Table: Employee
EID Name DOB DOJ Salary Project
E01 Ranjan 1990-07-12 2015-01-21 150000 P01
E02 Akhtar 1992-06-21 2015-02-01 125000 P04
E03 Muneera 1996-11-15 2018-08-19 135000 P01
E04 Alex 1991-10-25 2018-10-19 75000 P02
E05 Satyansh 1993-12-16 2018-10-19 85000 P04
5
i SELECT NAME, PROJECT FROM EMPLOYEE ORDER BY NAME DESC;
ii SELECT NAME, SALARY FROM EMPLOYEE WHERE NAME LIKE 'A%';
iii SELECT NAME, DOJ FROM EMPLOYEE WHERE SALARY BETWEEN
100000 AND 200000;
iv SELECT * FROM EMPLOYEE WHERE PROJECT = 'P01';
27 (a) Consider the following tables – FACULTY and COURSES : 3
Table: FACULTY
FID FNAME LNAME JOINDATE SALARY
F01 Anishma Garg 2000-12-14 32000
F03 Bhumi Goel 2001-08-10 15000
F04 Neha Verma 2000-05-17 27000
F05 Meenu Sharma 2006-07-11 30000
Table: COURSES
C_ID FID CNAME FEES
C11 F01 Grid Computing 40000
C12 F04 Python 17000
C13 F03 C++ 8000
C14 F04 Computer Network 15000
C15 F01 HTML 12000
C16 F05 Data Science NULL
6
Then the output should be
It's the appreciation for the love we're shown,
In moments big and small, it's truly known.
29 Navdeep creates a table RESULT with a set of records to maintain the 3
marks secured by students in Sem1, Sem2, Sem3, and their divisions.
After the creation of the table, he entered data of 7 students in the
table.
ADNO ROLLNO SNAME SEM1 SEM2 DIVISION
123 101 KARAN 366 410 I
245 102 NAMAN 300 350 I
128 103 ISHA 400 410 I
129 104 RENU 350 357 I
234 105 ARPIT 100 75 IV
187 106 SABINA 100 205 II
181 107 NEELAM 470 450 I
For example:
If the dictionary Stu_dict contains the following data:
Stu_dict ={5:(87,68,89), 10:(57,54,61), 12:(71,67,90),
14:(66,81,80), 18:(80,48,91)}
7
Q No. Questions Marks
Section-D (8 Marks)
31 Create a function maxsalary() in Python to read all the records 4
from an already existing file record.csv which stores the records
of various employees working in a department. Data is stored under
various fields as shown below:
E_code E_name Scale Salary
A01 Bijesh Mehra S4 65400
B02 Vikram Goel S3 60000
C09 Suraj Mehta S2 45300
…… …… …… ……
Function should display the row where the salary is maximum.
Note: Assume that all employees have distinct salary.
32 Consider a binary file 'INVENTORY.DAT' that stores information 4
about products using tuple with the structure (ProductID,
ProductName, Quantity, Price). Write a Python function
expensiveProducts() to read the contents of
'INVENTORY.DAT' and display details of products with a price
higher than Rs. 1000. Additionally, calculate and display the total
count of such expensive products.
For example: If the file stores the following data in binary format
(1, 'ABC', 100, 5000)
(2, 'DEF', 250, 1000)
(3, 'GHI', 300, 2000)
then the function should display
Product ID: 1
Product ID: 3
Total expensive products: 2
Q No. Questions Marks
Section-E (15 Marks)
33 Fun Media Services Ltd is an event planning organization. It is 5
planning to set up its India campus in Mumbai with its head office in
Delhi. The Mumbai campus will have four blocks/buildings -
ADMIN, DECORATORS, FOOD, and MEDIA.
You as a network expert need to suggest the best network-related
solutions for them to resolve the issues/problems mentioned in points
(i) to (v), keeping in mind the distances between various
blocks/buildings and other given parameters.
8
Shortest distance between various buildings:
FROM – TO DISTANCE
ADMIN TO DECORATORS 90 meters
ADMIN TO MEDIA 75 meters
ADMIN TO FOOD 50 meters
DECORATORS TO FOOD 65 meters
DECORATORS TO MEDIA 50 meters
FOOD TO MEDIA 45 meters
DELHI Head Office to MUMBAI 1475 KM
Campus
9
Write a user-defined function, findBook(price), that accepts
price as parameter and displays all those records from the
binary file BOOK.DAT which has a book price more than or equal
to the price value passed as a parameter.
35 i. Define the term constraint with respect to RDBMS. Give a 5
suitable example.
ii. Sameera maintains a database named STORE which contains a
table named ITEM with the structure given below:
• Ino(Item number )- integer
• Iname(Item Name) – string
• Price (Item Price) – float
• Discount (Discount) – float
Note the following to establish connectivity between Python
and MySQL:
• Username - root
• Password - tiger
• Host - localhost
Help her to remove the record from the table ITEM for a particular
value of item name input by the user.
import mysql.connector as mysql
con1= mysql.connect(host='localhost', user='root', password=
'__', database='STORE') #Statement-1
mycursor = ________ #Statement-2
item_name = input("Enter the Item name to remove the record : ")
query = ______________ #Statement-3
mycursor.execute(query)
con1.____ #Statement-4
print('Data Deleted successfully')
con1.close()
11
CBSE Additional Practice Question Paper
Class: XII Session: 2023-24
Computer Science (083)
Marking Scheme
1 a. per%marks 1
2 b. list.append(element) 1
3 b. lcomme T 1
4 b. One block of except statement cannot handle multiple exceptions 1
5 c. Statement 3 1
6 d. dump 1
7 d. dict_student.update(dict_marks) 1
8 b. mean() 1
9 c. 13.5 1
10 PPP – Point to Point Protocol 1
VoIP - Voice Over Internet Protocol
11 b. LIKE operator 1
12 d. fetchone 1
13 b. r 1
14 a. file_object.seek(offset [, reference_point]) 1
15 d. Interlinking of collection of webpages is called Internet. 1
16 c. TelNet 1
17 a. Both A and R are true and R is the correct explanation for A 1
18 c. A is True but R is False 1
19 Advantages: 2
1) A dedicated communication channel increases the quality of
communication.
2) Suitable for long continuous communication.
Disadvantages:
1) Resources are not utilized fully.
2) The time required to establish the physical link between the two stations is
too long.
OR
Web browser
Purpose: Receives and displays web content.
1
Function: Initiates requests to web servers, and receives and displays content
for users.
Web server
Purpose: Delivers web content to clients.
Function: Listens to incoming requests, processes them, and sends requested
content to the client.
1 mark for any one correct difference and 1/2 mark for each two correct
examples
20 num1, num2 = 10, 45 2
while num1 % num2 == 0:
num1+= 20
num2+= 30
else:
print('hello')
½ mark for 9$
½ mark for 14$
½ mark for 19$
½ mark for 5$
23 i. del D['Mumbai'] 2
1 mark for correct answer
2
ii. print(S.split())
1 mark for correct answer
OR
my_str = "Computer Science"
alternate_chars = my_str[::2]
print(alternate_chars)
_ (Underscore):
Matches a single character.
Example: LIKE '_ _T' on the other hand will search for a three letter
string, whose 3rd letter is 'T'. At first two places any two character can
appear.
1 mark for one correct difference. 1/2 mark each for correct example of each.
OR
DROP is a DDL command in SQL and can be used to remove tables (or
database).
Example: 'DROP TABLE STUDENT;' will remove the table STUDENT from
the database.
1 mark for one correct difference. 1/2 mark each for correct example of each.
25 COUNT(*) returns the count of all rows in the table, whereas COUNT() 2
is used with Column_Name passed as an argument and counts the number
of non-NULL values in a column that is given as an argument. Hence the
result may differ.
The SQL command with COUNT(*) may have higher value as it count
all rows in the table.
3
(b)
(i)
NAME PROJECT
Satyansh P04
Ranjan P01
Muneera P01
Alex P02
Akhtar P04
½ mark for correct output
(ii)
NAME SALARY
Akhtar 125000
Alex 75000
(iii)
NAME DOJ
Ranjan 2015-01-21
Akhtar 2015-02-01
Muneera 2018-08-19
½ mark for correct output
(iv)
Eid Name DOB DOJ Salary Project
E01 Rannja 1990-07-12 2015-01-21 150000 P01
E03 Muneera 1996-11-15 2018-08-19 135000 P01
½ mark for correct output
27 (a) 3
(i)
FID MIN(FEES) MAX(FEES)
F01 12000 40000
F04 15000 17000
F03 8000 8000
F05 NULL NULL
½ mark for correct answer
(ii)
AVG(SALARY)
29500
½ mark for correct answer
(iii)
FNAME CNAME
Neha Python
Neha Computer Network
½ mark for correct answer
(iv)
4
(b)
DESC or DESCRIBE command
1 mark for correct answer
28 def Count(): 3
F=open('Gratitude.txt')
T=F.readlines()
X=1
for i in T:
print('Line',X,':',i.count('e'))
X=X+1
F.close()
Count()
OR
def Start_with_I():
F=open('Gratitude.txt')
T=F.readlines()
for i in T:
if i[0] in 'Ii':
print(i,end='')
F.close()
Start_with_I()
1 mark for correctly writing both names of candidate keys. OR ½ mark for
specifying any one candidate key correctly.
5
Stu_Stk=[]
def Pop_elements(Stu_Stk):
while len(Stu_Stk)>0:
print(Stu_Stk.pop())
if not Stu_Stk:
print('Stack Empty')
Push_elements(Stu_Stk, Stu_dict)
Pop_elements(Stu_Stk)
expensiveProducts()
6
½ mark for opening and closing file
½ mark for correct try and except block
1.5 mark identifying and displaying details of expensive products
1 mark for displaying count of expensive products
33 i. The most appropriate location of the server inside the MUMBAI 5
campus is ADMIN building due to the maximum number of computers
in it.
½ mark for mentioning the branch and ½ mark for proper justification
v.
(a) WAN
(b) LAN
½ mark for mentioning WAN and ½ mark for mentioning LAN
34 i. 5
seek() tell()
Purpose Repositions the file pointer to a Returns the current
specific location within a file position of the file
pointer
Syntax seek(offset [,reference point]) tell()
Parameters Requires specifying the offset Requires no
and an optional reference point parameters
COPY_REC()
OR
i.
Binary CSV
1. pickle module to be used 1. csv module is used
2. Data is stored in binary 2. Data is stored in tabular
format(0s and 1s) and is not fashion and comma
in human readable form using separated by default. The
any plain text editor. file can be read by any
spreadsheet software or text
editor.
3. File extension .dat/.pdf/.exe 3. File extension .csv
etc.
ii.
import pickle
def findBook(price):
with open('BOOK.DAT', 'rb') as file:
while True:
try:
book_record = pickle.load(file)
for item in book_record:
book_price = book_record[item][2]
if book_price >= price:
print(item, book_record[item])
except EOFError:
break
findBook(50)
8
SQL constraints are used to specify rules for the data in a table. Constraints
are used to limit the type of data that can go into a table.
Constraints –
NOT NULL - Ensures that a column cannot have a NULL value
UNIQUE - Ensures that all values in a column are different
PRIMARY KEY - A combination of a NOT NULL and UNIQUE. Uniquely
identifies each row in a table
OR
(i)
Candidate Key: A candidate key is a set of attributes in a relation that can
uniquely identify each tuple (row). A relation can have multiple candidate
keys, but only one of them is chosen as the primary key.
Alternate Key: An alternate key is a candidate key that is not selected as the
primary key.
(ii)
a) import mysql.connector as mysql
b) mycursor = con1.cursor()
c) query = 'SELECT * FROM ITEM where Price > {}'.format(5000)
d) data = mycursor.fetchall()