0% found this document useful (0 votes)
22 views29 pages

Class 12 Computer Science Sample Paper

This document is a sample question paper for Computer Science for Class XII for the academic year 2025-26, consisting of 37 questions divided into five sections. Each section has varying marks assigned, and the questions cover topics in Python programming and SQL. The paper includes multiple-choice questions, coding tasks, and theoretical questions related to computer science concepts.

Uploaded by

joshthethunder5
Copyright
© All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
22 views29 pages

Class 12 Computer Science Sample Paper

This document is a sample question paper for Computer Science for Class XII for the academic year 2025-26, consisting of 37 questions divided into five sections. Each section has varying marks assigned, and the questions cover topics in Python programming and SQL. The paper includes multiple-choice questions, coding tasks, and theoretical questions related to computer science concepts.

Uploaded by

joshthethunder5
Copyright
© All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd

NODIA APP Sample Paper 01 Page 1

Sample Paper 01
Computer Science (083)
CLASS XII 2025-26
Time: 3 Hours Max. Marks: 70
General Instructions:
1. This question paper contains 37 questions.
2. All questions are compulsory. However, internal choices have been provided in some questions. Attempt
only one of the choices in such questions
3. The paper is divided into 5 Sections- A, B, C, D and E.
4. Section A consists of 21 questions (1 to 21). Each question carries 1 Mark.
5. Section B consists of 7 questions (22 to 28). Each question carries 2 Marks.
6. Section C consists of 3 questions (29 to 31). Each question carries 3 Marks.
7. Section D consists of 4 questions (32 to 35). Each question carries 4 Marks.
8. Section E consists of 2 questions (36 to 37). Each question carries 5 Marks.
9. All programming questions are to be answered using Python Language only.
10. In case of MCQ, text of the correct answer should also be written.

SECTION A
1. State if the following statement is True or False:
In Python, when opening a text file in ‘w+’ mode, if the file does not exist, a FileNotFoundError will be
raised.

2. What will be the output of the following Python code?


MyTuple = (“Code”, “For”, “Fun”)
print(MyTuple[0][-1] + MyTuple[2][0])
(A) eF (B) CF
(C) ef (D) cF

3. Consider the given expression:


print(not (10 > 20) and 20 != 10 or 5 == 5)
Which of the following will be the correct output of the given expression?
(A) True (B) False
(C) Error (D) None

4. In SQL, which key is an attribute or set of attributes that can uniquely identify a tuple within a relation,
but is not selected as the primary key?

5. What will be the output of the following Python code?


S = “PYTHON2025”
print(S[1:6:2])
(A) YH0 (B) YHN
(C) PTO (D) H02
Page 2 Sample Paper 01 CBSE Computer Science Class 12

6. Write the output of the following Python code:


i = 1
while i < 8:
print(i, end=’ ‘)
i += 3

7. What will be the output of the following Python statement:


