CBSE Class 12 Computer Science Sample Paper Set 2 for 2024-25 FREE PDF (1)
CBSE Class 12 Computer Science Sample Paper Set 2 for 2024-25 FREE PDF (1)
General Instructions:
Section A
1. State true or false: Do both the following represent the same list. 1
www.vedantu.com 1
a) Data Definition Language
a) All of these
b) Concatenation
c) Dot Representation
d) Relational-and
4. What are the possible outcome(s) executed from the following code? 1
Also specify the maximum and minimum values that can be assigned
to variable PICK.
import random
PICK= random.randint(0, 3)
print()
www.vedantu.com 2
6. Computer communication signal which is in the form of the continuous 1
wave is called
a) modulation signal
b) Binary signal
c) digital signal
d) analog signal
7. To read the entire remaining contents of the file as a string from a file 1
object infi, we use
a) infi.readlines( )
b) display databases;
c) infi.readline( )
d) infi.read( )
a) s.__getitem__(i)
b) s.getitem(i-1)
c) s.__getitem__(i-1)
d) s.getitem(i)
www.vedantu.com 3
a) LIKE operator
b) BETWEEN operator
c) INTO operator
d) EXISTS operator
file1.seek (2,-10)
file1.tell() file1.close()
a) Evaluation
b) Create
c) Push
d) Pop
www.vedantu.com 4
14. Internet is an example of ________ topology. 1
a) Mesh
b) Star
c) Tree
d) Bus
15. which of the following four code fragments will yield following 1
output?
Ziva
Diva
Riva
b) print(‘ZivaDivaRiva ')
c) print('Ziva\nDiva\nRiva')
16. Which of the following join gives the intersection of two tables? 1
a) Inner join
b) Outer join
www.vedantu.com 5
c) Equi join
d) Fuller join
a) 1
b) 2
c) 3
d) 0
a) Option (i)
b) Option (iii)
c) Option (iv)
d) Option (ii)
www.vedantu.com 6
Reason (R): The scalar value is repeated to match the length of the
index.
20. Assertion (A): To store the data permanently into the file we use file 1
handling.
www.vedantu.com 7
d) A is false but R is true.
Section B
22. Give one advantage and one disadvantage of optical fiber cable 2
and coaxial cable used in communication.
102 XYZ 7 70
103 PQR 8 65
104 XYZ 12 55
for x, y in dnry:
print(x, y)
www.vedantu.com 8
ii. Write the corrected code for part (a) so that it prints keys and values
both.
OR
If a is (1, 2, 3)
ii. is a * 3 equivalent to a + a + a?
25. Which data will get added in table Company by following code? 2
import mysql.connector
cur = con.cursor()
sql = "insert into Company(Name, Dept, Salary) values (%s, %s, %s)"
cur.execute(sql, val)
con.commit()
26. Write a program which will find all such numbers which are divisible 2
by 7 but are not a multiple of 5, between 200 and 300 (both included).
Or
www.vedantu.com 9
Underline the syntax errors in the following program
a=x+b+z
27. Write a program that check to see if the file name exists, it will give 2
you an error message, if not, it will create the file.
OR
Section C
Here are some function calls given below. Find out which of these are
correct and which of these are incorrect stating reasons?
For correct function call statements, specify the argument values too.
i. info(obj1)
www.vedantu.com 10
ii. info(spacing=20)
v. info(obj3, collapse = 0)
vi. info( )
OR
I. num = 1
def myfunc():
return num
print(num)
print(myfunc())
print(num)
ii. num = 1
def myfunc():
www.vedantu.com 11
num = 10
return num
print(num)
print(myfunc())
print(num)
iii. num = 1
def myfunc():
global num
num = 10
return num
print(num)
print(myfunc())
print(num)
iv.
display()
www.vedantu.com 12
print("there!")
Write the SQL command to remove the column DISCOUNT from the
table.
ii. Categorize the following SQL commands into DDL and DML:
OR
FROM product
GROUP BY brand
ii. Correct the error so that only those brands get listed that have a max
price more than 100.
iii. How will the corrected query's result be different from the following
query?
www.vedantu.com 13
FROM product
GROUP BY brand;
1. def processNumber(x):
2. x = 72
3. return x + 3
4.
5. y = 54
6. res = processNumber(y)
Or
class Book
char Bno[20];
protected:
www.vedantu.com 14
float Price;
public:
void GetB();
void ShowB();
};
class Member
char Mno[20];
protected:
char Name[20];
public:
void GetM();
void ShowM();
};
char Lname[20];
public:
void GetL();
www.vedantu.com 15
void ShowL();
};
void main()
Library L;
ii. Write the names of all the data members, which are directly
accessible by the member function GetL() of class Library.
iii. Write the names of all the member functions, which are directly
accessible by the member function ShowL() of class Library.
iv. Write the names of all the members, which are directly accessible
by the object L of class Library declared in the main() function.
Section D
32. Write a program to implement a stack for these book details (bookno, 4
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.
Or
www.vedantu.com 16
33. Write a point of difference between append (a) and write (w) modes in 4
a text file. Write a program in Python that defines and calls the
following user defined functions:
i. Add_Teacher() : It accepts the values from the user and inserts the
record of a teacher to a csv file 'Teacher.csv'. Each record consists of a
list with field elements as T_id, Tname and desig to store teacher ID,
teacher name and designation respectively.
34. Give output for following SQL queries as per given table(s) 4
Table: HOSPITAL
www.vedantu.com 17
8 Zareen 45 Gynecology 22/02/98 300 F
or
www.vedantu.com 18
5 Rakesh 42 Maths 05/09/97 25000 M
www.vedantu.com 19
MB004 Oppo SelfieEx 8500 2010-08-21
Section E
36. Ravya Industries has set up its new center at Kaka Nagar for its office 5
and web based activities. The company compound has 4 buildings as
shown in the diagram below:
www.vedantu.com 20
Jazz Building Harsh Building 170 m
Harsh Building 15
Fazz Building 15
Jazz Building 25
ii. Suggest the most suitable place (i.e., block) to house the server of
this organisation with a suitable reason.
iv. The organization is planning to link its front office situated in the
city in a hilly region where cable connection is not feasible, suggest an
economic way to connect it with reasonably high speed.
www.vedantu.com 21
37. Write SQL queries for (i) to (vii) on the basis of tables given below: 5
PRODUCTS
Table: SUPPLIERS
www.vedantu.com 22
S02 DIGI BUSY GROUP CHENNAI
ii. To display product name and price of all those products, whose price
is in the range of 10000 and 15000 (both values inclusive).
iv. To display the price, product name, and quantity (i.e., qty) of those
products which have a quantity of more than 100.
v. To display the names of those suppliers, who are either from DELHI
or from CHENNAI.
vi. To display the name of the companies and the name of the products
in descending order of company names.
vii. Obtain the outputs of the following SQL queries based on the data
given in tables PRODUCTS and SUPPLIERS above.
Or
www.vedantu.com 23
Write SQL queries for (i) to (iv) and find outputs for SQL queries (v)
to (viii), which are based on the tables:
TABLE: MEMBER
www.vedantu.com 24
i. To display all details from table MEMBER in descending order of
ISSUEDATE.
ii. To display the BNO and BNAME of all Fiction Type books from the
table Book.
iii. To display the TYPE and number of books in each TYPE from the
table BOOK.
www.vedantu.com 25
Answer Key
Section A
1. b) False
4. c) DELHI
MUMBAI
CHENNAI
KOLKATA
5. The tuple is similar to lists but the value of the items stored in the list can be changed,
whereas the tuple is immutable, and the value of the items stored in the tuple cannot be
changed.
6. d) analog signal
7. d) infi.read( )
8. (a) s.__getitem__(i)
9. a) LIKE operator
10. The code will open the file myfile.txt first by open function and then by seek() method
place the pointer 10 bytes before the end of file. Lastly, it will tell the position of the file
pointer from the starting of the file.
11. b) False
www.vedantu.com 26
13. DROP TABLE statement is used to delete the table and all its data from the database
entirely. The syntax for DROP TABLE is DROP TABLE ;
DROP VIEW Removes an existing view from a database. DROP VIEW statement is used to
remove a view or an object view from the database. The syntax for DROP VIEW is DROP
VIEW ;
14. a) Mesh
\nDiva
\nRiva ')
Explanation: p
rint( 'Ziva
\nDiva
\nRiva ')
17. d) 0
20. b) Both A and R are true but R is not the correct explanation of A.
www.vedantu.com 27
Section B
22.
Coaxial cable:
Disadvantage: When using coaxial cables over long distances, signal loss is a disadvantage.
23.
24.
i. The above code will produce Error as we can iterate only on keys in a dictionary.
Thus the line:
www.vedantu.com 28
for x, y in dnry:
for x in dnry:
print(x, dnry[x])
0a
1b
2c
Or
i. Expression a * 3 will give a tuple while (a, a, a) will give a nested tuple :
>>> a = (1, 2, 3)
>>> a * 3 (1, 2, 3, 1, 2, 3, 1, 2, 3)
>>> (a, a, a)
iv. a [1:2] will give a tuple with one item while a[1:1] will give an empty tuple.
www.vedantu.com 29
25.
26.
l = []
l.append (str(i))
print(','.join(l))
a=x+y+z
print("Result = ", a)
27.
import os
if os.path.isfile('test.txt’):
www.vedantu.com 30
else :
f = open("text.txt",'w’)
If the text file test exists, the program will print "You are trying to create a file that already
exists!" else the file is opened in write mode, to create a new file with length 0.
OR
fileObject = open("Article.txt",r)
count = 0
str = fileObject.read()
count += 1
fileObject.close()
28.
def dic(a):
for i in a:
www.vedantu.com 31
Output
1 : One
2 : Two
3 : Three
Section C
29.
i. Correct - obj1 is for positional parameter object; spacing gets its default value of 10 and
collapse gets its default value of 1. The function call would become info(obj, 10, 1).
ii. Incorrect - Required positional argument (object) missing; required arguments cannot be
missed. This function call is incorrect.
iii. Correct - Required parameter object gets its value as obj2; spacing gets value 12 and for
skipped argument collapse, default value 1 is taken. The function call would become
info(obj2, 12, 1), which is correct.
iv. Incorrect - Same parameter object is given multiple values - one through positional
argument and one through keyword(named) argument. The same parameter cannot have
multiple values in a function call. Therefore, this function call is incorrect.
v. Correct - Required parameter object gets its value as obj3; collapse gets value 0 and for
skipped argument spacing, default value 10 is taken. The function call would be info(obj3,
10,0), which is correct.
vi. Incorrect - Required parameter object's value cannot be skipped. Therefore, this function
call is incorrect.
www.vedantu.com 32
vii. Incorrect - Positional arguments should be before keyword arguments. obj3 should be
passed before spacing and collapse values. viii. Correct - Required argument object gets its
value through a keyword argument.
OR
i.
ii.
10
iii.
10
10
www.vedantu.com 33
30.
i. Removing the Column "DISCOUNT": To remove the column named "DISCOUNT" from
the existing "ITEMS" table, we can use the following SQL command:
OR
i. The condition price > 100 with HAVING clause is error because with group by groups of
records get created that contain the summary result and price > 100 is applicable on
individual records and not on group of records.
ii. SELECT brand, MAX(price) FROM product GROUP BY brand HAVING MAX(price) >
100 ;
iii. The corrected query will return only those groups where MAX(price) > 100. But the
given query will first extract records with price > 100 and then group them on the basis of
column brand.
www.vedantu.com 34
31.
Arguments y in line 6
Parameters x in line 1
return x + 3
res = processNumber(y)
OR
i. Multiple Inheritance
www.vedantu.com 35
GetM(), ShowM() of class Member
Section D
def isEmpty(stk):
if stk==[ ]:
return True
else:
return False
top=len(stk)-1
def displaybook(stk):
if isEmpty(stk):
www.vedantu.com 36
print “Book No----- Book Name”
print stk[a].split( )
#main
stack = [ ]
top = None
while True:
print “Books”
if ch == 1:
pushbook(item, stk)
row_input()
elif ch == 2:
www.vedantu.com 37
displaybook(stk)
row_input()
elif ch==3:
break else:
row_input( )
or
stack, append(ch)
top=len(stack)-1
return
if isempty(stack):
print stack[a],
return
www.vedantu.com 38
if stack==[]:
else:
return False
#.....main.....
str=[]
top=None
str=raw_input(“Enter a string”)
while a in str:
pushstack(stk, str)
popstack(stk)
33.
Difference between append (a) and write (w) modes in a text file:
a (append) mode - To open the file to write the content at the bottom(or end) of existing
content. It also creates the file, if it does not exist.
whereas
w (write) mode - To create a new file to write the content in it. It overwrites the file, if it
already exists.
www.vedantu.com 39
import csv
def Add_Teacher():
fout=open("Teacher.csv","a",newline="\n")
rec=[T_id,Tname,desig]
csvw=csv.writer(fout)
csvw.writerow(rec)
fout.close()
def Search_Teacher():
fin=open("Teacher.csv")
csvr=csv.reader(fin)
if record[2]=="PGT":
print(record)
fin.close()
Add_Teacher()
Search_Teacher()
www.vedantu.com 40
34.
16
750
385
OR
OUTPUT
i. 3
ii. 35
iii. 0
iv. 0
www.vedantu.com 41
35.
try:
cursor.execute(sql)
display=cursor.fetchall()
for i in display:
print (i)
except: mycon.rollback()
mycon.close()
cursor.execute(sql)
mycon.commit()
except:
mycon.rollback()
mycon.close()
www.vedantu.com 42
Section E
36.
i. The most suitable place/block to house the server of this organisation would be Raj
Building, as this block contains the maximum number of computers, thus decreasing the
cabling cost for most of the computers as well as increasing the efficiency of the maximum
computers in the network.
b. In the layouts, a hub/switch each would be needed in all the buildings, to interconnect the
group of cables from the different computers in each block.
iii. The type of network that shall be formed to link the sale counters situated in various parts
of the same city would be a MAN because MAN (Metropolitan Area Networks) are the
networks that link computer facilities within a city.
37.
i. SELECT * FROM PRODUCTS ORDER BY PNAME ASC; (* bydefault show all the
values)
ii. SELECT PNAME, PRICE FROM PRODUCTS WHERE ((PRICE = > 10000) AND
(PRICE = < 15000));
iv. SELECT PRICE, PNAME, QTY FROM PRODUCTS WHERE (QTY > 100);
www.vedantu.com 43
vii. a. S03
b. 28000 1100
c. 550000
d.
PNAME SNAME
OR
Fiction
Literature
www.vedantu.com 44
Comic
vii.
www.vedantu.com 45