Coimbatore Sahodaya Schools Complex
Coimbatore Sahodaya Schools Complex
General Instructions:
➢ Read the instructions carefully.
➢ This question paper has 5 Sections : Section - A, B, C, D & E.
➢ Section A has 18 questions carrying 1 mark each.
➢ Section B has 7 Very Short Answer (VSA) type questions carrying 2 marks each.
➢ Section C has 5 Short Answer (SA) type questions carrying 3 marks each.
➢ Section D has 2 Long Answer (LA) type questions carrying 4 marks.
➢ Section E has 3 Source-based/Case-based/Passage-based questions carrying 5 marks each .
Q. NO QUESTIONS MARKS
SECTION A
else:
print(A*B+C)
Disp()
Disp(3,'*','10')
Given is a Python string declaration: str="CBSE Examination@2024". Write the output of:
3
print(str[ -6: : -1]).
1
Which function usage is used to display the total number of non-null values in a column “Sub”
8
from a table in a database?
1
a) unique(sub) b) sum(Sub) c) count(Sub) d) count(distinct sub)
Suppose you have two columns named student_name and student_department inside table
9
student_details and need to update the value of these two columns where ID=4. Select the
correct statement.
a) UPDATE student_details SET Student_name="ram", Student_department = 1
What is the minimum maximum value that can be obtained by the variable b when the
11
following code is executed?
1
import random
a = random.random()
b = a + random.randint(1,4)
a) 1, 4.9999 b) 1, 5 c) 0, 4.9999 d) 0, 3.9999
Which of the following is used to read n characters from a file object “StuFile” ?
12 1
a)StuFile.read(n) b) StuFile(2) c) StuFile (read,2) d) All of the above
Which of the following python statements will bring the read pointer to the 10th character from
14
the end of a file containing 100 characters, opened for reading in binary mode?
1
a) File.seek(10,0) b) File.seek(-10,2) c) File.seek(-10,1) d) File.seek(10,2)
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 of A
b) Both A and R are true and R is not the correct explanation of A
c) A is True but R is False
d) A is False but R is True
Assertion (A): If the arguments in a function call statement match the number and order of
17 arguments as defined in the function definition, such arguments are called positional arguments. 1
Reasoning (R): During a function call, the argument list first contains default argument(s)
followed by positional argument(s).
Assertion (A): A variable declared as global inside a function is visible with changes made to it
18 outside the function.
Reasoning (R): All variables declared outside are not visible inside a function till they are
1
redeclared with global Keyword.
SECTION B
print(a[-1])
s+=a[-1]
print('sum=',s)
Write the python statement for each of the following tasks using BUILT-IN functions/methods
20
only:
(i) To remove an element at index 2 in a list L
(ii) To check whether a string named text has ‘th’ in the beginning. 2
Mr. Sarthak has just created a table name ‘Wrestling’ containing columns PlayerId, Pname,
21
Style and WeightCategory. After creating the table he realized that he had forgotten to add a
primary key column in the table. Help him in writing an SQL command to add a primary key
column PlayerId of integer type to the table Wrestling. Thereafter write the command to insert 2
Shifa has written a code to input a positive integer and display its factorial. Her code is having
23
errors. Rewrite the correct code and underline the corrections made. (factorial of a number n is
the product 1x2x3. . .n)
n=int(input("Enter a positive integer: ")
f=0 2
for i in range(n):
f*=i
print(f)
Predict the output of the following python code:
24
def disp(a1,a2):
2
b1=[]
b2=[]
for x in a1:
b1.append(x)
for x in a2:
b2.append(x)
return b1,b2
p,q=disp("FUN",'DAY')
print(p,q)
OR
Predict the output of the following python code:
data = [2,4,2,1,2,1,3,3,4,4]
d = {}
for x in data:
if x in d:
d[x]=d[x]+1
else:
d[x]=1
print(d)
Write a function count_city(CITY) in Python, that takes the dictionary, CITY as an argument
25
and displays the names (in uppercase) of the cities whose names are smaller than 6 characters.
For example, Consider the following dictionary
CITY = {1:"Ahmedabad", 2:"Pune", 3:"Baroda", 4:"Simla", 5:"Surat"} 2
SECTION C
Consider the following tables ITEM and CUSTOMER . Write outputs for SQL queries:
26
TABLE : ITEM
TABLE : CUSTOMER
Write a method SHOWLINES() in Python to read lines from text file ‘story.txt’ and display the
27
lines which do not contain 'text'.
Example: If the file content is as follows :
Write a function word_of_length(text). 3
Anil has created a list, X containing marks of 5 students. Write a program, with separate user
30
defined function to perform the following operation:
PUSH() - Traverse the content of the List, L and push all the odd marks into the stack S.
POP() - Pop and display the content of the stack.
Example: If the content of the list is as follows: L=[81, 94, 63, 19, 62] 3
Then the output of the code should be: 19 63 81 empty
OR
Write a function in Python, Push(BItem) where , BItem is a dictionary containing the details of
bakery items– {Bname:price}.The function should push the names of those items in the stack S
which have prices less than 50.
For example: If the dictionary contains the following data:
Bitem={"Bread":40,"Cake":250,"Muffins":80,"Biscuits":25}
The stack should contain
Bread
Biscuits
SECTION D
Aryan is a Python programmer working in Infotech Ltd. For Ambica Furniture, he has created a
31
csv file named furniture.csv, to store the data of different furniture. Write User Defined
Functions in Python as per following requirements :
i) ADD () – To accept and add data of an item to a CSV file ‘furniture.csv’. Each record 4
Oxford college, in Delhi is starting up the network between its different wings. There are four
33 5
Buildings named as SENIOR, JUNIOR, ADMIN and HOSTEL as shown below:
i) Define Pickling. Which function aids in serializing the python object? 2+3
34
ii) A binary file “salary.DAT” has structure [employee id, employee name, salary]. Write a
function countrec() in Python that would read the contents of the file “salary.DAT” and display
the details of those employees whose salary is above 20000.
OR
i) What is the difference between ‘r’ and ‘w’ mode in a Python file ?
ii) A binary file “STUDENT.DAT” has structure [admission_number,Name, Percentage]. Write
a function countrec() in Python that would read contents of the file “STUDENT.DAT” and
display the details of those students whose percentage is above 90. Also display the number of
students scoring above 90%.
i) Define the term Degree with respect to RDBMS.
35 1+4
ii) Sarithahas created a table Inventory in MYSQL database, warehouse:
Inv_No(Inventory Number )- integer
Inv_name(Name) – string
Inv_Entry(Date )
Inv_price – Decimal
Note the following to establish connectivity between Python and MySQL:
Username - root
Password - 12345
Host - localhost
Saritha now wants to delete the records of inventory whose price is more than 1000. Help
Saritha to write the program in Python.