CBSE Sample Papers for Class 12 Computer Science Set 8 with Solutions

Students must start practicing the questions from CBSE Sample Papers for Class 12 Computer Science with Solutions Set 8 are designed as per the revised syllabus.

CBSE Sample Papers for Class 12 Computer Science Set 8 with Solutions

Time: 3 hrs Max.
Marks: 70


1. Please check this question paper contains 35 questions.
2. The paper is divided into 5 Sections A, B, C, D and E.
3. Section A, consists of 18 questions (1 to 18). Each question carries 1 Mark.
4. Section B, consists of 7 questions (19 to 25). Each question carries 2 Marks.
5. Section C, consists of 5 questions (26 to 30). Each question carries 3 Marks.
6. Section D, consists of 2 questions (31 to 32). Each question carries 4 Marks.
7. Section E, consists of 3 questions (33 to 35). Each question carries 5 Marks.
8. All programming questions are to be answered using Python Language only.

Section – A

Question 1.
State True or False
“A dictionary is ordered by index”.

Question 2.
The module required to use the mode function is
(a) math
(b) statistics
(c) random
(d) Pandas
(b) statistics

Question 3.
The output of print(math.ceil(17.34)) is
(a) 18
(b) 17
(c) 10
(d) 20
(a) 18

CBSE Sample Papers for Class 12 Computer Science Set 8 with Solutions

Question 4.
Which function is used to generate a sequence of numbers overtime?
(a) range()
(b) len()
(c) limit()
(d) lim()
(a) range()

Question 5.
Which of the following symbol is used in Python for comments?
(a) $
(b) @
(c) //
(d) #
(d) #

Question 6.
The default mode in which a file is opened is
(a) r
(b) rw+
(c) w
(d) a
(a) r

Question 7.
Which of the following is not a DDL command ?
(c) DROP

Question 8.
The ……… command can be used to remove all records of a table along with the table
(d) None of these

Question 9.
What is the output of the following code?

>>> a = 10
>>> b = 2
>>> print(a + 10 * 2 + b)

(a) 32
(b) 22
(c) 40
(d) 80
(a) 32

Question 10.
The relation between Primary key , Candidate key and Alternate key is
(a) Primary key = Candidate key – Alternate key
(b) Candidate key= Primary key – Alternate key
(c) Alternate key= Primary key + Candidate key
(d) None of the above
(a) Primary key = Candidate key – Alternate key

Question 11.
Fill in the blank is used to return access mode with that file was opened. [1](a) mode.file
(b) mode.file.name
(c) file.mode
(d) file.mode.type
(c) file.mode

Question 12.
In a stack, if a user tries to remove an element from empty stack is called [1](a) Underflow
(b) Overflow
(c) Empty
(d) Garbage collection
(a) Underflow

Question 13.
State whether the following statement is True or False.
Two friends have connected their computers, but are getting weak signals. Repeater need to be used to get better signals. [1]Answer:

Question 14.
Given a list Lst= [65,182,90,420,20,10]. What will be the correct statement to take out the 3rd element from the list? [1](a) Lst.pop(2)
(b) L.find(2)
(c) L.pop(-1)
(d) L.del(90)
(a) Lst.pop(2)

Question 15.
Fill in the blank
Frequency is measured in ………

CBSE Sample Papers for Class 12 Computer Science Set 8 with Solutions

Question 16.
What is the collection of the hyperlinked document on the Internet known as?
(a) HTML
(b) Email
(c) WWW
(d) Internet
(c) WWW

Directions In the question numbers 17 and 18, a statement of Assertion (A) is followed by a statement of Reason (R). Choose the correct option.

Question 17.
Assertion (A) Python overwrites an existing file or creates a non-existing file when we open a file with ‘w’ mode. [1]Reason (R) a+ mode is used only for writing operations.
(a) Both A and R are true and R is the correct explanation for A.
(b) Both A and R are true but R is not the correct explanation for A.
(c) A is true but R is false.
(d) A is false but R is true.
(b) Both A and R are true but R is not the correct explanation for A.

Question 18.
Assertion (A) A file that is opened using the open() function may not specify the mode of opening it.[1]Reason (R) If the mode is not specified , the read mode is used by default.
(a) Both A and R are true and R is the correct explanation for A.
(b) Both A and R are true but R is not the correct explanation for A.
(c) A is true but R is false.
(d) A is false but R is true.
(b) Both A and R are true but R is not the correct explanation for A.

Section – B

