Article

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

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

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

Time: 3 hrs Max.
Marks: 70

Instructions

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 [1]“The method that can be used to delete a range of values from a list is del”.
Answer:
True

Question 2.
In which module, ceil() function resides? [1](a) pandas
(b) pyplot
(c) random
(d) math
Answer:
(d) math

Question 3.
Given L=[2,3,4,5,6]. The output of print(L[-1:-5]) is [1](a) [6,5,4](b) Error
(c) [](d) [6,5]Answer:
(c) []

Question 4.
The ……. function returns True if all the characters in a string are digits. [1](a) isalnum()
(b) isdigit()
(c) isnumber()
(d) isalpha()
Answer:
(b) isdigit()

Question 5.
Given a tuple t=(2,5,1,6,3). The statement t.sort() returns [1](a) (1,2,3,5,6)
(b) (6,5,3,2,1)
(c) Error
(d) None of these
Answer:
(c) Error

Question 6.
The seek(n) places the file pointer at position n with reference to [1](a) Beginning
(b) End
(c) Current position
(d) Position 10
Answer:
(a) Beginning

Question 7.
To see a list of all the databases in the system , the command may be used. [1](a) Show
(b) Show databases
(c) Display databases
(d) View databases
Answer:
(b) Show databases

Question 8.
It is a way to convey a Python object into a character stream. [1](a) Pickling
(b) Unpickling
(c) dump() method
(d) load() method
Answer:
(a) Pickling

Question 9.
in and not in are ……. Operators. [1](a) Arithmetic
(b) Membership
(c) Logical
(d) Identity
Answer:
(b) Membership

Question 10.
Rows of a relation are called [1](a) relation
(b) tuples
(c) data structure
(d) an entity
Answer:
(b) tuples

Question 11.
Fill in the blank: While opening a binary file the character has to be added to the mode of opening. [1](a) b
(b) x
(c) u
(d) b
Answer:
(a) b

Question 12.
If a table cames 10 columns and 15 rows, what is its degree? [1](a) 10
(b) 150
(c) 15
(d) 25
Answer:
(a) 10

Question 13.
State whether the following statement is True or False : Modulation and demodulation is performed by modem. [1]Answer:
True

