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 Allowed: 3 hours
Maximum Marks: 70

General Instructions:

  • This question paper contains five sections, Section A to E.
  • All questions are compulsory.
  • Section A have 18 questions carrying 01 mark each.
  • Section B has 07 Very Short Answer type questions carrying 02 marks each.
  • Section C has 05 Short Answer type questions carrying 03 marks each.
  • Section D has 03 Long Answer type questions carrying 05 marks each.
  • Section E has 02 questions carrying 04 marks each. One internal choice is given in Q35 against part c only.
  • All programming questions are to be answered using Python Language only.

Section – A

Question 1.
State True or False.
Consider the following operation performed on a stack of size 5. [1]
Push(l);
PopO;
Push(2);
Push(3);
Pop();
Push(4);
Pop();
Pop();
Push(5);
After the completion of all operation, the number of elements present in stack is one.
Answer:
True
Explanation:
1. Push (1): Operand 1 is added in the stack
2. Pop (): Operand 1 is deleted.
3. Push (2): Operand 2 is added in stack.
4. Push (3): Operand 3 is added in stack
5. Pop (): Operand 3 is deleted.
6. Push (4): Operand 4 is added.
7. Pop (): Operand 4 is removed.
8. Pop (): Operand 2 is removed.
9. Push (5): Operand 5 is added

Conclusion:
At last only the operand 5 remains in stack. So the correct answer is 1.

Answering Tip:
Students should remember that PUSH means inserting an element into stack and POP means extracting or picking out an element from stack.

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

Question 2.
It is the process by which a python object is converted to a byte stream. [1]
(A) Unpickling
(B) loading
(C) pickling
(D) Dumping
Answer:
(C) pickling

Explanation:
Pickling is a process where a Python object hierarchy is converted into a byte steam. Serialization process is also called pickling

Question 3.
What value will be shown if you try to open a binary file as a text file? [1]
(A) Default value
(B) Advance value
(C) Garbage value
(D) Parameter value
Answer:
(C) Garbage value

Explanation:
Binary files represent the actual content such as image, audio, video, compressed versions of other files executable files, etc. These files are not human readable. Thus, trying to open a binary file using a text editor will show some garbage values.

Question 4.
A/An is a block of organised and reusable code. [1]
(A) Function
(B) argument
(C) parameter
(D) Definition
Answer:
(A) Function

Explanation:
A function is a block of organised and reusable code that is used to perform a single, related action. Functions provide better modularity for your application and a high degree of code reusability.

Question 5.
Which of the following can be used as valid variable identifier(s) in Python ? [1]
(A) 4thSum
(B) Total
(C) Number#
(D) import
Answer:
(B) Total

Explanation:
4thSum;import and Number# are invalid identifiers because name cannot be start with a digit and We cannot use special symbols like !, @, #, $, %, etc., in identifiers.

Question 6.
Consider a tuple tupl = (10,15,25, 30). Identify the statement that will result in an error. [1]
(A) print(tupl[2])
(B) tupl [2] = 20
(C) print(min(tupl))
(D) print(len(tupl))
Answer:
(B) tupl [2] = 20

Explanation:
Tuples are immutable.

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

Question 7.
How many rules were laid down by E.F Codd? [1]
(A) 10
(B) 11
(C) 12
(D) 13
Answer:
(C) 12

Explanation:
E.F. Codd invented relational model for database management system. He proposed 13 rules (numbered 0 to 12) and are known as Codd’s 12 rules. It defines what is required from a database management system in order for it to be considered as a relational database management system (RDBMS).

Question 8.
Which of the following types of table constraints will prevent the entry of duplicate rows? [1]
(A) Unique
(B) Distinct
(C) Primary Key
(D) NULL
Answer:
(C) Primary Key

Explanation:
The SQL PRIMARY KEY constraint combines between the UNIQUE and SQL NOT NULL constraints, where the column or set of columns that are participating in the PRIMARY KEY cannot accept a NULL value. If the PRIMARY KEY is defined in multiple columns, you can insert duplicate values on each column individually, but the combination values of all PRIMARY KEY columns must be unique.