Question 19.
(a) Briefly discuss the role of a web browser in Internet surfing. [1 + 1 = 2](b) Write the full form of the following
(i) GNU
(ii) XML


(a) Mention any two advantages of e-mail over conventional mail.
(b) What is the difference between video conferencing and chat?
(a) A web browser is a software program that allows a user to locate and display web pages, acts as Internet surfing,
(b) (i) GNU – GNU’s not Unix
(ii) XML – extensible Markup Language


(a) Advantages

  • E-mail is extremely cost effective.
  • E-mail takes lesser time for transmitting data than conventional mail.

(b) Chat generally involves one-to-one communication. On the other hand, video conferencing means more than two persons are involved in a discussion.

Question 20.
Observe the given list and find the answer of questions that follows.
list1 = [23, 45, 63, ‘Hello’, 20, ‘World’, 15, 18)
(a) list1[-3](b) list1[3]Answer:
(a) ‘World’
(b) ‘Hello’

Question 21.
Find the output
L = [10, 19, 45, 77, 10, 22, 2)
(a) L [3 : 5](b) L [:: -2]


Find the error(s).
L1 = [7, 2, 3, 4]L2 = L1 + 2
L3 = L1 * 2
L = L1.pop(7)
(a) [77, 10](b) [2, 10,45,10]


Error 1 L2 = L1 + 2 because + operator cannot add list with other type as number or string.
Error 2 L = L1.pop(7) parentheses puts index value instead of element. In the given list, maximum index value is 3 and 7 is out of index range.

Question 22.
What do you understand by RDBMS?


A table, ITEM has been created in a database with the following fields
Give the SQL command to add a new field, DISCOUNT (of type Integer) to the ITEM table.
A Relational Database Management System (RDBMS) is a database management system. It is developed by Dr. E.F. Codd, of IBM’s SAN Jose Research Laboratory.
RDBMS stores data in the form of related tables. Popular RDBMS include Oracle, MySQL, PostgreSQL etc.



Question 23.
Observe the following code and answer the questions that follow [2]

File = open(”Mydata”,”a”)
......# Blank1
File.close( )

(a) What type (Text/Binary/CS V) of file is Mydata?
(b) Fill in the Blank 1 with statement to write “ABC” in the file “Mydata”.
(a) Text File
(b) File.write (“ABC”)

Question 24.
Predict the output [2]

dic = {‘a’ : 1, ‘b’ : 2, ‘C’ : 3, ‘d’ : 4}
if ‘a’ in dic :
del dic[’a’]


Distinguish between tuple and list.
{‘d’ : 4, ‘a’: 1, ‘c’: 3, ‘b’: 2}
{‘d’ : 4, ’c’: 3, ‘b’ : 2}


Differences between tuple and list are as follows

Tuple List
Elements of a tuple are immutable. Elements of a list are mutable.
Tuple is declared in parenthesis 0- List is declared in square brackets Q.
Tuples cannot be changed after creation. Lists can be changed after creation.
Iterating over the elements of a tuple is fast. Iterating over the elements of a list is slow.

CBSE Sample Papers for Class 12 Computer Science Set 8 with Solutions