Question 14.
t1=(9, 6, 7, 6)
t2=(2, 8, 12, 20)
The output of the statement below is [11
print( min(t1) + max(t2))
(a) 26
(b) 25
(c) Error
(d) None of these
Answer:
(a) 26

Question 15.
Fill in the blank is a system of interlinked hypertext accessed via internet. [1]Answer:
WWW

Question 16.
The arrangement where all data pass through a central computer is known as
(a) ring topology
(b) mesh topology
(c) star topology
(d) bus topology
Answer:
(c) Star topology

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

Question 17.
Assertion (A)Pickling is a way to convey a Python object into character stream.
Reason (R) To perform pickling, the pickle module needs to be imported.
(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.
Answer:
(a) Both A and R are true and R is the correct explanation for A.

Question 18.
Assertion (A) A recursive function does not require a loop. [1]Reason (R) A recursive function calls itself again and again until a certain condition is true.
(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.
Answer:
(a) Both A and R are true and R is the correct explanation fo A.

Section – B

Question 19.
(a) Expand the following terms [1+1=2]PPP, XML
(b) What is the mean by SMS?
Answer:
(a) PPP Point-to-Point
XML eXtensib’e Markup Language
(b) SMS (Short Message Service) commonly referred to as text messaging, is a service for sending short messages upto 160 characters to mobile devices.

Or

(a) Mr. Lai owns a factory which manufactures automobile spare parts. Suggest him the advantages of having a web page for his factory.
(b) Name one commonly used open source Internet browser and one commonly used open source operating system.
Answer:
(a) The web page provides the information to the clients about his factoy of spare parts. Moreover, he can receive the order on the Internet from the client using the web page.
(b) Open source internet browser – Chromium
Open source operating system – Linux

Question 20.
Observe the code given below and find the output [2]

s=”oceanview”
count=0
for a in s:
if a in “stuv”:
count+= 1
print(count)

Answer:
1
The for loop checks for existence of the characters of the string in “stuv”, and returns the count.
Answer:

Question 21.
Given the following code [2]

d={ ‘Bed’ :145000, ‘Almirah’ :9000, ‘Chair’ :1000}
for v in d.keys( ):
if d[v]>100000 :
d[v]- =10000
print(d)

What will be the output of the print statement?
Or
Find the output of following code

Name= PythoN3@1”
R = " "
for x in range(len(Name)):
if Name[x].isuppero:
R=R+Name[x].lower( )
elif Name[x].islower( ):
R=R+Name[x].upper( )
elif Narne[x].isdigit( ):
else:
R=R+"#"
print(R)
Answer:
{‘Bed’: 135000, ‘Almirah’: 9000, Chair: 1000}
Or
pYTHOnN#@

Question 22.
Explain database and DBMS in detail. [2]Or
Differentiate between char(n) and varchar(n) data types with respect to databases.
Answer:
Database The database is a shared collection of logically related data, designed to meet the information needs of an organisation. A database is a computer based record keeping system whose over aH purpose is to record and maintains information.
DBMS A Database Management System (DBMS) is a collection of programs that enables users to store, modify and
xtract information from a database as per the requirements. It acts as an interface between the application program and the operating system to access or manipulate the database.

Or

Differentiate between char(n) and varchar(n) are as follows

char(n) varchar(n)
It stores a fixed length string between 1 and 255 characters. It stores a variable length string.
If the value is of smaller length, then it adds blank spaces. No blanks are added by varchar(n) even if value is of smaller length.
Some space is wasted in it. No wastage of space in varchar(n).

Question 23.
(a) What is the minimum number of iterations that while( ) loop could make? [2](b) Write an appropriate loop for the condition a loop is to be repeated loo times.
Answer:
(a) while() loop could make minimum 0 iteration.
(b) f0r i in range (0, 100, +1);

Question 24.
What output will the following code produce? [2]

y=str( 123)
x="hello"*3
print(x,y)
x=”hello" + world”
y=len(x)
print(y,x)

Or

Write function names for the following with respect to strings.
(a) To make the first letter of a string in capital.
(b) To find the index of the 1st occurrence of a string in another.
Answer:
hellohellohello 123 .
10 helloworld

Or

(a) capitalize() Returns a copy of the string with the 1st character capitalized.
(b) find() Returns the lowest index in a string where another string is found.

Question 25.
Determine the hierarchy of operations and evaluate following expression.
A = 3*4//5+5/,7+8—2 +4/12
Answer:
The * operator will be performed before II. Though both have same priority but in this expression * is prior to //.
A = 3*4//5 + 5//7 +8-2+4//2
= 12//5+5//17+8—2+4//2
= 2+ 5//7 + 8—2+ 4//2 operation : //
=2+0+8—2+4/2 operation://
= 2+ 0+ 8-2+2 operation : //
= 2+0+6+2 operation:-
= 10

Section – C

Question 26.
With respect to the table PAYMENTS given below , write output of the following questions. [1 × 3 = 3]TABLE : PAYMENTS

(i) To display the average of employees salary from PAYMENTS table.
(ii) To count the total number of employees from PAYMENTS table Department wise
(iii) To count distinct values of column Department from PAYMENTS table.
Answer:
SELECT AVG(Salary) FROM PAYMENTS;
(ii) SELECT Department ,COUNT(*) FROM PAYMENTS GROUP BY Department:
(iii) SELECT COUNT(DISTINCT Department) FROM PAYMENTS;

Question 27.
Write a code in Python to open a Binary file “College.dat” containing records of students as per following structure. [3]Roll Name SemPercentage
The code should display only records of students from the file where the percentage is greater than 30.
Or
Write a method countopen( ) to count and display the number of lines starting with the word ‘OPEN’(including lower cases and upper cases) present in a text file “start, txt”.
e.g. If the file “start.txt” contains the following lines:
Get the data value to be deleted;
Open the file for reading from it.
Read the complete file into a list
Delete the data from the list
Open the file
Open same file for writing into it
Write the modified list into file.
Close the file.
The method should display
Total lines started with word ‘OPEN’ is/are: [3]Answer:

stud=[]
f_open("College.dat", "rb”)
while True:
try:
stud=pickle. load(f)
if stud[2]>30:
print(stud)
except EOFError:
print("End of file")
break
f.close()

Or

import os
def countopen( ):
if os.path.isfile(”start.txt”):
f=open(”start .txt”, “r”)
c=0
print(”The lines are:”)
while True:
l=f.readline( )
l=l.rstrip( )
print (l)
if not 1:
break
list1=l.upper( ).split( )
if(list1[0]==’OPEN’ ):
c=c+1
if(c>0):
print(”Total lines started with the word ‘OPEN’ is/are:”, c)
else:
print(”There is no line started with the word OPEN “)
f.close()
else:
print(”File does not exist”)

Question 28.
Write SQL commands from (i) to (iii) on the basis of the table INTERIORS given below [1 × 3 = 3]TABLE: INTERIORS

(i) To show all information about the Sofa from the INTERIORS table.
(ii) To list the ITEMNAME, which are priced at more than 10000 from the INTERIORS table.
(iii) To list ITEMNAME and TYPE of those items, in which DATEOFSTOCK is before 22/01/02 from the INTERIORS table in descending order of ITEMNAME.
Answer:
(i) SELECT * FROM INTERIORS WHERE TYPE = ‘Sofa’:
(ii) SELECT ITEMNAME FROM INTERIORS WHERE PRICE > 10000;
(iii) SELECT ITEMNAME, TYPE FROM INTERIORS WHERE DATEOFSTOCK < ‘22/01/02’ ORDER BY ITEMNAME DESC;

Question 29.
Write a user defined function to accept a string and check whether it is palindrome or not.
(A palindrome is a string that is same as its reverse) [3]Answer:
def checkPal in():
string = input (“Enter the string:”)
str1 = ” ”
for i in string:
str1 = i + str1
print (“string in reverse order:”, str1)
if (string == str1):
print (“This is a palindrome string”)
else :
print (“This is not a palindrome string”)

Question 30.
Explain the traversal operation in a stack. [3]Write the algorithm for Traversal of a stack to display its contents.
You need not to write the actual code.
Answer:
Moving through the elements of the stack is known as traversal. Traversing is the basic operation to display elements in a stack.
Algorithm Steps to Display all the Elements of the Stack

  1. Start
  2. if (Top = – 1) go to step 3
    else go to step 4
  3. Print “Stack is empty” and go to step 7
  4. Print the Top element of the stack
  5. Decrement Top by 1
  6. if (Top = – 1) go to step 7
    else go to step 4
  7. Stop

Section – D

Question 31.
Consider the following table [1 × 4 = 4]TABLE:INTERIORS

Write statements to
(a) Write a command to display only the Column ITEMNAME , Net Amount(PRICE- DISCOUNT)
(b) Display only ITEMNAME and Discount column.
(c) Which clause is to be used to search non blank values in the table?
(d) Which command will be used to make the “No” column as the primary key?
Answer:
(a) SELECT ITEMNAME, PRICE-DISCOUNT AS “Net Amount” FROM INTERIORS;
(b) SELECT ITEMNAME, DISCOUNT FROM INTERIORS;
(c) NOT NULL
(d) ALTER TABLE INTERIORS ADD Primary key(No);

Question 32.
A binary file “Telephone.dat” exists storing details of BSNL customers as per following structure. [4]PhoneNo CustomerName ConnType
Write a program in Python for adding and displaying record count from the binary file using following functions
NewCustomer() To add data of customers to the binary file “Telephone.dat”.
Note : The existing connection data should be preserved.
PrintConnections() To open the file “Telephone.dat” and display the connections and number of connections.
Answer:

import pickle
def NewCustomerl) :
f=open("Telephone.dat","ab")
ans="y"
pno=""
cname=""
ctype=””
while ans=='y':
pno=input("Enter telephone number ,”)
cname=input("Enter customer name ")
ctype=input("Enter connection Type")
phone1st=[pno,cname,ctype]
pickle.dump(phonelst, f)
ans=input("Continue(y/n)")
f .close()
def PrintConnections( );
f=open("Telephone.dat","rb")
while True:
try:
phonelst=pickle.load(f)
print("Phone No.:" phonelst[0])
print("Customer Name : "phonelst[1])
print(“Connection Type phonelst[2])
except EOFError:
print("End of file")
break
f.close()
NewCustomer( )
PrintConnections( )

Section – E

Question 33.
Tech Up Corporation (TUC) is a professional consultancy company. The company is planning to set up their new offices in India with its hub at Hyderabad. As a network adviser, you have to understand their requirement and suggest to them the best available solutions. Their queries are mentioned as (a) to (e) below. [1 × 5 = 5]

(a) What will the most appropriate block, where TUC should plan to install their server?
(b) Draw a block to block cable layout to connect all the buildings in the most appropriate manner for efficient communication.
(c) Write names of different types of Modems.
(d) Which of the following devices will be suggested by you to connect each computer in each of the buildings?
(i) Gateway
(ii) Switch
(iii) Modem
(e) Company is planning to connect its Block in Hyderabad which is more than 20 km. Which type of network will be formed?
Answer:
(a) TUC should install its server in Human Resource Block as it has maximum number of computers.
(b)

The above layout is based on the minimum length of cable required, i.e. 140 m.
(c) Internal Modem : Fixed inside the computer.
External Modem : Attached externally to a computer
(d) (ii) Switch
(e) MAN

Question 34.
(a) What is DDL? Explain with its commands. [1 + 4 = 5](b) Write a code in Python to update the class of a student to 12 whose roll number is 22. The table structure is as follows :
RollNo Name Class Perc
Note:
Database :PythonDB
Table: Student
Host: localhost
UserId:root
Password: arihant

Or

(a) What is DML? Explain with its commands.
(b) Write a code in Python to delete the record of a student whose rollno is 33.
The table structure is as follows
RollNo Name Class Perc
Note :
Database :PythonDB
Table: Student
Host: localhost
UserId:root
Password: arihant
Answer:
(a) DDL (Data Definition Language) provides statements for creation and deletion of the database tables, views, etc. The DDL provides a set of definitions to specify the storage structure in a database system.
Some DDL statements are as follows

  1. CREATE used to create new table in the database.
  2. DROP used to delete tables from the database.
  3. ALTER used to change the structure of the database table. This statement can add up additional column, drop existing, and even change the data type of columns involved in a database table.
  4. RENAME used to rename a table.

(b)

import mysql.connector
con = mysql.connector.connect
(host = “localhost”, user = “root", passwd = “arihant”, database = “PythonDB”)
cursor = con.cursor( )
try :
cursor.execute (“update Student set Class = 12 where RollNo = 22”)
con.commit( )
except :
con.rollback()
con.close()

Or

(a) DML (Data Manipulation Language) provides statements for manipulating the database objects. It is used to query the databases for information retrieval. Some DML statements are as follows
(i) iNSERT used to insert data into a table.
(ii) SELECT used to retrieve data from a database.
(iii) UPDATE used to update existing data within a table.
(iv) DELETE used to delete all records from a table.

(b)

import mysql.connector
con = mysql.connector.connect
(host = “localhost”, user = “root”,
passwd = “ariharit”,
database = “PythonDB”)
cursor = con.cursor( )
try :
cursor.execute (“update Student set Class = 12 where RollNo = 22”)
con.commit( )
except :
con.rollback( )
con.close( )

Question 35.
(a) What is the use of writerows() function for CSV files? [2 + 3=5](b) A binary file “Hotel.dat” exists storing details of hotel customers as per following structure:
RoomId CustomerName Days
Write a program in Python for adding and displaying records from the binary file using following functions
Reserve() To add data of customers to the binary file.
ShowReservations() To open the file “Hotel.dat” and display all the records.
Or
(a) What is csv. reader() function?
(b) Write a program in Python to modify records of a binary file “hotel.dat” using random access. The program would accept the room id, search the record by random access and display. It will then accept the new data and modify the file.
The file structure is
RoomId Customer Name Days
Answer:
(a) writerows function writes multiple rows (sequence) to the writer’s file object.

(b)

import pickle
def Reserve( ) :
f=open("Hotel .dat”,”wb”)
ans="y"
roomid=” ”
cname=" "
day =" "
while ans==’y’:
roomid=input(”Enter room id”)
cname=input(”Enter customer name “)
days=input(”Enter days”)
hotel lst=[roomid, cname ,days]
pickle.dump(hotel lst, f)
ans=input( “Continue(y/n)”)
f.close()
def ShowReservations( ):
f=open(”Hotel.dat”, “rb”)
while True:
try:
lst=pickle.load(f)
print(”Room ID :“lst[O])
print(”Customer Name :“,lst[1])
print(”Days :“,lst[2])
except EOFError:
print(”No more records”)
break
f.close()
Reserve()
ShowReservations()

Or

(b)

import pickle
lst =[]
f=open( “hotel .dat”.” rb+”)
ans="y’
while ans==’y’:
r=int(input(”Enter roomid to modify :“))
1st=pickle.load(f)
size=f.tell( )
f.seek(0)
f.seek((r-1)*Size)
1st=pickle.load(f )
print(”old record“)
print(”Room Id :“ , lst[0])
print(”Customer :“, lst[1])
print(”Days :“,lst[2])
f.seek(0)
f.seek((r-1)*size)
print(”Enter new record “)
nm=input(”Enter customer name :“)
days=input(”Enter days :“)
rs=str(r)
lst=[rs,nm, days]
pickle.dump(lst,f)
ans=input(”Modify another(y/n)”)
f.close()


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