print(5 3 // 2 + (15 % 4) 2)

8. Consider the given SQL Query, which intends to display the average salary for each job role having more
than 2 employees.
SELECT job, AVG(salary) FROM employees WHERE COUNT() > 2 GROUP BY job;
Identify the error and provide the corrected query.
(A) SELECT job, AVG(salary) FROM employees GROUP BY job WHERE COUNT() > 2;
(B) SELECT job, AVG(salary) FROM employees GROUP BY job HAVING COUNT() > 2;
(C) SELECT job, AVG(salary) FROM employees HAVING COUNT() > 2;
(D) SELECT job, AVG(salary) FROM employees WHERE COUNT > 2 GROUP BY job;

9. What will be the output of the following Python code?


try:
print(“A”)
k = 5 // 0
print(“B”)
except ValueError:
print(“Value Error”)
finally:
print(“C”)

10. What will be the output of the following Python code?


stack = [10, 20, 30]
[Link](40)
print([Link]())
(A) 30
(B) 40
(C) [10, 20, 30]
(D) AttributeError

11. What possible output is expected to be displayed on the screen at the time of execution of the Python
program from the following code?
import random
Words = [“GO”, “TO”, “SLEEP”, “NOW”]
N = [Link](1, 3)
print(Words[N], end=”#”)
print(Words[N-1], end=”#”)
(A) TO#GO#
(B) SLEEP#TO#
(C) GO#TO#
(D) NOW#GO#
NODIA APP Sample Paper 01 Page 3

12. What will be the output of the following Python code?


def ScopeTest(x):
x = x + 5
print(x, end=’ ‘)
x = 10
ScopeTest(x)
print(x)
(A) 15 15 (B) 10 15
(C) 15 10 (D) 10 10

13. Which SQL aggregate function is used to find the total number of rows in a table that match a specified
condition?
(A) SUM() (B) TOTAL()
(C) COUNT() (D) NUM()

14. What is the output of the given Python code?


Data = “1, 2, 3, 4”
L = [Link](‘,’, 2)
print(L)
(A) [‘1’, ‘ 2’, ‘ 3, 4’] (B) [‘1’, ‘2’, ‘3’, ‘4’]
(C) [[‘1’, ‘2’, ‘3’, ‘4’]] (D) Error

15. In SQL, a table ‘STUDENTS’ has 4 rows and 5 columns. After executing a DELETE command that
removes 2 rows, what will be the new cardinality of the table?
(A) Cardinality: 4 (B) Cardinality: 2
(C) Cardinality: 5 (D) Cardinality: 3

16. Which SQL constraint ensures that all values in a column are different and that the column does not contain
any NULL values?
(A) UNIQUE (B) NOT NULL
(C) PRIMARY KEY (D) CHECK

17. _________ is a network protocol used for secure data communication over a computer network, widely
used for logging into remote machines and executing commands.
(A) TELNET (B) SSH
(C) FTP (D) SMTP

18. Which of the following network topologies requires a central controller or hub, where all nodes are connected
directly to this central device?
(A) Bus Topology (B) Ring Topology
(C) Star Topology (D) Mesh Topology

19. What is the full form of XML, a markup language that defines a set of rules for encoding documents in a
format that is both human-readable and machine-readable?
(A) Extensible Markup Language (B) Executable Markup Language
(C) Extra Modern Language (D) Extended Markup Linguistics
Page 4 Sample Paper 01 CBSE Computer Science Class 12

20. Assertion (A): In Python, a try block must be followed by at least one except block or a finally block.
Reason (R): The finally block is executed regardless of whether an exception is thrown or not, making it
useful for cleanup actions.
(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 the correct explanation for A.
(C) A is True but R is False.
(D) A is False but R is True.

21. Assertion (A): The GROUP BY clause in SQL is always used before the WHERE clause.
Reason (R): The WHERE clause is used to filter individual rows from a table before they are grouped by
the GROUP BY clause.
(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 the correct explanation for A.
(C) A is True but R is False.
(D) A is False but R is True.

SECTION - B
22. Seema was asked to accept a list of even numbers ,but she did not put the relevant condition while accepting
the list of numbers. She wrote a user defined function odd to even (L) that accepts the list L as an argument
and converts all the odd numbers into even by multiplying them by 2.
def oddtoeven (L)
for i in range (size(L)):
if (L[i]%2! == 0)
L[i]= L[1] ** 2
print (L)
There are some errors in the code . Rewrite the correct code.

23. Observe the code and write the output


(a) ‘‘Nodia publication’. count(‘hant’, 0, 10)
(b) dic = {}
dic[(1, 2, 4)] = 8
dic[(4, 2, 1)] = 10
dic[(1, 2)] = 24
sum = 0
for i in dic:
sum = sum + dic[i]
print(sum)

24. How are E-mail and chat applications different?


 or
How are LAN and MAN different?

25. Write about the terms degree and cardinality of a table.

26. (a) Write the full forms of


(i) URL
(ii) VoIP
(b) Write the use of SMTP.
NODIA APP Sample Paper 01 Page 5

27. Find the output of following code.


dic = {“Nitin”: (21, “NIIT”), “Ankit”: (15, “NIIT”)}
print(“The original dictionary :”, str(dic))
result = [(key, i, j) for key, (i, j) in [Link]()]
print(“The list after conversion :”, str(result))
 or
What output will be generate when the following Python code is executed?
def ChangeList ():
l =[]
l1=[]
l2=[]
for i in range(1, 10):
[Link](i)
for i in range(10, 1, –2):
[Link](i)
for i in range(len (l1)):
[Link](l1[i] + l[i])
[Link] (len(l)– len(l1))
print(l2)
ChangeList()

28. Differentiate between DROP and DELETE commands of SQL.


 or
Identify any two DML commands from the following and also explain.
ALTER , INSERT , UPDATE , DROP , CREATE

SECTION-C
29. Write a function countEU() in Python, which should read each character of a text file. [Link] should
count and display the occurrence of alphabets E and U (including small cases e and u too).
e.g. If the file content is as follows :
Pinaky has gone to his friend’s house.
His friend’s name is Ravya. Her house is 12 km from Pinaky’s house.
The countEU() function should display the output as
E:8
U:3
 or
Write a Python program to find the longest word in file “[Link]”. If contents of [Link] are Welcome
to your one-step solutions for all your study, practice and assessment need for various competitive and
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...
Output should be
Longest word : examinations
Page 6 Sample Paper 01 CBSE Computer Science Class 12

30. Priya has created a dictionary with names as keys and marks as values for 6 students. Write a program with
separate user-defined functions to perform the following operations.
(a) Push the keys (name of the student) of the dictionary into a stack, where the corresponding value
(marks) is greater than 75.
(b) Pop and display the content of the stack.
For example If the sample content of the dictionary is as follows
R={“OM”:76, “JAI”:45, “BOB”:89, “ALI”:65, “ANU”:90, “TOM”:82}
The output from the program should be
TOM ANU BOB OM
 or
Rohit has a list of 10 integers. Write a program with separate user-defined functions to perform the specified
operations on this list..
(a) Traverse the content of the list and push the even numbers into a stack.
(b) Pop and display the content of the stack.
For example, If the sample content of the list is as follows
N = [12, 13, 34, 56, 21, 79, 98, 22, 35, 38]
Sample Output of the code should be:
38 22 98 56 34 12

31. Consider the following tables - STUDENT and STREAM :


TABLE: STUDENT
SCODE NAME AGE STRCDE POINTS GRADE
101 Amit 16 1 6 NULL
102 Arjun 13 3 4 NULL
103 Zaheer 14 2 1 NULL

TABLE: STREAM
STRCDE STRNAME
1 SCIENCE+COMP
2 SCIENCE+ BIO
3 SCIENCE+ECO
4 COMMERCE+MATHS
What will be the ouput of the following statement?
SELECT NAME, STRNAME FROM STUDENT S, STREAM ST WHERE [Link]=[Link];
 or
Write the output for SQL queries (i) to (iii), which are based on the table ITEMS.

TABLE: ITEMS
Code IName Qty Price Company TCode
1001 DIGITAL PAD 12i 120 11000 XENITA T01
1006 LED SCREEN 40 70 38000 SANTORA T02
1004 CAR GPS SYSTEM 50 2150 GEOKNOW T01
1003 DIGITAL CAMERA 12X 160 8000 DIGICLICK T02
1005 PEN DRIVE 32 GB 600 1200 STOREHOME T03
NODIA APP Sample Paper 01 Page 7

(i) SELECT MAX(Price), MIN(Price) FROM ITEMS;


(ii) SELECT Price * Qty AS AMOUNT
FROM ITEMS WHERE Code=1004;
(iii) SELECT DISTINCT TCode FROM ITEMS;

SECTION-D
32. (a) Find the output of the following Python program:
def makenew (mystr):
newstr = “”
count = 0
for i in mystr:
if count%2!=0:
newstr = newstr + str (count)
else:
if islower (i):
newstr = newstr + upper (i)
else:
newstr = newstr + i
count + = 1
newstr = newstr + mystr [:1]
print(“The new string is:”,
newstr)
makenew(“sTUdeNT”)
(b) Consider the table Student whose fields are

Scode Name Age Strcde Points Grade


101 Amit 16 1 6 NULL
102 Arjun 13 3 4 NULL
103 Zaheer 14 2 1 NULL
104 Gegen 15 5 2 NULL
105 Kumar 13 6 8 NULL

Write the Python code to update grade to ‘A’ for all these students who are getting more than 8 as points.
The table structure is as follows :
Scode : integer
Name : varchar
Age : integer
Strcde : integer
Points : integer
Grade : varchar
Note the following to establish the connection between Python and MySQL:
Host : localhost
Username : Admin
Password : Admin@123
The table exists in MySQL database as : Student
Page 8 Sample Paper 01 CBSE Computer Science Class 12

 or
(a) Write a Python program to remove the characters of odd index values in a string.
(b) Consider the table MobileStock with following fields
M_Id. M_Name, M_Oty, M_Supplier
Write the Python code to fetch all records with fields M_Id, M_Name and M_Supplier from database
Mobile.
Consider:
host : localhost
UserName : root
Password : system
Database : Mobile

33. Consider the following tables GARMENT and FABRIC. Write SQL commands for the statements (i) to
(iv).

TABLE: GARMENT
GCODE DESCRI-PTION PRICE FCODE READY-DATE
10023 PENCIL SKIRT 1150 F03 19-DEC-08
10001 FORMAL SHIRT 1250 F01 12-JAN-08
10012 INFORMAL SHIRT 1550 F02 06-JUN-08
10024 BABY TOP 750 F03 07-APR-07
10090 TULIP SKIRT 850 F02 31-MAR-07
10019 EVENING GOWN 850 F03 06-JUN-08
10009 INFORMAL PANT 1500 F02 20-OCT-08
10007 FORMAL PANT 1350 F01 09-MAR-08
10020 FROCK 850 F04 09-SEP-07
10089 SLACKS 750 F03 20-OCT-08

TABLE: FABRIC
FCODE TYPE
F04 POLYSTER
F02 COTTON
F03 SILK
F01 TERELENE

(i) To display GCODE and DESCRIPTION of each GARMENT in descending order of GCODE.
(ii) To display the details of all the GARMENTs, which have READYDATE in between 08-DEC-07 and
16-JUN-08 (inclusive of both the dates).
(iii) To display the average PRICE of all the GARMENTs. Which are made up of FABRIC with FCODE as
F03.
(iv) To display FABRIC wise highest and lowest price of GARMENTs from GARMENT table.
(Display FCODE of each GARMENT alongwith highest and lowest price.)
NODIA APP Sample Paper 01 Page 9

34. Red Pandas Info-systems has its 4 blocks of buildings. The number of computers and distances between
them is given below :

Building Number of Computers

HR 15
ADMIN 100

SYSTEM 25
PERS 30

Building Distance

HR -Admin 10 m
HR- System 50 m

HR- Pers 750 m

Admin- System 300 m

Admin- Pers 20 m

System-Pers 250 m
Answer the following questions with respect to the above :
(i) Suggest a suitable cable layout for the network.
(ii) Suggest the best place to house the server of the network.
(iii) Which topology should be used to connect computers in each building?
(iv) What kind of network will be formed here? (LAN/MAN/WAN)
Page 10 Sample Paper 01 CBSE Computer Science Class 12

35. What is CSV file?


Write a program using two functions :
(a) addCustomer( ): To write Customer code, Customer name and Amt in file “[Link]”.
The details of the customers are as follows :
[‘CustCode’, ‘CustName’, ‘Amount’]
[‘001’, ‘Nihir’, ‘8000’]
[‘104’, ‘Akshay’, ‘5000’]
(b) readCustomer( ): To read the details of the customers and display them.
 or
When do we use CSV file?
Write a program using following functions :
(a) getlnventory() : Write code to accept as many inventory records and store them to the csv file Inventory.
csv storing records of inventory as per following structure
PCode Invname Price Reorder
(b) Display() : To display the detail that store in [Link]

SECTION - E
36. Consider the table MOVIE DETAILS given below

Table : MOVIEDETAILS
MOVIEID TITLE LANGUAGE RAT-ING PLAT-FORM
M001 Minari Korean 5 Netflix
M004 MGR Magan Tamil 4 Hotstar
M010 Kaagaz Hindi 3 Zee5
M011 Harry Potter and the Chamber of Secrets English 4 Prime Video
M015 Uri Hindi 5 Zee5
M020 Avengers: Endgame English 4 Hotstar

(i) Identify the degree and cardinality of the table.


(ii) Which field should be made the primary key? Justify your answer.
(iii) Write statements to :
(a) Delete the records whose language is “English”
(b) Add a new record : “M050”, “Palki”,“Hindi”, 5, “Amazon Prime”.
 (Option for part (iii) only)
or
Write statements to :
(a) Add a new column “DAYS” of type integer
(b) Remove the column “RATING”

ss
NODIA APP Sample Paper 01 Page 11

37. Below is a program to delete the line having word (passed as argument). Answer the questions that follow
to execute the program successfully.
import ......
def filedel (word):
file1 = open (“Python. txt ”,
“......”)
nfile = open (“[Link]”, “w”)
while True:
line = [Link]( )
if not line:
break
else :
if word in line :
......
else :
print(line)
nfile......(line)
[Link]()
[Link]()
filedel (‘write’)
(i) Name the module that should import in Line 1.
(ii) In which mode, above program should open the file to delete the line?
(iii) Fill the blank in Line 11 and Line 14.
(iv) Suggest an alternative way to open and read the file without using.
(v) Explain what happens if the specified word is not found in any line of “[Link]”.

 
NODIA APP Sample Paper 02 Page 1

Sample Paper 02
Computer Science (083)
CLASS XII 2025-26
Time: 3 Hours Max. Marks: 70
General Instructions:
1. This question paper contains 37 questions.
2. All questions are compulsory. However, internal choices have been provided in some questions. Attempt
only one of the choices in such questions
3. The paper is divided into 5 Sections- A, B, C, D and E.
4. Section A consists of 21 questions (1 to 21). Each question carries 1 Mark.
5. Section B consists of 7 questions (22 to 28). Each question carries 2 Marks.
6. Section C consists of 3 questions (29 to 31). Each question carries 3 Marks.
7. Section D consists of 4 questions (32 to 35). Each question carries 4 Marks.
8. Section E consists of 2 questions (36 to 37). Each question carries 5 Marks.
9. All programming questions are to be answered using Python Language only.
10. In case of MCQ, text of the correct answer should also be written.

SECTION A
1. State if the following statement is True or False:
In Python, the [Link]() function is used to serialize a Python object and write it to a binary file, while
[Link]() is used to read from the binary file and deserialize it back into a Python object.

2. What will be the output of the following Python code?


L1 = [10, 20, [30, 40, 50], 60]
print(L1[2][1] + L1[-1])
(A) 90 (B) 70
(C) 100 (D) 80

3. Consider the given expression:


print(15 2 > 35 or 4 + 6 == 10 and not 5 < 3)
Which of the following will be the correct output of the given expression?
(A) True (B) False
(C) None (D) Error

4. In SQL, which key is an attribute in one table that is used to refer to the primary key in another table,
thereby establishing a link between them?
(A) Primary Key (B) Alternate Key
(C) Foreign Key (D) Candidate Key
Page 2 Sample Paper 02 CBSE Computer Science Class 12

5. What will be the output of the following Python code?


text = “HelloWorld”
print([Link](‘l’, ‘L’, 2))

6. Write the output of the following Python code:


for num in range(10, 0, -3):
print(num, end=’-’)

7. What will be the output of the following Python statement:


(A) 31.2
(B) 4
(C) 31
(D) -18

8. A user wants to add a new column named DOB of DATE type to the STUDENT table. The user writes the
following SQL query:
MODIFY TABLE Student ADD DOB DATE;
Identify the error and provide the corrected query.
(A) ALTER TABLE Student ADD COLUMN DOB DATE;
(B) UPDATE TABLE Student ADD DOB DATE;
(C) ALTER TABLE Student ADD DOB DATE;
(D) MODIFY Student ADD COLUMN DOB DATE;

9. What will be the output of the following Python code?


data = [10, 20, 30]
try:
print(data[3])
except IndexError:
print(“Index Error”)
except:
print(“Some other error”)

10. What will be the output of the following Python code?


d = {‘a’: 1, ‘b’: 2, ‘c’: 3}
[Link](‘b’)
d[‘b’] = 4
print([Link](‘b’))

11. What possible output is expected to be displayed on the screen at the time of execution of the Python
program from the following code?
import random
fruits = [“Apple”, “Orange”, “Banana”, “Grape”]
chosen_fruit = [Link](fruits)
print(len(chosen_fruit), chosen_fruit[0], sep=’-’)
(A) 5-Apple
(B) 6-O
(C) 5-A
(D) Banana-6
NODIA APP Sample Paper 02 Page 3

12. What will be the output of the following Python code?


def modify_list(L):
[Link](100)
L = [1, 2, 3]
my_list = [10, 20]
modify_list(my_list)
print(my_list)
(A) [1, 2, 3]
(B) [10, 20, 100]
(C) [10, 20]
(D) [10, 20, 1, 2, 3]

13. Which DML command in SQL is used to modify existing records in a table?
(A) MODIFY
(B) ALTER
(C) INSERT
(D) UPDATE

14. What is the output of the given Python code?


items = [‘p’, ‘y’, ‘t’, ‘h’, ‘o’, ‘n’]
result = “-”.join(items)
print(result)
(A) p-y-t-h-o-n
(B) [“p-y-t-h-o-n”]
(C) p y t h o n
(D) TypeError

15. In SQL, a table ‘EMPLOYEE’ has attributes EID, Ename, Salary, and Dept. What is the degree of this
relation?
(A) Degree: 1
(B) Degree: 2
(C) Degree: 3
(D) Degree: 4

16. Which of the following SQL commands is used to add a new row of data into a table?
(A) ADD ROW
(B) CREATE
(C) INSERT INTO
(D) UPDATE

17. _________ is the standard protocol for sending emails across the Internet. It is a push protocol and is
used to send the mail, whereas POP3 or IMAP are used to retrieve it.
(A) HTTP
(B) FTP
(C) PPP
(D) SMTP
Page 4 Sample Paper 02 CBSE Computer Science Class 12

18. Which network device operates at the Network Layer (Layer 3) of the OSI model and is used to connect
different networks together, making decisions about the best path for data packets?
(A) Hub (B) Switch
(C) Repeater (D) Router

19. What does URL stand for, which is essentially the address of a given unique resource on the Web?
(A) Universal Resource Link (B) Uniform Resource Locator
(C) Unified Resource Link (D) Uniform Resource Linker

20. Assertion (A): A Python tuple is immutable, meaning its elements cannot be changed after creation.
Reason (R): If a tuple contains a mutable element like a list, the contents of that list can be modified.
(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 the correct explanation for A.
(C) A is True but R is False.
(D) A is False but R is True.

21. Assertion (A): In SQL, the LIKE operator is used with the WHERE clause for pattern matching in string
values.
Reason (R): The ‘%’ wildcard used with LIKE matches any single character.
(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 the correct explanation for A.
(C) A is True but R is False.
(D) A is False but R is True.

SECTION - B
22. Find the error in following (s).
L1 = [7, 2, 3, 4] Statement 1
L2 = L1 + 2 Statement 2
L3 = L1 * 2 Statement 3
L = [Link](7) Statement 4

23. (a) Observe the code and write the output:


t = ‘APPLE’
t1 = tuple(t)
print(t1)
(b) Predict the output of the following code
x = (2, 3, 4)
y = (3, 4)
t = x + y
print(t)

24. Name two switching techniques used to transfer data between two terminals (computers).
 or
Arrange the following network in ascending order of their area:
LAN, PAN, WAN, MAN

25. Differentiate between an attribute and a tuple with an example.


NODIA APP Sample Paper 02 Page 5

26. (a) Write the hill forms of


(i) WVVW
(ii) TCP/IP
(b) List down the types of computer networks.

27. Identify the output of the following Python code.


D = {1: “One”, 2: “Two”, 3: “Three”}
L = [ ]
for K, V in [Link]():
if V[0] = = “T”:
[Link] (K)
print(L)
 or
Identify the output of the following Python statement.
lst1 = [10, 15, 20, 25, 30]
[Link](3, 4)
[Link](2, 3)
print (lst1[– 5])

28. Describe the following terms


(i) Domain
(ii) DB2
 or
Identify commands/functions for the following actions :
(i) To add a new column to a table.
(ii) To get the sum of all values in a column of a table.

SECTION - C
29. Write a function Del() to delete the 4th word from a text file [Link].
 or
Write a function countmy( ) in Python to read the text file “[Link]” and count the number of times “my”
occurs in the file.
For example If the file contents are:
My first book was. Me and My Family.
It gave me chance to be known to the world.
The output of the function should be
No. of times “my” occur : 2

30. Write Push (contents) and Pop (contents) methods in Python to add numbers and remove numbers
considering them to act as Push and Pop operations of stack.
 or
Write the Push operation of stack containing person names. Notice that the name should only accept
characters, spaces and period (.) except digits. Assume that Pname is a class instance attribute.
Page 6 Sample Paper 02 CBSE Computer Science Class 12

31. Write a user-defined function find-name (name), where name is an argument in Python to delete phone
number from a dictionary phone-book on the basis of the name, where name is the key.
 or
Given below is a code to open a text file and perform some operations on it. Answer questions with respect
to the code given
myfile=open(“[Link]”, “r”)
s =.......... Line 2
print(s)
[Link]( )
(i) In which mode is the file opend?
(ii) If the entire file is to be read, write a statement in place of Line 2.
(iii) What is the original code performing?

SECTION - D
32. Does python create a file itself if the file doesn’t exist in the memory? Illustrate your answer with an
example:
Write a program using following functions :
(a) inputStud() :To input details of as many students and add them to a csv file “[Link]” without
removing the previous records.
SrNo Studname City Percentage
(b) readCollege() : To open the file “[Link]” and display records whose city is “Kolkata”
 or
Write a statement to create a [Link] file with the following text.
Python file handling is very interesting and useful.
Write a python code using two functions as follows
(a) removerow( ) : To remove a record from the college file “[Link]” having following structure.
SrNo Studname City Percentage
(b) getCollege( ) : To read the records of the college file “[Link]” and display names of students whose
names start with a lowercase vowel.

33. (a) Consider the tables CARS and SUPPLIER given below. What will be the output of the statement
given?
TABLE: CARS
Ccode Car-Name Make Color Capa-city Cha-rges Scode
501 A-star Suzuki RED 3 14 1
503 Indigo Tata SILVER 3 12 2
502 Innova Toyota WHITE 7 15 2
509 SX4 Suzuki SILVER 4 14 2
510 C-Class Merc-edes RED 4 35 4

Table : SUPPLIER
Scode Sname
1 Great Suppliers
2 Himalayan Vehicles
3 Road Motors
4 Speed
NODIA APP Sample Paper 02 Page 7

SELECT CarName, Sname, Charges FROM CARS C, SUPPLIER S WHERE [Link]= S. Scode
AND Charges > 15;
(b) Write the output for SQL queries (i) to (iv), which are based on the table CARDEN.

TABLE: CARDEN
C code Car Name Make Color Capa-city Charges
501 A-star Suzuki RED 3 14
503 Indigo Tata SILVER 3 12
502 Innova Toyota WHITE 7 15
509 SX4 Suzuki SILVER 4 14
510 C-Class Mercedes RED 4 35
(i) SELECT COUNT(DISTINCT Make) FROM CARDEN;
(ii) SELECT COUNT(*) Make FROM CARDEN;
(iii) SELECT CarName FROM CARDEN WHERE Capacity = 4;
(iv) SELECT SUM (Charges) FROM CARDEN WHERE Color = “SILVER”;

34. Write the output of the queries (i) to (iv) based on the table FURNITURE given below.

Table : FURNITURE
FID NAME DATE OF PURCHASE COST DISCOUNT

B001 Double Bed 03-JAN-2018 45000 10

T010 Dinning Table 10-MAR-2020 51000 5

B004 Single Bed 19-JUL-2021 22000 0

C003 Long back Chair 30-DEC-2016 12000 3

T006 Console Table 17-NOV-2019 15000 12

B006 Bunk bed 01-JAN-2021 28000 14

(i) SELECT SUM(DISCOUNT) FROM FURNITURE WHERE COST>15000;


(ii) SELECT MAX(DATEOFPURCHASE) FROM FURNITURE;
(iii) SELECT * FROM FURNITURE WHERE DISCOUNT>5 AND FID LIKE “T%”;
(iv) SELECT DATEOFPURCHASE FROM FURNITURE WHERE NAME IN (“Dinning Table”, “Console
Table”);

35. Sony corporation has set up its 4 offices in the city of Srinagar, with its offices X, Z, Y, U:
Page 8 Sample Paper 02 CBSE Computer Science Class 12

Branch to Branch distance is given below:

X to Z 40 m
Z to Y 60 m
Y to X 135 m
X to U 70 m
Z to U 165 m
Z to U 80 m
Number of computers in each of the offices is as follows:

X 50
Z 130
Y 40
U 15
(i) Suggest a suitable cable layout of connectivity of the offices.
(ii) Suggest placement of server in the network with suitable reason.
(iii) Suggest placement of following devices in the network:
(a) Switch/Hub
(b) Repeater
(iv) Suggest a suitable topology for connecting the computers in each building.

SECTION - E
36. Consider the table APPLICANTS

TABLE: APPLICANTS
No NAME FEE GEN-DER C_ID JOINYEAR

1012 Amandeep 30000 M A01 2012


1102 Avisha 25000 F A02 2009
1103 Ekant 30000 M A02 2011
1049 Arun 30000 M A03 2009
1025 Amber 40000 M A02 2011
1106 Ela 40000 F A05 2010
1017 Nikita 35000 F A03 2012
1108 Arluna 30000 F A03 2012
2109 Shakti 35000 M A04 2011
1101 Kirat 25000 M A01 2012
(i) Which field qualifies to be the Primary key.
(ii) If all the records of Male applicants are deleted, what will be the cardinality of the table.
(iii) Write statements to
(a) Increase FEE of “M” (Male) applicatnts by 2000.
(b) Display details of “F” (Female) applicants in descending order of FEE.
NODIA APP Sample Paper 02 Page 9

 or
(Option for part (iii) only)
Write statements to
(a) Change width of column FEE to 20.
(b) Remove the column C_ID.

37. (a) Carefully observe the following Python code and answer the question that follow:
x = 5
def func2():
x = 3
global x
x = x + 1
print(x)
print(x)
On execution the above code, produces the following output:
6
3
Explain the output with respect to the scope of the variables.
(b) Write the code to create a table Product in database Inventory with following fields

Fields Datatype
PID varchar(5)
PName char(30)
Price float
Rank varchar(2)

Note the following to establish the connection between Python and MySQL:
Host : localhost
Username : system
Password : hello
Database : Inventory

 EN
NODIA APP Sample Paper 05 Page 1

Sample Paper 05
Computer Science (083)
CLASS XII 2025-26
Time: 3 Hours Max. Marks: 70
General Instructions:
1. This question paper contains 37 questions.
2. All questions are compulsory. However, internal choices have been provided in some questions. Attempt
only one of the choices in such questions
3. The paper is divided into 5 Sections- A, B, C, D and E.
4. Section A consists of 21 questions (1 to 21). Each question carries 1 Mark.
5. Section B consists of 7 questions (22 to 28). Each question carries 2 Marks.
6. Section C consists of 3 questions (29 to 31). Each question carries 3 Marks.
7. Section D consists of 4 questions (32 to 35). Each question carries 4 Marks.
8. Section E consists of 2 questions (36 to 37). Each question carries 5 Marks.
9. All programming questions are to be answered using Python Language only.
10. In case of MCQ, text of the correct answer should also be written.

SECTION A
1. State if the following statement is True or False:
In Python, a variable created inside a function is local by default and cannot be accessed from outside that
function.

2. What will be the output of the following Python code?


T1 = (10, 20)
T2 = (30,)
print(T1 2 + T2)
(A) (20, 40, 30) (B) (10, 20, 10, 20, 30)
(C) (10, 20, 30) (D) TypeError

3. Consider the given expression:


print([] and “Hello” or (not 0))
Which of the following will be the correct output of the given expression?
(A) False (B) True
(C) Hello (D) []

4. In SQL, which command is used to modify the structure of a database table, such as adding, deleting, or
modifying columns?
(A) UPDATE (B) MODIFY TABLE
(C) ALTER TABLE (D) EDIT TABLE
Page 2 Sample Paper 05 CBSE Computer Science Class 12

5. What will be the output of the following Python code?


L = [xx for x in range(5)]
print(L[-1])

6. Write the output of the following Python code:


i = 5
while i > 0:
print(i, end=’ ‘)
i -= 2
if i == 1:
break
(A) 5 3 1 (B) 5 3
(C) 5 4 3 2 1 (D) 5 3 1 -1

7. What will be the output of the following Python statement:


print(20 // 3 % 2 5)

8. A user is trying to create a table PRODUCTS but the query fails.


CREATE TABLE PRODUCTS (PID INTEGER PRIMARY, PName VARCHAR(20), Price FLOAT);
Identify the error and provide the corrected query.
(A) Data type INTEGER should be INT.
(B) PRIMARY should be PRIMARY KEY.
(C) VARCHAR size should not be specified.
(D) CREATE PRODUCTS should be used instead.

9. What will be the output of the following Python code?


try:
x = 10 / 2
except ZeroDivisionError:
print(“Divide Error”)
else:
print(“Success”)

10. What will be the output of the following Python code?


d1 = {‘a’: 1, ‘b’: 2}
d2 = {‘b’: 3, ‘c’: 4}
[Link](d2)
print(d1)
(A) {‘a’: 1, ‘b’: 2, ‘c’: 4} (B) {‘a’: 1, ‘b’: 3, ‘c’: 4}
(C) {‘a’: 1, ‘b’: 2, ‘b’: 3, ‘c’: 4} (D) {‘a’: 1, ‘c’: 4}

11. What possible output is expected to be displayed on the screen at the time of execution of the Python
program from the following code?
import random
word = “PYTHON”
char = [Link](word)
print(char, [Link](char))
(A) P 0 (B) T 2
(C) N 5 (D) All of the above
NODIA APP Sample Paper 05 Page 3

12. What will be the output of the following Python code?


value = 100
def update_value():
global value
value = value + 50
update_value()
print(value)
(A) 100 (B) 150
(C) Error (D) 50

13. In SQL, which clause is used to filter the results of a GROUP BY based on an aggregate function?
(A) WHERE (B) FILTER
(C) HAVING (D) RESTRICT

14. What is the output of the given Python code?


text = “New Delhi”
print([Link](“del”))

15. Which of the following SQL statements is a DDL command that removes all rows from a table without
logging the individual row deletions, making it faster than DELETE?
(A) DROP (B) REMOVE ALL
(C) TRUNCATE (D) CLEAR

16. Which of the following is considered a Data Definition Language (DDL) command in SQL?
(A) SELECT (B) INSERT
(C) CREATE (D) UPDATE

17. Which protocol enables real-time, two-way voice communication over the internet, allowing users to make
phone calls using an internet connection instead of a traditional phone line?
(A) SMTP (B) VoIP
(C) PPP (D) HTTP

18. In a computer network, which device broadcasts an incoming data packet to all other connected ports,
unlike a switch which sends it only to the intended destination?
(A) Router (B) Modem
(C) Gateway (D) Hub

19. What is the term for a service that allows organizations and individuals to post a website or web page onto
the Internet, making it accessible to others on the World Wide Web?
(A) Web Browser (B) Web Server
(C) Web Hosting (D) Domain Name

20. Assertion (A): The expression my_list[:] in Python creates a shallow copy of my_list.
Reason (R): Slicing a list always creates a new list object, and a full slice [:] copies all references from the
original list into this new list object.
(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 the correct explanation for A.
(C) A is True but R is False.
(D) A is False but R is True.
Page 4 Sample Paper 05 CBSE Computer Science Class 12

21. Assertion (A): In SQL, a column with a UNIQUE constraint can contain multiple NULL values.
Reason (R): The UNIQUE constraint ensures that all values in the column are different from each other,
and NULL is not considered equal to another NULL.
(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 the correct explanation for A.
(C) A is True but R is False.
(D) A is False but R is True.

SECTION B
22. Observe the given list and find the answer of questions that follows.
list1 = [23, 45, 63, ‘Hello’, 20
‘World’, 15, 18]
(i) list1[–3]
(ii) list1[3]

23. (i) Find the output


L = [15, 28, 55, 88, 15, 33, 5]
(a) L[2:6]
(b) L[::-3]
(ii) Find the error(s).
L1 = [7, 2, 3, 4]
L2 = L1 + 2
L3 = L1 * 2
L = [Link](7)

24. What is the advantage of using switch over hub?


 or
Write some benefits of networking.

25. What do you understand by RDMS?

26. (a) Write the full forms of :


(i) POP
(ii) HTTP
(b) Differentiate between the terms Internet and Intranet.

27. What will be the output of the following code?


dic = {‘a’:1, ‘b’:2, ‘c’:3, ‘d’:4}
print(dic)
if ‘a’ in dic :
del dic[‘a’]
print(dic)
 or
Distinguish between tuple and list.
NODIA APP Sample Paper 05 Page 5

28. Describe the concept of candidate keys and provide a suitable example to illustrate.
 or
Observe the following table carefully and write the names of the most appropriate columns, which can be
considered as (i) candidate keys and (ii) primary key.
Table: Product
CID CNAME AMOUNT COUNTRY ITEM
101 ALLE 100000 JMEKA SHOES
111 BEN 20000 FRANCE HELMET
110 RIKI 25000 AMERICA BAG
011 BRETT LEE 105000 AUSTRALIA BAT

SECTION C
29. Write Push(contents) and Pop() methods in Python to add and remove numbers, simulating stack operations.
 or
Find the final contents of a stack on which the following operations are done.
1. Push(100)
2. Push(200)
3. Push(50)
4. Push(50)
5. Pop()
6. Push()
7. Pop(2)
8. Pop()

30. The binary file “[Link]” contains employee records with the following structure:
Eno Ename Salary
1 Mr. Raj 85000
h
Write a Python program to open “[Link]” and display only the records where the employee’s salary
exceeds 75000.
 or
Write a program to read the content from a text file “[Link]”, count and display the total number of lines
and blank spaces present in it. e.g. if the “[Link]” 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
Page 6 Sample Paper 05 CBSE Computer Science Class 12

31. The code given below reads a text file and displays those words that begin with an uppercase vowel and end
with a lowercase vowel . Some of the codes are missing .Write codes to fill up the blanks.
f=open(“[Link]”)
filedata=[Link]()
count=0
print(filedata)
data=[Link](‘ ’)
for.......... in data : #Blank1
if words[–1] in “aeiou” and ...in “AEIOU”: # Blank2
print(......... .) # Blank3
[Link]()
(i) Write the missing code for Blank1.
(ii) Write the missing code for Blank2.
(iii) Write the missing code for Blank3.
 or
Write a user defined function change(L) to accept a list of numbers and replace the numbers in the list with
their sum of digits.
Example
Input : [32,142,215,26,7]
Output : [5, 7 , 8 , 8, 8,7]

SECTION D
32. (a) Underline the syntax errors in the following program
x = int(input(“Enter first number:))
y = int(input(“Enter second number:”))
z = int(input(“Enter third number:”)
a = x+ b+ z
print (“Result = ”, b)
(b) Write the code to create the following table Student with the following fields
RollNo
FirstName
LastName
Address
ContactNo
Marks
Course
Rank
In the table, Rank should be Good, Best, Bad, Worst, Average.
 or
(a) Differentiate between a logical error and syntax error. Also, give suitable examples of each in Python.
(b) What is the use of fetchone() method? Write an example code to fetch a single record from a database.
Note :
Database : PythonDB
Table : Student
Host : localhost
UsedlD : root
Password : arihant
NODIA APP Sample Paper 05 Page 7

33. Which module is used to operate on CSV file?


Write a python program with following functions :
(a) addcsv():
File [Link] has come from branch in Pune and it needs to be added to file “[Link]” which has
data for all branches. Write the code in the function to perform the same.
(b) convertcsv() :
A file [Link] has come with separator ‘:’ but your system can only read ‘;’ Write a program to convert
to “[Link]” file. Write the function to change the separator of the file.

34. (a) Consider the tables Travel and Train given below.

Table : Travel
Tcno Pname Class TId Amt
1 Rahul AC T1 2500
2 Sujit SL T2 4500
3 Ravi AC T1 6000
4 Ankita AC T3 1800

Table : Train
TId Tname
T1 Rajdhani
T2 Himgiri Exp
T3 Darjeeling Mail

Write the command to display the passenger names and the train names by which they are travelling for all
passengers travelling by “Mail” trains.
(b) Considering the tables Train and Travel given above write commands for the following :
(i) Display passenger names , corresponding train names and amounts for records where amount
>5000.
(ii) Increase amount of passengers by 20% who are travelling by ‘AC”
(iii) Display a cross join of the two tables.
 or
(iv) Remove records of passengers who are travelling by “Rajdhani”.

35. Consider the following tables SENDER and RECIPINT. Write SQL commands for the statements (i) to
(iv).

TABLE: SENDER
SenderlD SenderName SenderAddress SenderCity
ND01 R Jain 2, ABC Appts New Delhi
MU02 H Sinha 12, Newtown Mumbai
MU15 S Jha 27/A, Park Street Mumbai
ND50 T Prasad 122-K, SDA New Delhi
Page 8 Sample Paper 05 CBSE Computer Science Class 12

TABLE: RECIPIENT
RecID SenderlD RecName RecAddress RecCity
KO05 ND01 R Bajpayee 5, Central Avenue Kolkata
ND08 MU02 S Mahajan 116, A Vihar New Delhi
MU19 ND01 H Singh 2A, Andheri East Mumbai
MU32 MU15 P K Swamy B5, C S Terminus Mumbai
ND48 ND50 S Tripathi 13, B1 D, Mayur Vihar New Delhi
(i) To display the names of all Senders from Mumbai.
(ii) To display the RecID, SenderName, SenderAddress, RecName, RecAddress for every Recipient.
(iii) To display Recipient details in ascending order of RecName.
(iv) To display number of Recipients from each City.

SECTION E
36. Freshminds University of India is launching its first campus in Ana Nagar, South India, with a central
admissions office in Kolkata. The campus spans 5 km and consists of three main blocks: Office, Science, and
Commerce.
As a network expert, propose a network plan addressing points (i) to (v), considering the given distances
and parameters.

Expected wire distance between various locations.


Office Block to Science Block 90 m
Office Block to Commerce Block 80 m
Science Block to Commerce Block 15 m
Kolkata Admission Office to Ana Nagar Campus 450 km
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
NODIA APP Sample Paper 05 Page 9

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

37. Consider the following table Person

P_Id LastName First Name Address City


1 Hansen Ola Timoteivn 10 Sandnes
2 Svendson Tove Borgvn 23 Sandnes
3 Pettersen Kari Storgt 20 Stavanger
4 Nilsen Johan Bakken 2 Stavanger
(i) What should be the constraint(s) of the P_Id column?
(ii) If 3 columns are added to the table , what will be its degree?
(iii) Write statements to :
(a) Display the Unique Cities.
(b) Display Firstnames of people who do not have a address.
 or
(Option for part (iii) only)
Write appropriate data types to store the following :
(a) Amounts carrying values with decimal.
(b) Joining dates.

 EN

You might also like