Sample QP-CS (Xii-Hy) - 2024-25
Sample QP-CS (Xii-Hy) - 2024-25
Sample QP-CS (Xii-Hy) - 2024-25
General Instructions:
• Please check this question paper contains 35 questions.
• The paper is divided into 5 Sections- A, B, C, D and E.
• Section A, consists of 18 questions (1 to 18). Each question carries 1 Mark.
• Section B, consists of 7 questions (19 to 25). Each question carries 2 Marks.
• Section C, consists of 5 questions (26 to 30). Each question carries 3 Marks.
• Section D, consists of 2 questions (31 to 32). Each question carries 4 Marks.
• Section E, consists of 3 questions (33 to 35). Each question carries 5 Marks.
• All programming questions are to be answered using Python Language only.
a) PYTHON-IS-Fun b) PYTHON-is-Fun
c) Python-is-fun d) PYTHON-Is -Fun
4 Which of the following will delete key-value pair for key = “B” from a dictionary D? 1
5 Consider the statements given below and then choose the correct output from the given 1
options:
pride="#G20 Presidency"
print(pride[-2::-2])
6 Which of the following statement(s) would give an error during execution of the following 1
code?
Page 1 of 6
tup = (20,30,40,50,80,79)
print(tup) #Statement 1
print(tup[10]+50) #Statement 2
print(max(tup)) #Statement 3
7 Which is NOT the possible output of following program from given options: 1
import random
periph = ['Mouse', 'Keyboard', 'Printer','Monitor']
for i in range(random.randint(0,2)):
print(periph[i],'*',end=" ")
14 Consider the following program. What is the correct flow of execution of statements: 1
1 def fun1(m, n):
2 c=m+n
3 print(c)
4 return c
5 x = 10
6 y = 20
7 fun1(x, y)
8 print("OK")
Page 2 of 6
15 Which of the following functions changes the position of file pointer and returns its new 1
position?
a) flush() b) tell() c) seek() d) offset()
16 Which of the following statement opens a file ‘student.bin’ in write mode and writes data 1
from a list L=[41, 50, 67, 100] on the binary file?
a) with open ('student.bin', 'wb+') as myfile:
pickle.dump(myfile, L)
b) with open ('student.bin', 'ab') as myfile:
pickle.dump(myfile, L)
c) with open ('student.bin', 'wb') as myfile:
pickle.dump(L, myfile)
d) with open ('student.bin', 'wb') as myfile:
pickle.dump(myfile, L)
Q17 and 18 are ASSERTION AND REASONING based questions. Mark the 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
SECTION – B
19 Predict the output of the following code: 2
20 Differentiate syntax and logical error in Python. Explain the same using an example in Python. 2
OR
Write a function, lenWords(STRING), that takes a string as an argument and returns a tuple
containing length of each word of a string.
For example, if the string is "Come let us study",
Page 3 of 6
the tuple will have (4, 3, 2, 5)
23 The code given below accepts a number as an argument and returns the reverse number. 2
Observe the following code carefully and rewrite it after removing all syntax and logical
errors. Underline all the corrections made.
24 Compare relative and absolute path. Explain the same using an example in Python. 2
b) What will be the return type of the following Python command (assume file handle is file)
i) file.read(30)
ii) file.readlines()
SECTION – C
26 Write the Python statement for each of the following tasks using BUILTIN functions/methods 3
only:
(i) To insert an element 200 at the third position from last, in the list L1.
(ii) To insert # between every character of the string S1.
(iii) To remove and get the last element from a dictionary D1
27 When are the following built-in exceptions raised? Give examples to support your answers. 3
a) KeyError
b) NameError
c) ZeroDivisionError
28 Write a function in Python to read a text file, Alpha.txt and displays those lines which ends 3
with the character s/n (ignore case sensitivity).
OR
Page 4 of 6
Write a function, vowelCount() in Python that counts and displays the number of each vowel
in the text file named Poem.txt. (ignore case sensitivity)
30 Write a function which reads the content of the text file 'Diary.txt' and forms a tuple of all 3
those words of the file which contains a vowel. The function should return the tuple.
Call the function and print the tuple.
SECTION – D
31 A binary file MOBILE.DAT contains records of type [Company, Model, Price, Stock]. 4
Write a program to update the price of all the mobiles by 10%(increase) of Samsung company.
Print all the updated records.
SECTION – E
33 (i) What will be the output of the following Python code? 5
Page 5 of 6
(iii) Write a function in Python which accepts an integer list and changes the content of the list
with 0 if it is a multiple of either 5 or 7 (but not divisible by both) other wise updates the list
content to 1.
OR
(i) Compare w+ and a+ modes of Python.
(ii) A Binary file, CINEMA.DAT has the following structure: {MNO:[MNAME, MTYPE]} Where
MNO – Movie Number MNAME – Movie Name MTYPE is Movie Type Write a user defined
function, findType(mtype), that accepts mtype as parameter and displays all the records from
the binary file CINEMA.DAT, that have the value of Movie Type as mtype.
35 Vedansh is a Python programmer working in a school. For the Annual Sports Event, he has 5
created a csv file named Result.csv, to store the results of students in different sports events.
The structure of Result.csv is :
[St_Id, St_Name, Game_Name, Result]
Where St_Id is Student ID (integer)
ST_name is Student Name (string)
Game_Name is name of game in which student is participating(string)
Result is result of the game whose value can be either 'Won', 'Lost' or 'Tie'
For efficiently maintaining data of the event, Vedansh wants to write the following user
defined functions:
Accept() – to accept a record from the user and add it to the file Result.csv. The column
headings should also be added on top of the csv file.
wonCount() – to count the number of students who have won any event.
Page 6 of 6