Question 9.
What are the two main types of functions? [1]
(i) Custom function
(ii) Built in function
(iii) User defined function
(iv) System function
(A) (i)and(ii)
(B) (ii) and (iii)
(C) (iii) and (iv)
(D) (i) and (iv)
Answer:
(B) (ii) and (iii)

Explanation:
Built in functions and user defined functions are the two main types of functions. The Built in functions are part of the python language that are pre defined e.g. dir (),len (), abs () etc.

Question 10.
Fill in the blank
Each table comprises of _____________ and _____________ . [1]
(A) rows, columns
(B) data, information
(C) database, table
(D) None of these
Answer:
(B) data, information

Explanation:
A database is an organized collection of data that is arranged in rows and columns.

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

Question 11.
What is the output of 0.1 + 0.2 = = 0.3? [1]
(A) True
(B) False
(C) Machine dependent
(D) Error
Answer:
(B) False

Explanation:
== is relational operator. These operators compare two operands to one another. 0.1 + 0.2 = = 0.3 is invalid or false

Question 12.
An Alternate key can be defined as:
(A) An attribute which is a primary key
(B) An attribute which is not a primary key
(C) A candidate key
(D) None of these
Answer:
(B) An attribute which is not a primary key

Explanation:
All the keys which did not become the primary Key are called alternate keys.

Question 13.
Fill in the blank [1]
1 Gbps is equal to
(A) 125 Mbps
(B) 125 Bps
(C) 125 Kbps
(D) 125 Gbps
Answer:
(A) 125 Mbps

Explanation:
Gbps stands for Gigabits per second and Mbps stands for Megabits per second. Both are the units of bandwidth i.e., ways to measure the speed of the internet connection. The higher bandwidth, the faster is your internet speed.

Question 14.
Which of the following is an invalid statement? [1]
(A) abc = 1,000,000
(B) a b c = 1000 2000 3000
(C) a,b,c = 1000,2000, 3000
(D) a_b_c = 1,000,000
Answer:
(B) a b c = 1000 2000 3000

Explanation:
You can assign multiple values to multiple variables in a single statement.
Valid
abc = 1,00,000 (abc is a single variable name)
a, b, c = 1000, 2000, 3000
a, b, c = 1,00,000 (multiple values are being assigned multiple values in a single statement.)
abc = 1,000,000 (multiple values cannot be assigned to a single variable.)

Question 15.
The MAX () function finds the [1]
(A) Maximum number of records entered in a table
(B) Maximum number of rows allowed to be entered
(C) Maximum value of the selected column
(D) None of these
Answer:
(C) Maximum value of the selected column

Explanation:
The SQL MAX() function is used to return the maximum value of an expression in a SELECT statement. E.g. SELECT MAX(per) AS “Highest Percentage” FROM student. This statement will return the maximum value of percentage from column PER in STUDENT table.

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

Question 16.
Which of the following types of table constraints will prevent the entry of duplicate rows?
(A) Unique
(B) Distinct
(C) Primary Key
(D) NULL
Answer:
(C) Primary Key

Explanation:
The SQL PRIMARY KEY constraint combines between the UNIQUE and SQL NOT NULL constraints, where the column or set of columns that are participating in the PRIMARY KEY cannot accept a NULL value. If the PRIMARY KEY is defined in multiple columns, you can insert duplicate values on each column individually, but the combination values of all PRIMARY KEY columns must be unique.

Assertion and Reason:
In the following questions, A statement of Assertion (A) is followed by a statement of Reason (R). 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 correct explanation for A.
(C) A is true but R is false.
(D) A is false but R is true.

Question 17.
Assertion (A): A complex arithmetic operations can be converted into polish strings.
Reason (R): Example of Stacks application is reversal of a given line. [1]
Answer:
(B) Both A and R are true and R is not correct explanation for A.

