Class 12 Computer Science Sample Paper
Class 12 Computer Science Sample Paper
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.
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?
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;
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
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()
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.
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
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
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
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 :
HR 15
ADMIN 100
SYSTEM 25
PERS 30
Building Distance
HR -Admin 10 m
HR- System 50 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
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
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.
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
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;
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
13. Which DML command in SQL is used to modify existing records in a table?
(A) MODIFY
(B) ALTER
(C) INSERT
(D) UPDATE
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
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
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
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
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
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.
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
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
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
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]
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
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.
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?
EN