SREE GOKULAM PUBLIC SCHOOL - CHENGALPATTU
CLASS: XII QUARTERLY EXAMINATION MARKS: 70
DATE:12.09.2025 COMPUTER SCIENCE (083) TIME: 3 HRS
General Instructions:
This question paper contains 37 questions.
All questions are compulsory. However, internal choices have been provided in some questions.
Attempt only one of the choices in such 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 the correct answer should also be written.
SECTION A
State True or False. 1
1
“Variable declaration is implicit in Python.”
What will be output of the following code: 1
d1={1:2,3:4,5:6}
2 d2=d1.popitem()
print(d2)
a) {1:2} b) {5:6} c) (1,2) d) (5,6)
Consider the given expression: 1
3 (not True) and False or True
Which of the following is the correct value of the expression?
a) True b) False c) None d) NULL
Fill in the blank: 1
4 ___________ command is used to add a new column in a table in SQL.
a) update b) remove c) alter d)drop
Which of the following mode in file opening statement generates an error if the file 1
5 exists?
a) a+ b) r+ c) w+ d) None of these
Which of the following commands can remove all the data from a table in a MYSQL 1
6 database?
a) DELETE b) DROP c) REMOVE d) ALTER
Fill in the blank: 1
7 A candidate key, which is not the primary key of a table, is a/an _________.
a) Primary Key b) Foreign Key c) Candidate Key d) Alternate Key
Select the correct output of the code : 1
n = "Post on Twitter is trending"
8 q = n.split('t')
print( q[0]+q[2]+q[3]+q[4][1:] )
a. Pos on witter is rending b. Pos on Twitter is ending
c. Poser witter is ending d. Poser is ending
1
Fill in the blank: 1
9 The ________ command is used in a WHERE clause to search for a specified pattern in a
column.
(a) match (b) similar (c) like (d) pattern
Which of the following statement(s) would give an error after 1
executing the following code?
10
(a) Statement 4 (b) Statement 5
(c) Statement 4 & 6 (d) Statement 1 & 2
The name of the module used to establish a connection between Python and SQL 1
11 database is-
(a) mysql-connect (b) mysql-connector (c) mysql-interface (d) mysql-conn
Which of the following is NOT a DML Command? 1
12
(a) Insert (b) Update (c) Drop (d) Delete
Which of the following statements correctly explain the function of tell() method? 1
(a) tells the current position within the file.
13 (b) tell the name of file.
(c) move the current file position to a different location.
(d) it changes the file position only if allowed to do so else returns an error
14 Which is known as range operator in MySQL? 1
(a) IN (b) BETWEEN (c) IS (d) DISTINCT
What will be the value of y when following expression be evaluated in Python? 1
15 x=10.0
y=(x<100.0) and x>=10
(a)110 (b) False (c)Error (d)True
A database ___________is a special control structure that facilitates the row by row 1
16 processing of records in the result set.
(a) Fetch (b) table (c) cursor (d) query
17 What do you understand by the terms Degree , cardinality of a Relation? Explain with an 1
example.
The correct syntax of seek() is: 1
(a) file_object.seek(offset [, reference_point])
18 (b) seek(offset [, reference_point])
(c) seek(offset, file_object)
(d) seek.file_object(offset)
Which SQL keyword is used to retrieve only unique values? 1
19
(a) DISTINCTIVE (b) UNIQUE (c) DISTINCT (d) DIFFERENT
Q20 and 21 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
Assertion (A):- print(f1()) is a valid statement even if the function f1() has no return 1
20 statement.
Reasoning (R):- A function always returns a value even if it has no return statement.
2
Assertion(A): DBMS is an application package which arranges the data in orderly 1
manner in a tabular form.
21
Reason(R): It is an interface between database and the user. It allows the users to access
and perform various operations on stored data using some tools.
SECTION B
22 (a) Given is a Python string declaration: 2
str="malayalam"
Write the output of :print(str[: :-1])
(b) Write the output of the code given below:
Employee1={'name':'John','salary':10000,'age':24}
Employee2={'name':'Diya','salary':54000,'dept':'Sales'}
Employee1.update(Employee2)
print(Employee1)
23 (a) Predict the output of the Python code given below: 2
(b)Predict the output of the Python code given below:
x= “hello world”
print(x[:2],x[:-2],x[-2:])
print(x[6],x[2:4])
print(x[2:-3],x[-4:-2])
24 Explain the use of ‘Primary Key’ in a Relational Database Management System. Give 2
example to support your answer.
25 (a) Write the outputs of the SQL queries (i) to (iv) based on the relations 2
SCHOOL and ADMIN given below:
3
(i) SELECT SUM (PERIODS), SUBJECT FROM SCHOOL GROUP BY SUBJECT;
(ii) SELECT TEACHERNAME, GENDER FROM SCHOOL, ADMIN
WHERE DESIGNATION = ‘COORDINATOR’ AND
SCHOOL.CODE=ADMIN.CODE;
(iii) SELECT COUNT (DISTINCT SUBJECT) FROM SCHOOL;
(iv) SELECT MAX(PERIODS) FROM SCHOOL;
26 a) Differentiate between ‘WHERE’ clause and ‘HAVING’ clause in MySQL with 2
appropriate example.
OR
b) Differentiate between DELETE and DROP keywords used in MYSQL, giving
suitable example for each.
27 Consider the following tables – Bank_Account and Branch: 2
What will be the output of the following statement?
SELECT * FROM Bank_Account, Branch;
28 a) Differentiate between DDL and DML. 2
OR
b) Write the main difference between INSERT and UPDATE Commands in SQL
SECTION C
29 Write a function SQUARE_LIST(L), where L is the list of elements passed as argument 3
to the function. The function returns another list named ‘SList’ that stores the Squares of
all Non-Zero Elements of L.
For example:
If L contains [9,4,0,11,0,6,0]
30 a) Write a method/function COUNT_BLANK_SPACES() in Python to read lines 3
from a text file STORY.TXT, and display the count of blank spaces in the text
file.
OR
b) Write a method/function DISPLAYWORDS() in python to read lines from a text
file POEM.TXT, and display those words, which are less than 4 characters.
31 Write the outputs of the SQL queries (a) to (c) based on the relation Furniture 3
4
(a) SELECT Itemname FROM Furniture WHERE Type="Double Bed";
(b) SELECT MONTHNAME(Dateofstock) FROM Furniture WHERE Type="Sofa";
(c) SELECT Price*Discount FROM Furniture WHERE Dateofstock>31/12/02;
SECTION D
32 Consider the table EXAM with details of marks. Write MySQL commands for the 4
following questions:
(i)To display all information of the students of humanities in descending order of
percentage.
(ii)To display Adno, Name, Percentage and Stream of those students whose name starts
with S and ends with t.
(iii)To display SName, Percentage, Clsection of students whose stream is commerce.
(iv) To display details of students who have Percentage in the range of 80 and 90 (both
inclusive) in decreasing order of Percentage.
33 a) A list contains following record of a doctor: 4
[Doc_ID, Doc_name, Phone_number, Speciality]
Write the following user defined functions to perform given operations on
the stack named "status":
(i) Push_element() - To Push an object containing Doc_ID and Doc_name
of doctors who specialize in Anesthesia to the stack.
(ii) Pop_element() - To Pop the objects from the stack and display them.
Also, display “Stack Empty” when there are no elements in the stack.
For example: If the lists of Doctors' details are:
['D01', "Gurdas", “99999999999”,"Anesthesia”]
["D02", "Julee", “8888888888”,"cardiology"]
[D03",“Murugan”,”77777777777”,”Anesthesia”]
["D04",“Ashmit”, “1010101010”,”Medicine”]
The stack should contain
['D03', 'Murugan']
['D01', 'Gurdas']
The output should be:
['D03', 'Murugan']
['D01', 'Gurdas']
Stack Empty
OR
b) Write a function in Python, Push(KItem), where KItem is a dictionary
containing the details of Kitchen items– {Item:price}.
The function should push the names of those items in a stack which have price less than
100. Also display the average price of elements pushed into the stack.
For example: If the dictionary contains the following data:
{"Spoons":116,"Knife":50,"Plates":180,"Glass":60}
The stack should contain
Glass
Knife
The output should be:
5
The average price of an item is 55.0
34 Tushar is a Python programmer. He has written a code and created a binary file record.dat 4
with employeeid, ename and salary. The file contains 10 records. He now has to delete a
record based on the employee id entered by the user. For this purpose, he creates a
temporary file, named temp.dat, to store all the records other than the record to be deleted.
If the employee id is not found, an appropriate message should to be displayed.
As a Python expert, help him to complete the following code (by completing statements
1, 2, 3, and 4) based on the requirement given above:
(i) Complete Statement#1 to import the required module.
(ii) Write the correct statement required to open a temporary file named temp.dat.
(#Statement 2)
(iii) Which statement should Aman fill in Statement 3 to read the data from the binary
file, record.dat
(iv) What should be written in Statement 4 to write the required records in the file
temp.dat?
35 Modern Public School is maintaining fees records of students. The database 4
administrator Aman decided that-
• Name of the database -School
• Name of the table – Fees
• The attributes of Fees are as follows:
Rollno - numeric
Name – character of size 20
Class - character of size 20
Fee – Numeric
Qtr – Numeric
Answer any four from the following questions:
(i) Identify the attribute best suitable to be declared as a primary key
(ii) What is the degree of the table.
(iii) Write the statements to:
a. Insert the following record into the table
Rollno-1201, Name-Akshay, Class-12th, Fee-350, Qtr-2
b. Increase the second quarter fee of class 12th students by 50
OR (Option for part iii only)
a. Delete the record of student with Rollno-1212
b. Aman wants to add a new column to the Fees table,
Which command will he use from the following:
a) CREATE b) ALTER c) SHOW d) DESCRIBE
6
SECTION E
36 (a ) Write the output of the code given below: 5(2+3)
(b) The code given below reads records from the table named student and
displays only those records who have marks greater than 75. The structure
of a record of table Student is:
RollNo – integer; Name – string; Clas – integer; Marks – integer
Note the following to establish connectivity between Python and MYSQL:
• Username is root
• Password is abc
• The table exists in a MYSQL database named school.
• The details (RollNo, Name, Clas and Marks) are to be accepted from
the user.
Write the following missing statements to complete the code:
Statement 1 – to create the cursor object
Statement 2 – to execute the query that extracts records of those students whose marks
are greater than 75.
Statement 3 - to read the complete result of the query (records whose marks are greater
than 75) into the object named data, from the table student in the database.
37 Navdeep creates a table RESULT with a set of records to maintain the marks 5
secured by students in Sem1, Sem2, Sem3 and their division. After creation of
the table, he has entered data of 7 students in the table.
(i) Can Name be a candidate key of the table? Justify your answer.
(ii) If a column is added and 3 rows are deleted from the table result, what
will be the new degree and cardinality of the above table?
(iii) Write the statements to:
a) Insert the following record into the table
Roll_No- 108, Name- Aadit, Sem1- 470, Sem2-444, Sem3-475, Div– I.
b) Increase the SEM2 marks of the students by 3% whose Name ends with 'A'.
iv) Write the statements to:
Delete the record of students securing IV division.
v) Add a column GRADE, of type char of length 3 characters to the RESULT table.