Explanation:
Polish string refers to the notation in which the operator symbol is placed either before its operands (prefix notation) or after its operands (postfix notation).
Reversal of a given line can be accomplished by pushing each character on to a stack as it is read.

Question 18.
Assertion (A): Lists can be change after creation.
Reason (R): Lists are mutable.
Answer:
(A) Both A and R are true and R is the correct explanation for A.

Explanation:
List is a type of container in data structure, which is used to store multiple data at the same time. It contains a sequence of heterogenous elements which makes it powerful tool in Python. Lists are mutable which means they can be changed after creation.

Section – B

Question 19.
Consider the code given below and rewrite the correct code. [2]
i=0
while i<100:
i + = 1
if i % 2 = = 0
print (1)
Answer:
i = 0
while i<100:
if i%2=0
print(i)
i+=1

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

Question 20.
Define the following:
(i) Firewall
(ii) VoIP [2]
OR
Expand the following abbreviations.
(i) FTP
(ii) TCP
(iii) SMTP
(iv) VOIP
Answer:
(i) Firewall: A system designed to prevent unauthorized access to or from a private network is called firewall. It can be implemented in both hardware and software or combination of both.
(ii) VoIP: It is a methodology and group of technologies for delivering voice communication and multimedia sessions over IP networks, such as the Internet

OR

(i) File Transfer Protocol
(ii) Transmission Control Protocol
(iii) Simple Mail Transfer Protocol
(iv) Voice over Internet Protocol

Question 21.
(a) What is the output of the following Python statements?
x = [[10.0, 11.0, 12.0], [13.0, 14.0, 15.0]]
y = x[l] [2]
print (y) [2]
(b) What is the output of following code?
T=(100) print(T*2)
(A) Syntax error
(B) (200)
(C) (100)
(D) (100,100)
Answer:
(a) 15.0

Commonly Made Error:
Students do not understand the correct function of pop()

Answering Tip:
Learn nested lists.

(b) 200

Question 22.
Explain the concept of candidate keys with the help of an appropriate example. [2]
Answer:
Candidate key is a column or set of columns that can help in identifying records uniquely. Example: consider a table STUDENT
CBSE Sample Papers for Class 12 Computer Science Set 8 with Solutions 1
Here, AdmnNo and RollNo define the table uniquely.
Hence, they are candidate keys.

Question 23.
(a) Write two advantages of using an optical fibre cable over an ethernet cable to connect two service stations, which are 200m away from each other. [2]
(b) Write the expanded names for the following abbreviated terms used in Networking and Communications:
(i) MBPS
(ii) WAN
(iii) CDMA
(iv) WLL
Answer:
(a) Advantages of optical fibre over ethernet cable:
(i) Faster speed than Ethernet
(ii) Lower attenuation

(b) (i) MBPS – Mega Bytes per Second OR Mega Bits per second
(ii) Wide Area Network
(iii) CDMA – Code Division Multiple Access
(iv) WLL – Wireless Local Loop

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

Question 24.
What would this code do?
list = [‘Delhi’, ‘Mumbai’, ‘Chennai’, ‘Kolkata’]
print(list.pop()) [2]
OR
What output will this code produce?
colours = []
colours.append(“blue”)
colours.append(“green”)
colours.append(“red”)
colours.reverse()
print(colours)
Answer:
Remove ‘Kolkata’ from the list and print it out to the shell

Commonly Made Error:
Students do not understand the correct function of pop():

Answering Tip:
pop() removes last element from the list and returns it

OR

[‘red’, ‘green’, ‘blue’]

Question 25.
What will happen if the data being loaded into a text column exceeds the maximum size of that type? What type of value Numeric Data is used to store.? [2]
OR
Name few DDL commands.
Answer:
Data will be truncated. Both Whole numbers and real numbers are stored as numeric data

OR

CREATE, ALTER

Section – C

