SAMPLE QUESTION PAPER
COMPUTER SCIENCE (803)
Class XII (Session 2024-25)
Time Allowed: 3 Hours Maximum Marks: 70
General Instructions:
● This question paper contains 37 questions.
● The paper is divided into 5 Sections- A, B, C, D, and E.
● Section A consists of 21 questions (1 to 21). Each question carries 1 Mark.
● Section B consists of 7 questions (22 to 28). Each question carries 2 Marks.
● Section C consists of 3 questions (29 to 31). Each question carries 3 Marks.
● Section D consists of 4 questions (32 to 35). Each question carries 4 Marks.
● Section E consists of 2 questions (36 to 37). Each question carries 5 Marks.
● All programming questions are to be answered using Python Language only.
● In case of MCQ, text of correct answer should also be written.
SECTION A: OBJECTIVE TYPE QUESTIONS (21 × 1 = 21 Marks)
i. State True or False: 1
“In a Python program, continue statement terminates the execution of the
loop.”
ii. What will be the output produced on the execution of the following 1
statement?
print(5 - 100// 5 ** 2 * 3 / 2)
a. -0.5 b. -1.0
c. -244.0 d. Error
iii. What will be the output produced on the execution of the following code 1
snippet?
quote = "Be HAppy AlwayS!"
L = quote.split()
print(L[::-1])
a. ['Be', 'HAppy', 'AlwayS!'] b. ['eB', 'yppAH', '!SyawlA']
c. ['AlwayS!', 'HAppy', 'Be'] d. []
iv. Which of the following is a relational operator? 1
a. +=
b. !=
c. *=
d. **=
[1]
v. Which of the following will delete the key-value pair for key "marks" from a 1
dictionary result?
a. delete result("marks")
b. del result["marks"]
c. del.result["marks"]
d. result.del["marks"]
vi. What will be the output produced on the execution of the following code 1
snippet?
myDict = {"Pen" : "Reynolds", "Pencil" : "Natraj" ,
"Eraser" : "Pulsar" }
str1 = ""
for i in myDict:
str1 = str1 + str(myDict[i]) + '#'
for x in str1[5:15:3]:
if x not in "aeiou":
print(x, end = "*")
a. s*
b. l*#*t*j*
c. l*#*t*
d. yndsr
7. Which statement(s) would yield an error while executing the following code 1
snippet?
tup = (20,30,40,50,80,79)
print(tup) #Statement 1
print(tup[3]+50) #Statement 2
print(max(tup)) #Statement 3
tup[4]=80 #Statement 4
a. Statement 1
b. Statement 2
c. Statement 3
d. Statement 4
8. Consider the code snippet given below. 1
import random
maximum = 5
myNum = int (20 + random.random()* maximum)
for num in range (myNum,26):
print (num, '*',end =' ')
Which of the following is NOT a possible output produced on executing the
above code snippet?
[2]
a. 21 * 22 * 23 * 24 * 25 *
b. 20 * 21 * 22 *
c. 24 * 25 *
d. 23 * 24 * 25 *
9. In a table in the MySQL database, an attribute A of datatype varchar(10) has 1
the value "India". The attribute B of datatype char(10) has the value "Bharat".
How many bytes are occupied by attributes A and B, respectively?
a. 5, 10
b. 6, 10
c. 10,5
d. 5, 6
10. Which of the following is an immutable data object? 1
a. [3,4]
b. (3,4)
c. {3:4}
d. None
11. What will be the output produced on the execution of the following code 1
snippet?
num = 40
def test():
num = num + 10
test()
print(num)
a. 40
b. 50
c. 10
d. Error
12. State whether the following statement is True or False: 1
While handling an exception in Python, the finally block is always executed.
13. In MySQL database, if a table, Cake, has degree 6 and cardinality 4, and 1
another table, Drinks, has degree 3 and cardinality 2, what will be the degree
and cardinality of the Cartesian product of Cake and Drinks, respectively?
a. 8, 7 b. 8, 9
c. 7, 8 d. 9, 8
14. Which of the following statements will be used to view the list of tables in a 1
database?
a. VIEW TABLES;
b. DISPLAY TABLES;
c. SHOW TABLES;
d. PRINT TABLES;
[3]
15 Which of the following establishes a relationship between two tables? 1
a. Primary Key
b. Alternate Key
c. Foreign Key
d. Composite Key
16. Which of the following is a DDL command? 1
a. SELECT
b. DELETE
c. DROP
d. UPDATE
17. Which of the following protocols is used while video conferencing? 1
a. PPP
b. FTP
c. VoIP
d. HTTP
18. Riya wants to share a document with her friend using Bluetooth technology. 1
Which type of network will be formed in this case?
a. PAN
b. LAN
c. MAN
d. WAN
19. Which of the following is NOT a networking device? 1
a. Switch
b. Modem
c. Hub
d. Bus
Q20 and 21 are Assertion(A) AND Reason(R) based questions. Mark the 1
correct choice as
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.
20. Assertion (A): A list in Python can hold elements of different data types. 1
Reason (R): Python lists are implemented as arrays, which require all
elements to be of the same type to maintain fixed-size memory allocation.
21. myString = "Good" + "Day" 1
Assertion(A): The value of myString will be 'GoodDay'
Reason (R): The operator '+' appends one string after another.
[4]
SECTION B: SUBJECTIVE TYPE QUESTIONS (7 × 2 = 14)
22. Examine the following code and rewrite it after removing all syntax and logical 2
errors so that on its execution, it produces the following output:
0
1
4
9
16
Underline all the corrections made.
def test(num)
for x in range(num):
print(x * x)
value = input("Enter a number: ")
test()
23. Write a function that takes a string, message, and a number num as 2
arguments. The function should display all vowels in the string message, num
times, in the same sequence in which they appear in the input string. If a
vowel appears multiple times, it should still be displayed num times, but not
repeatedly, for multiple occurrences of the same vowel.
For example, if the value of the message is "helicopter" and the value of num
is 5, the output should be:
eeeeeiiiiiooooo
OR
Write a Python function lenWords(sentence) that takes a string as input and
returns a dictionary where each word in the string is a key, and the value is
the length of that word.
For example, if the input string is "Come let us have some fun", the function
should return the dictionary:
{'Come': 4, 'let': 3, 'us': 2, 'have': 4, 'some': 4, 'fun': 3}
24. Write a Python statement for each of the following tasks using BUILT-IN 2
functions/methods only:
a. To display the number of times the element "go" appears in a list, L1.
b. To check whether the last three characters of string words are "and".
25. What will be the output produced on the execution of the following code 2
snippet?
Moves = [-10, 5, 15, 10]
Queen = Moves
Moves[2] += 22
length = len(Moves)
[5]
for i in range (length):
print("Now@", Queen[length-i-1], "#",
Moves[i])
26. Abdul has created a table named Gadgets in MySQL with the following fields 2
– gadgetId, gadgetName, price, qty, category, model
He wants to perform the following tasks on the table:
a) View the structure of the table.
b) Delete the attribute Category from the table
Write the commands required to complete the tasks.
OR
Differentiate between DDL and DML commands in SQL, giving suitable
examples.
27. Consider the table, GARMENT given below: 2
Table: GARMENT
GCODE GNAME SIZE COLOUR PRICE
111 Tshirt XL Red 1400.00
112 Jeans L Blue 1600.00
113 Skirt M Black 1100.00
114 Jacket XL Blue 4000.00
115 Trousers L Brown 1500.00
116 Ladies Top L Pink 1200.00
a. Suggest a suitable primary key for the above table. Justify your answer.
b. What is the degree and cardinality of the table?
OR
Write the SQL commands to:
(i) View the structure of the table, Cards
(ii) Delete the database named School.
28. (i) Expand the following terms: 2
ARPANET, XML
(ii) Give one application of TELNET.
OR
Briefly describe the tree topology with the help of an example.
SECTION C: (3 × 3 = 9 Marks)
29. A) Write a function wordsOfAir(filename) that takes the name of a text file as 2
an argument, reads the file's contents, and returns a list of words from the file
that begins with "Air".
OR
B) Write a function, longWords(), that reads a text file named poets.txt and
counts the number of words more than six characters long.
[6]
30. Samvit has created a dictionary, myDict, containing the names and ages of his
friends as key-value pairs. Write a program with user-defined functions to
perform the following operations:
● pushKeys(myDict) to push the keys (names of the student) of those
friends whose age is less than 25 onto a stack.
● display() to display the contents of the stack
For example:
If the content of the dictionary is as follows:
R = {'Joan':15, 'Ritu':50, 'Beenu':19, 'Alice':26,
'Simreet':29, 'Tintin':24}
The program should output the following:
Tintin Beenu Joan
OR
Asha wants to input ten numbers and store them in a list. After that, she
intends to extract only the even numbers and store them in a stack. Write a
function that accepts the list as an argument, creates the stack containing only
even numbers, displays the stack, and then shows the largest element in the
stack.
For example, if the user enters the following numbers:
1 , 8 , 5 , 2 , 90 , 4 , -4 , -10 , 40 , 99
The output will be :
The stack is [40, -10, -4, 4 , 90 , 2, 8]
The maximum value of stack is 90
31. What will be the output produced on the execution of the following code
snippet?
advise = "#GenZ 2 each"
count = 0
for ch in advise:
if not ch.isspace():
advise = advise[0:4] + 'z'
elif 'e' in advise:
advise = advise[0] + '$@'
elif 'Z' not in advise:
advise = '9' + advise[1:] + 'z'
count += 5
else:
[7]
advise = advise + 'PLS'
print("The coded string is", advise)
print("The count is ", count)
OR
What will be the output produced on the execution of the following code
snippet?
myList = [10, 20, 40]
sum = 0
for myList[-1] in myList:
print(myList[-1], end = "**")
sum += myList[-1] // 2
print('sum=', sum)
SECTION D: (4 × 4 = 16 Marks)
32. *Consider the table CLUB given below. 2
CID CNAME AGE GENDER SPORTS PAY DOAPP
5246 AMRITA 35 FEMALE CHESS 900 2006-03-27
4687 SHYAM 37 MALE CRICKET 1300 2004-04-15
1245 MEENA 23 FEMALE VOLLEYBALL 1000 2007-06-18
1622 AMRIT 28 MALE KARATE 1000 2007-09-05
1256 AMINA 36 FEMALE CHESS 1100 NULL
1720 MANJU 33 FEMALE KARATE 1250 2004-04-10
2321 VIRAT 35 MALE CRICKET 1050 2005-04-30
Write the output on executing the following SQL queries:
(i) SELECT COUNT(DISTINCT SPORTS)
FROM CLUB;
(ii) SELECT CNAME, SPORTS
FROM CLUB
WHERE DOAPP<"2006-04-30";
(iii) SELECT CNAME, AGE, PAY
FROM CLUB
WHERE GENDER = "MALE" AND
PAY BETWEEN 1000 AND 1200;
(iv) SELECT * FROM CLUB
WHERE GENDER = “FEMALE” ORDER BY PAY
[8]
OR
Consider the table CLUB given below.
CID CNAME AGE GENDER SPORTS PAY DOAPP
5246 AMRITA 35 FEMALE CHESS 900 2006-03-27
4687 SHYAM 37 MALE CRICKET 1300 2004-04-15
1245 MEENA 23 FEMALE VOLLEYBALL 1000 2007-06-18
1622 AMRIT 28 MALE KARATE 1000 2007-09-05
1256 AMINA 36 FEMALE CHESS 1100 NULL
1720 MANJU 33 FEMALE KARATE 1250 2004-04-10
2321 VIRAT 35 MALE CRICKET 1050 2005-04-30
Write SQL queries to perform the following operations:
(i) Display records of club members whose date of application is not known
(ii) Display the average age of all club members.
(iii) Increase the pay of female employees by 500.
(iv) Delete the records of club members whose age is less than 25
33. Write a Program in Python that defines and calls the following user-defined
functions:
(i) addRecord() – To accept and add data from a book and save it to a CSV file,
bookRecord.csv. Each record consists of a list with the following elements:
[bookId, bookName, price]
(ii) countPrice() – To count and return the number of books with a price of
more than 500.
34. Write queries (a) to (d) based on the tables VEHICLE and OWNER given below:
TABLE: VEHICLE
VNO COMPANY MODEL MAKE PRICE
HR06AB1234 Kia SELTOS 2020 18.5
DL27CD5243 Honda AMAZE 2021 12.5
RJ27BK3245 MARUTI SUZUKI ALTO K10 2021 9.3
MP14AJ0053 Hyundai VENUE 2020 15.5
DL30KA2364 Hyundai CRETA 2023 10.8
MP05AB1233 Kia SELTOS 2021 20.1
[9]
TABLE: OWNER
ID OWNER_NAME AGE CITY VNO
101 Farooq 35 Bhopal MP14AJ0053
102 Anvesha 40 Delhi DL27CD5243
103 Ritesh 45 Delhi DL30KA2364
104 Abhishek 30 Gurugram HR06AB1234
105 Asha 25 Jaipur RJ27BK3245
(i) Display the owner's name and vehicle’s model from the tables VEHICLE and
OWNER for the owners from Delhi.
(ii) Display the total price of each model from the table VEHICLE.
(iii) Display the vehicle number, Owner name, and model of vehicles whose
vehicle number begins with “HR”.
(iv) Display the number of people who own a Kia car.
OR
Display the cartesian product of two tables VEHICLE and OWNER.
35. Bharti wants to write a program in Python to insert the following record in the
table named SchoolTeam in the MySQL database EVENTS:
TeamId(Student Id)- integer
name(Name) - string
Captain (name of captain) - string
Note the following to establish connectivity between Python and MySQL:
Username - root
Password - tiger
Host - localhost
The user must accept the values of all fields. Helped Bharti write the program
in Python.
SECTION E: (2 × 5 = 10 Marks)
36. A binary file, admission.dat stores data using the list objects, each object 2
comprising three components: [admNo, Name, Percentage].
(i) Write a function, addInfo(), that accepts data from the user and appends
it to the binary file.
(ii) Write a function to display all records from the binary file.
(iii) Write a function, showMerit(), that reads the contents of the
admission.dat file and displays the details of those students whose
percentage is above 75. The function should also return the number of
students scoring above 75.
[10]
37. GOODRUN Technologies Ltd is a Delhi-based organisation expanding its office
setup to Chandigarh. The Chandigarh office campus plans to have three blocks
for HR, Accounts, and Logistics related work. Each block has several
computers, which must be connected to a network for communication, data,
and resource sharing. As a network consultant, you must suggest the best
network-related solutions for issues/problems raised in (i) to (v), considering
the distances between various blocks/locations and other given parameters.
(a) Suggest the most appropriate block/location to house the SERVER in the
CHANDIGARH Office (out of the 3 Blocks) to get the most effective
connectivity. Justify your answer.
(b) Draw the cable layout (block to block) to connect various blocks efficiently
within the CHANDIGARH office compound.
(c) In continuation of your answer to the question in part(b), which of the
following kinds of networks would you recommend?
(A) PAN (B) WAN (C) MAN (D) LAN
(d) Where should the following devices be placed?
(i) Switch/Hub
(ii) Repeater
(e) Which is the best-wired medium that can be used to connect the head
office in Delhi with the Chandigarh Office?
[11]