Question 25.
Observe the following program and answer the questions that follow: [2]import random
x = 3
N = random.randint (1, x)
for i in range (N):
print (i, #, i + 1)

(a) What is the maximum and minimum number of times the ioop will execute?
(b) Find out which line of output out of (i) to (iv) will not be expected from the program.
(i) 0#1
(ii) 2#3
(iii) 1#2
(a) Maximum number = 3
Minimum number = 1

(b) Output (iv) is not expected

Section – C

Question 26.
Consider the tables Travel and Train given below. [1 × 3 = 3]Table : Travel
CBSE Sample Papers for Class 12 Computer Applications Set 8 with Solutions 1
Write commands for the following
(a) Display passenger names, corresponding train names and amounts for records where amount >5000.
(b) Increase amount of passengers by 20% who are travelling by “AC”
(c) Display a cross join of the two tables.
(a) SELECT T1.Pname,T2.Tname, T1.Amt FROM Travel T1, Train T2 WHERE T1 ,TId= T2. TId AND Amt>5000;
(b) UPDATE Travel SET Amt=Amt+Amt*0.2 WHERE Class=”AC”;
(c) SELECT * FROM Travel, Train;

Question 27.
A binary file “emp.dat” contains records of employees as per following structure: [3]CBSE Sample Papers for Class 12 Computer Applications Set 8 with Solutions 2
Write a program in Python to open the Binary file “emp.dat” and display only those records where the employee salary is greater than 75000.


Write a program to read the content from a text file “status.txt”, count and display the total number of lines and blank spaces present in it. e.g. if the “status.txt” file contains the following lines:
Welcome to your one-step solutions for all your study, practice and assessment needs for various competitive & recruitment examinations and school segment. We have been working tirelessly for over a decade to make sure that you have best in class study resources because you deserve SUCCESS AND NOTHING LESS…
The output will be:
The status file contents are
Total lines in file are: 4
Total spaces in file are: 43

import pickle
while True:
if (lst[2]>75000):
print("Employee No. :", lst[0])
print("Employee Name :", lst[1])
print("Employee Salary :", lst[2])
except EOFError:
print("No more records")


import os
if os.path.isfile(tfile):
fob=open(tfile, ‘r’)
print(“The status file contents are”)
print (“---------”)
while True:
if not aline:
for i in aline:
if i.isspace( ):
print(“Total lines in file are:”, total_lines)
print(“Total space in file are:”, blankspaces)
fob.close( )
print(“File does not exist”)

Question 28.
Consider the following tables SENDER and RECIPIENT. Write SQL commands for the statements (a) to (c). [1 × 3 = 3]TABLE: SENDER
CBSE Sample Papers for Class 12 Computer Applications Set 8 with Solutions 3

CBSE Sample Papers for Class 12 Computer Applications Set 8 with Solutions 4
(a) To display the names of all Senders from Mumbai.
(b) To display the RecID, SenderName, SenderAddress, RecName, RecAddress for every Recipient.
(c) To display Recipient details in ascending order of RecName.
(a) SELECT SenderName FROM SENDER WHERE SenderCity = ‘Mumbai’;
(b) SELECT RecID, SenderName, SenderAddress, RecName, RecAddress

CBSE Sample Papers for Class 12 Computer Science Set 8 with Solutions

Question 29.
Write a code to accept a list of numbers and replace the numbers in the list with their sum of digits. [3]Example
Input: [32,142,215,26,7]Output: [5, 7,8,8, 7]Answer:

L= []
n=int(input!“Enter number of element”))
for i in range (1, n+1):
b=int(input!“Enter element:”))
for a in L:
s=0 ;
while a>0:

Question 30.
Write Push (contents) and Pop() methods in Python to add numbers and remove numbers considering them to act as Push and Pop operations of stack. [3]Answer:

def Push (contents):
if(len(stack) >= limit) :
print(“Stack Overflow!”)
else :
stack.append (contents)
print (“Stack after Push”, stack)
def Pop ( ) :
if (len (stack) <= 0) :
print(“Stack Underflow!”)
return 0
else :
return stack. Pop( )

Section – D

Question 31.
Consider the following table Person [1 × 4 = 4]CBSE Sample Papers for Class 12 Computer Applications Set 8 with Solutions 5
Write statements to
(a) Display the Unique Cities.
(b) Display Firstnames of people who do not have an address.
(c) Display the last name and city of person whose first name starts with K.
(d) Display the person ID and first name who lives in Sandnes.
(b) SELECT FirstName FROM Person WHERE address IS NULL;
(c) SELECT LastName, City FROM Person WHERE FirstName LIKE “K%”;
(d) SELECT P_ID, FirstName FROM Person WHERE City = “Sandnes”;

Question 32.
Write a Python program to perform the following using functions as follows [4]copytocsv() A CSV file “marks.csv” has name, class and marks separated by comma. Write the Python function to copy only the name and class to another CSV file “class. csv”
copyselected() The CSV file “marks.csv” which has name, class and marks separated by comma. Write the Python function to copy only rows of students of class 2 to another CSV file “class.csv”.