Question 26.
(a) Sonal needs to display name of teachers, who have “O” as the third character in their name. She wrote the following query.
SELECT NAME FROM TEACHER WHERE NAME = “**07″;
But the query isn’t producing the result. Identify the problem.
(b) Consider the table student given below:
CBSE Sample Papers for Class 12 Computer Science Set 8 with Solutions 2
Write outputs of the following queries:
(i) SELECT distinct city FROM STUDENT;
(ii) SELECT CLASS,DOB, CITY FROM STUDENT WHERE MARKS BETWEEN 490 AND552;
(iii) SELECT, CLASS, COUNTO FROM STUDENT GROUP BY CLASS HAVING MARKS>450;
(iv) SELECT NAME FROM STUDENT WHERE CITY = “DUBAI”; [3]
Answer:
(a) The wildcards are incorrect. The corrected query is
SELECT name FROM teacher WHERE name LIKE ‘_ _ O%’;

(b) (i) Agra
Mumbai
Delhi
Dubai
Moscow

(ii)

X 06-06-1995 Agra

(iii)

X 2
XII 1

(iv) Marisla

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

Question 27.
Define a function reverse() that overwrites the contents of the file “myfile.txt” with its reverse contents. That is
the file will now contain the lines of the original file in reverse order. [3]
OR
Write a program that prompts for a phone number of 10 digits and two dashes, with dashes after the area code and the next three numbers. ’
e.g. 017-555-1212 is a legal input.
Display if the phone number entered is invalid format or not and display if the phone number is valid or not.
Answer:

def reverse]):
file=open ("myfile . txt" , "r")
text=file . readlines ()
file . close ()
n=len(text)
file=open ("myfile . txt" , "w")
for i in range(n-1,-1,-1):
file.writeline (text[i])
file . close ()

OR

