Class 12 Computer Science Sample Paper Set 5
Class 12 Computer Science Sample Paper Set 5
Join School of Educators' exclusive WhatsApp, Telegram, and Signal groups for FREE access
to a vast range of educational resources designed to help you achieve 100/100 in exams!
Separate groups for teachers and students are available, packed with valuable content to
boost your performance.
Additionally, benefit from expert tips, practical advice, and study hacks designed to enhance
performance in both CBSE exams and competitive entrance tests.
Don’t miss out—join today and take the first step toward academic excellence!
COMPUTER SCIENCE
All questions are compulsory. However, internal choices have been provided in some questions. Attempt only one
of the choices in such questions.
Section A
1. State true or false: [1]
Like while, the for loop also works with conditions and truth values.
2. With SQL, how can you return the number of not null records in the Project field of "Students" table? [1]
a) parentheses b) argument
c) parameter d) classes
5. What is the slice expression that gives every third character of string St, starting with the last character and [1]
proceeding back to the first?
6. Find EVEN parity bit for 10010110 [1]
a) 3 b) 0
c) 2 d) 1
7. ________ method of File Input Stream class closes the file input stream and releases any system resources [1]
associated with the stream.
a) Query b) Structural
c) Relational d) Compiler
9. Which of the following is a SQL aggregate function? [1]
a) JOIN b) LEN
c) AVG d) LEFT
10. Write a statement in Python to perform the following operations: [1]
i. To open a text file "MYPET.TXT" in write mode.
ii. To open a text file "MYPET.TXT" in read mode.
11. State true or false: [1]
A parameter having default value in the function header is known as a default parameter.
12. Which data structure is needed to convert infix notation to postfix notation? [1]
a) Tree b) Stack
c) Queue d) Branch
13. What do you understand by MySQL server instance? [1]
14. A ________ is a network spread across a building, or a factory/plant or campus or nearby buildings. [1]
a) MAN b) PAN
c) WAN d) LAN
15. If L1 = [1, 3, 5] and L2 = [2, 4, 6] then L1 + L2 will yield [1]
a) 0 b) 1
c) 3 d) 2
18. A router: [1]
a) Both A and R are true and R is the correct b) Both A and R are true but R is not the
explanation of A. correct explanation of A.
a) Both A and R are true and R is the correct b) Both A and R are true but R is not the
explanation of A. correct explanation of A.
a) Both A and R are true and R is the correct b) Both A and R are true but R is not the
explanation of A. correct explanation of A.
Write Python code to increase NUMBORD by 5 if QUOTPRIC is less than 100 or NUMBORD is greater than 3.
24. As immutable types cannot be changed in place then the following code should raise an error which modifies an [2]
int (an immutable type) variable. But it produces no error. Why?
A = 22
A += 2
OR
Explain the use of the pass statement. Illustrate it with an example.
25. Consider the table Student whose fields are [2]
dict = {}
a, b, c = 15, 25, 35
dict[a, b, c] = a + b - c
a, b, c = 25, 20, 40
dict[a, b, c] = a + b - c
print(dict)
27. Write a function stats() that accepts a filename and reports the file's longest line. [2]
OR
Write a method in python to read the content from a text file diary.txt line by line and display the same on-screen.
28. What is the difference between parameters and arguments? [2]
Section C
29. Write the definition of a function Count_Line() in Python, which should read each line of a text file [3]
"SHIVAJI.TXT" and count total number of lines present in text file. For example, if the content of the file
"SHIVAJI.TXT" is as follows:
Shivaji was born in the family of Bhonsle.
He was devoted to his mother Jijabai.
India at that time was under Muslim rule.
The function should read the file content and display the output as follows:
Total number of lines : 3
OR
What is the difference between the formal parameters and actual parameters? What are their alternative names? Also,
give a suitable Python code to illustrate both.
30. Write the queries for the following questions using the table Item with the following fields. [3]
(Item_Code, Item_Name, Quantity, Price)
i. Display the price 500 of item having code as 106.
ii. Display the names of all items with quantity greater than 50 and price less than 500.
iii. Display the item code of all items with quantity less than 70.
OR
Differentiate between char(n) and varchar(n) data types with respect to databases.
31. Define a function overlapping () that takes two lists and returns true if they have at least one member in [3]
common, False otherwise.
OR
From the program code given below, identify the parts mentioned below :
1. def processNumber(x):
2. x = 72
3. return x + 3
4.
5. y = 54
6. res = processNumber(y)
Identify these parts: function header, function call, arguments, parameters, function body, main program.
Section D
32. Write a program that depends upon the user's choice, either pushes or pops an element in a stack. [4]
OR
A line of text is read from the input terminal into a stack. Write a program to output the string in the reverse order,
each character appearing twice.
(ie.g., the string a b c d e should be changed to ee dd cc bb aa)
33. Given a file "dept.dat", containing records of departments with following attributes: [4]
Candidate: Name of the candidates Department:
Department name like: Computer, Physics, Math, Biology, etc. Write a method copy that would read contents
from the file "dept.dat" and creates a file named "com.dat" copying only those records from "dept.dat" where the
department name is "Computer". Assume that is a field separator in "dept.dat".
34. Write SQL commands for (i) to (v) on the basis of the table SPORTS [4]
TABLE: SPORTS
i. Display the games taken up by the students, whose name starts with 'A'.
ii. Write a query to add a new column named MARKS.
iii. Write a query to assign a value 200 for Marks for all those, who are getting grade ‘B’ or grade 'A' in both
GAME1 and GAME2.
iv. Which command will be used to arrange the whole table in the alphabetical order of NAME?
a. SELECT FROM SPORTS ORDER BY NAME;
b. SELECT * SPORTS ORDER BY NAME;
c. SELECT * FROM SPORTS ORDER NAME;
d. SELECT * FROM SPORTS ORDER BY NAME;
v. Identify the attribute best suitable to be declared as a primary key.
OR
Consider the following tables WORKER and PAYLEVEL and answer (a) and (b) parts of this question:
Table: WORKER
Table: PAYLEVEL
Table: CUSTOMER
a. Give a suitable example of a table with sample data and illustrate Primary and alternate Keys in it.
b. Write SQL commands for the following statements:
i. To display the names of all the white-colored vehicles.
ii. To display the name of vehicle name and the capacity of vehicles in ascending order of their sitting
capacity.
iii. To display the highest charges at which a vehicle can be hired from CABHUB.
iv. To display the customer name and the corresponding name of the vehicle hired by them.
c. Give the output of the following SQL queries:
i. SELECT COUNT (DISTINCT Make) FROM CABHUB;
ii. SELECT MAX(Charges), MIN(Charges) FROM CABHUB;
iii. SELECT COUNT (*) Make FROM CABHUB;
iv. SELECT Vehicle FROM CABHUB WHERE Capacity=4;
OR
Given the following family relation. Write SQL commands for questions (i) to (v) based on the table FAMILY
TABLE: FAMILY