import csv
def copytocsv() :
file = open('class.csv','w', newline="")
writer = csv.writer(file)
with open('marks.csv') as csvfile:
data = csv.reader(csvfile)
for row in data:
file.closed( )
def copyselected( ) :
file = open('class.csv', 'w' ,newline="\n”)
w1 = csv.writer(file)
with open('marks.csv') as csvfile:
data = csv. reader(csvfile)
for row in data:
if row[1]== '2' :
file.close( )
copytocsv( )
copyselected( )

Section – E

Question 33.
Freshminds University of India is starting its first campus in Ana Nagar of South India with its centre admission office in Kolkata. The university has three major blocks comprising of Office block, Science block and Commerce block is in 5 km area campus.
As a network expert, you need to suggest the network plan as per (a) to (e) to the authorities keeping in mind the distance and other given parameters. [1 × 5 = 5]Expected wire distance between various locations

Office Block to Science Block 90
Office Block to Commerce Block 80
Science Block to Commerce Block 15
Kolkata Admission Office to 450
Ana Nagar Campus

Expected number of computers to be installed at various locations in the university are as follows:

Office Block 10
Science Block 140
Commerce Block 30
Kolkata Admission Office 8

(a) Suggest the authorities, the cable layout amongst various blocks inside university campus for connecting the blocks.
(b) Suggest the most suitable place (i.e. block) to house the server for this university with a suitable reason.
(c) Suggest an efficient device from the following to be installed in each of the block to connect all the computers.
(i) Modem
(ii) Switch
(iii) Gateway
(d) Suggest a suitable topology to connect the computers in each building.
(e) University is planning to connect its campus in Kolkata which is more than 100 km. Which type of network will be formed?
CBSE Sample Papers for Class 12 Computer Applications Set 8 with Solutions 6

(b) The most suitable place to house the server is Science Block as it has maximum number of computers. Thus, reducing the cabling cost and increases efficiency of network.
(c) (ii) Switch is the device to be installed in each of the blocks to connect all the computers.
(d) Star topology, as it is the best in efficiency.
(e) WAN (Wide Area Network) will be formed.

Question 34.
(a) Explain the concept of candidate keys with the help of an appropriate example. [1 + 4 = 5](b) Write the code to create the following table Student with the following fields
In the table, Rank should be Good, Best, Bad, Worst, Average.


(a) What is the use of fetchone() method?
(b) Write an example code to fetch a single record from a database.
Note :
Database : PythonDB
Table : Student
Host: localhost
UsedID : root
Password : arihant
(a) A candidate key is a set of one or more fields that identifies each record uniquely in a table. There can be multiple candidate keys in one table and one of them will become the primary key.
Table: Item

INO IName Qty
101 CD 10
102 Pen 5
103 Pencil 2
104 Eraser 3

In the Item table, INO and IName can be treated as the candidate keys.


import mysql.connector
mycon = mysql.connector.connect (
host = “local host”,
user = "root”,
passwd = "system”,
database = “School”
cursor = mycon.cursor ( )
db = cursor.execute


(a) fetchone() returns the next row from the result set as tuple. If there are no more rows to retrieve, None is returned.

import mysql.connector
con = mysql.connector.connect
(host = "localhost”,
user = “root”, '
passwd = "arihant”,database = "PythonDB”)
cursor = con.cursor( )
cursor.execute ("Select Name,
RollNo, Address, Percentage from Student”)
display = cursor.fetchone()
con.close( )

CBSE Sample Papers for Class 12 Computer Science Set 8 with Solutions

Question 35.
(a) Which module is used to operate on CSV file? . [2 + 3 = 5](b) Write a Python program with following functions :
addcsv() File old.csv has come from branch in Pune and it needs to be added to file “updated.csv” which has data for all branches. Write the code in the function to perform the same.
convertcsv() A file old.csv has come with separator but your system can only read ‘;’ Write a program to convert to “converted.csv” file. Write the function to change the separator of the file.


(a) CSV files are opened with which argument to suppress EOL translation.
(b) Riya is a Python expert and she got a task to write a program in which filedel() is a function, to delete the line having word (passed as argument).
File content are in file “Python.txt” and after deleting the content. Write the content in file “algo1.txt”.
(a) To read and write in CSV files we need to import csv module.


import csv
def addcsv():
f1 = open("old.csv", 'r')
f2 = open("updated.csv", 'a', newline = "\n")
r1 = csv.reader(f1)
w1 = csv.writer(f2)
for row in r1 :
def convertcsv():
f1 = open("old.csv", 'r')
f2 = open("converted.csv", 'w', newline = "\n")
r1 = csv.reader(f1, delimiter = ":")
w1 = csv.writer(f2, delimiter = ";")
for row in r1 :
f1.close( )
f2.close( )
addcsv( )
convertcsv( )


(a) newline=’ ‘

import OS
def filede1 (word) :
file1 = open (“Python, txt ”,“r”)
nfile = open (“algol.txt”, “w”)
while True :
line = file1.readline( )
if not line :
else :
if word in line :
pass else :
print (line)
nfile.write (line)
file1.close ( )
nfile.close ( )
filedel (‘write’)

Show More

Related Articles

यौगिक किसे कहते हैं? परिभाषा, प्रकार और विशेषताएं | Yogik Kise Kahate Hain Circuit Breaker Kya Hai Ohm ka Niyam Power Factor Kya hai Basic Electrical in Hindi Interview Questions In Hindi