phone_no=input ("Enter phone number
with area code:")
check=0
for a in range (len(phone_no)):
if a==3 or a==7:
if phone_no [a] != '-':
print("Invalid Input")
break
else:
if not((phone_no[a]>='A' and phone_on[a]<='Z')
or
(phone_ no[a]>='a' and phone_ no[a]<='z')):
print("Valid Input")
break
else:
print("Valid phone no", phone_no)

Question 28.
(a) Write output for SQL queries (i) to (iv), which are based on the table: STUDENT given below:
CBSE Sample Papers for Class 12 Computer Science Set 8 with Solutions 3
(i) SELECT COUNTO, City FROM STUDENT GROUP BY CITY HAVING COUNT(*)>1;
(ii) SELECT MAX(DOB),MIN(DOB) FROM STUDENT;
(iii) SELECT NAME,GENDER FROM STUDENT WHERE CITY=”Agra”;
(iv) SELCT CITY FROM STUDENT WHERE MARKS = 400;
(b) Charu has to create a database named EARTH in MYSQL, write the command for the same [3]
Answer:
(a)
(i)

COUNT(*) City
2 Mumbai
2 Delhi
2 Moscow

(ii)

MAX(DOB) MIN(DOB)
08-12-1995 07-05-1993

(iii)

NAME GENDER
Nanda M

(iv)

City Delhi

(b) create database EARTH

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

Question 29.
Write a python method/function Swapper (Numbers) to swap the first half of the content of a list Numbers with second half of the content of list Numbers and display the swapped values.
Note: Assuming that the list has even number of values in it.
For example:
If the list Numbers contains
[35, 67, 89, 23, 12, 45]
After swapping the list content should be displayed as
[23, 12, 45, 35, 67, 89] [3]
Answer:
def Swapper (Numbers):
mid=int(len(Numbers)/2 )
for i in range(0,mid):
T=Numbers[i]
Numbers[i]=Numbers[mid+i]
Numbers[mid + i]=T
print (Numbers )

Question 30.
Write a function to push any student’s information to stack. [3]
OR
Write a program to implement a stack for these book details (bookno, bookname). That is, now each item node of the stack contains two types of information -a bookno and its name. Just implement push and display operations.
Answer:

def push(stack):
s=[]
print ("STACK BEFORE PUSH")
display(stack)
s.append(input ("Enter student rollno?"))
s.append(raw_input ("Enter student name"))
s.append (raw_input ("Enter student grade"))
stack.append(s)
def display (stack):
l=len (stack)
print ("STACK CONTENTS")
for i in range (1-1,-1,-1):
print stack [i]
stack= []
print "Creating stack"
n = input ("Enter the number of students")
for i in range(n):
push (stack)
display (stack)

OR

def isempty(stk):
if stk== []
return True
else:
return False
def pushbook (stk, item):
stk.append(item)
top=len (stk)-1
def displaybook(stk):
if isempty(stk):
print("Stack Empty")
else :
top=len (stk)-1
print("book no.......... book name")
for a in range (top,-1,-1):
print (stk[a])
stk= []
top=None
while True:

print ("book")
print("1. add a book")
print ("2. display list")
print ("3. exit")
ch=int (input("enter your choice 1-3:"))
if ch==1:
bno=input("enter book no:")
bname=input ("enter book name")
item=[bnp, bname]
pushbook (stk, item) input () elif ch==2:
displaybook(stk)
input()
elif ch=3:
break
else:
print("invalid choice!") input()

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

Section – D

Question 31.
Sanskar University of Himachal Pradesh is setting up a secured network for its campus at Himachal Pradesh ~ for operating their day-to-day office & web based activities. They are planning to have network connectivity between four buildings. Answer the question (i) to (v) after going through the building positions in the campus & other details which are given below: A i
CBSE Sample Papers for Class 12 Computer Science Set 8 with Solutions 6
The distance between various buildings of university are given as:

Building 1 Building 2 Distance(in mtrs.)
Main Admin 50
Main Finance 100
Main Academic 70
Admin Finance 50
Finance Academic 70
Admin Academic 60

Number of computers:

Building No. of Computers
Main 150
Admin 75
Finance 50
Academic 60

As a network expert, you are required to give best possible solutions for the given queries of the university administration:
(i) Suggest cable layout for the connection between the various buildings,
(ii) Suggest the most suitable building to house the server of the network of the university,
(iii) Suggest the placement of following devices with justification:

  • Switch/Hub
  • Repeater

(iv) Suggest the technology out of the following for setting-up very fast Internet connectivity among

  • buildings of the university
  • Optical Fibre
  • Coaxial cable
  • Ethernet Cable

(v) Expand the term LAN and MAN. [2+3=5]
Answer:
(i)
CBSE Sample Papers for Class 12 Computer Science Set 8 with Solutions 4
(ii) Server should be placed at Main Building as it has the maximum number of computers.
(iii) Hub/Switch each would be needed in all the buildings to interconnect the group of cables from the different computers in each building A repeater needs to be placed along the wire between main building & finance building as the distance is more than 70 mtr.
(iv) Optical Fibre (1 mark for correct answer)
(v) LAN – Local Area Network
MAN – Metropolitan Area Network

Question 32.
(a) What is the output of the following Python statements? lstl = [10,15,20,25, 30] lstl.insert( 3,4) lstl.insert( 2,3) print (lstl [-5])
(b) Consider the tables Product and Client with structures as follows:

Product Client
P_ID C_ID
ProductName CName
Manufacturer CCity
Price CProd

Write Python codes to display the details of products whose price is in range of 50 to 100 (Both values included)
OR
(a) Identify the output of the following Python statements :

D={}
T=("ZEESHAN","NISHANT","GURMEET","LISA")
for i in range (1, 5):
D[i]=T[i-l]
print (D)

(b) Consider a table structure as foEows:
Employee
Emp_Id
Emp_name
Dept
Age.
Write Python code to create the above table
Answer:
(a) 3

(b) import MySQLdb
db=MySQLdb.connect('localhost', 'Admin', 'Admin@pwd', 'cosmetics')
cursor=db.cursor()
sql="""select * from Product where Price BETWEEN %F to %F"""
value = (50,100)
try:
cursor.execute(sql, value)
results = cursor.fetchall()
print ("ID ProductName Manufacturer Price")
for row in results:
PID = row[0]
PName = row[1]
PManu = row[2]
PPrice = row[3]
print (" %s %s %s %s", % \ (PID, PName, PManu, PPrice)
print (cursor.rowcount, "Records Found") except:
print ("Error unable to Fetch data") cursor.close()
db.close() )

OR

(a) {1:”ZEESHAN”,2:”NISHANT”,3:”GURMEET”/4 :”LISA”}

(b) import MySQLdb
db = MySQLdb.connect("localhost", "Admin", "Ad123", "HMD") cursor=db.cursor()
cursor.execute("DROP TABLE IF EXISTS Location")
sql="""Create Table Employee (Emp_Id Numeric (5) PRIMARY KEY, ldg._code varchar(10) Not Null, Dept varchar(6) Not Null, Age Numeric (5) Not Null)""" cursor.execute(sql)
db. close ()

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

Question 33.
How can you read input from the keyboard?
A csv file students.csv contains students name score. Write a function
(i) score() – to read students name score from the file and print
(ii) count() – to count the number of records and column names present in the file. [5]
OR
How can you write output to the monitor?
Create file marks, dat that stores the detaEs in foUowing format:

Name Marks
Rahul 750
Kiyaan 665

Obtain the details from the user.
Answer:
To read input from the keyboard import sys module and use sys.stdin.read().

PROGRAM
import csv def score():
with open('students.csv',newline='") as f:
data=csv.DictReader(f)
print("StudentName","\","Score" , )
for i in data:
print (i [ 'StudentName' ] , "&t" ,i ['Score'])
def count()
fields=[]
rows=[]
with open ('Students.csvnewline='')
as f:
data=csv.reader(f)
fields=next(data)

OR

To write on the monitor, import sys module and use sys.stdout.write()

Program
fp1 = open ("marks.dat",,w')
fp1.write ("Name")
fpl.write (" ")
fpl.write ("marks")
fp1.write ('\n')
while True:
name = input ("Enter name:")
mark = input ("Enter marks:")
fpl.write (name)
fpl.write (" ")
fpl.write (mark)
fpl.write ("\n")
ch = input ("Want to enter more=y/n")
if ch == 'N' or ch == 'n': break
fpl.close()

Section – E

Question 34.
Consider the table TRIP and answer the questions that foUow
CBSE Sample Papers for Class 12 Computer Science Set 8 with Solutions 5

Note:

  • NO is Driver Number
  • KM is Kilometre Travelled
  • NOP is number of travellers travelled in vehicle
  • TDATE is Trip Date

(i) Identify the primary key [1]
(ii) Identify the alternate key [1]
(iii) Find the output for following SQL queries
(a) To display NO, NAME, TDATE from the table TRIP in descending order of NO [2]
(b) To display the NAME of the drivers from the table TRIP, who are travelling by transport vehicle with code 101 or 103.
OR (Option for part iii only)
(iii) (a) To display the NO and NAME of those drivers from the table TRIP who travelled between ‘2015-02-10’ and ‘2015-04-01’.
(b) To display name whose NO is 14.
Answer:
(i) NO
(ii) NAME
(iii) (a) Select No, Name, TDATE from Trip order by No DESC;
(b) SELECT NAME FROM TRIP WHERE TCODE = 101 OR TCODE = 103;
OR
(iii) (a) SELECT NO, NAME FROM TRIP WHERE ‘2015-02-10’ < TDATE < ‘2015-04-01’;
(b) SELECT NAME FROM TRIP WHERE NO = 14;

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

Question 35.
Here is the function to find the sum of arguments

total = _____________ # Line 1
def sum (argl, arg2):
total = argl + _____________ # Line 3
print (total)
return _____________ # Line 5
total = sum (10, 20)
print (_____________) # Line 7

Answer the questions that follow
(i) Which value or constant will be equal to variable total in line 1? [1]
(ii) Which value will be return in line 5? [10]
(iii) Fill the blank in line 7 [2]
Answer:
(i) 0
(ii) total
(iii) total