Page 1
2023-24
HALF YEARLY
EXAM
NCERT BASED
SYLLABUS
DOWNLOAD PDF
FOR
CBSE BOARD
AND
STATE BOARDS
Page 2
Half Yearly Exam 2023-24
Question Paper
Class - XII Subject – Computer Science
Time – 3 Hours Maximum Marks- 70
General Instructions:
Please check this question paper contains 34 questions.
The paper is divided into 4 Sections- A, B, C, D and E.
Section A, consists of 17 questions (1 to 17). Each question carries 1 Mark.
Section B, consists of 6 questions (18 to 23). Each question carries 2 Marks.
Section C, consists of 6 questions (24 to 29). Each question carries 3 Marks.
Section D, consists of 2 questions (30 to 31). Each question carries 4 Marks.
Section E, consists of 3 questions (32 to 34). Each question carries 5 Marks.
All programming questions are to be answered using Python Language only.
SECTION-A[1 MARK EACH]
1. State True or False: “A file opened through ‘with’ keyword need to be closed explicitly.”
2. Choose the correct output:
t=(4,5,6,7,8,9,3,2,1)
print(t[5:-1])
a) (8,9,3,2,1)
b) (9,3,2)
c) (4,5,6,7)
d) (2,3,9)
3. Mr Subodh is working with a dictionary in python for his project. He wants to display the
key, and value pair but confuse by these statements, choose the correct statement for him:
a) dict.values()
b) disct.keys()
c) dict.keysvalues()
d) dict.items()
4. Which one of the following is the correct statement for creating a dictionary for assigning a
day number to weekdays using short names?
a) d ={1:Mon,2:Tue,3:Wed,4:Thur}
b) d ={1:’Mon’,2:’Tue’,3:’Wed’,4:’Thur’}
c) d ={1;’Mon’,2;’Tue’,3;’Wed’,4;’Thur’}
d) d ={1-‘Mon’,2-‘Tue’,3-‘Wed’,4-‘Thur’}
5. What will be the output of the following code?
dict={'x':11,'y':13,'z':15}
s=""
for i in dict:
s=s+str(dict[i])+" "
s1=s[:-1]
1
Page 3
print(s1[::-1])
a) 15 13 11
b) 11 13 15
c) 51 31 11
d) 10 13 14
6. Find the output:
5//3+2**2*2
a) 9
b) 9.0
c) 9.5
d) 10
7. Select the proper order of execution for the following code:
A. def diff(a,b):
B. c=a-b
C. print(“The Difference is :”,c)
D. x,y =7,3
E. diff(x,y)
F. print(“Finished”)
a) A -> B -> C -> D -> E -> F
b) D -> E -> F -> A -> B -> C
c) D -> E -> A -> B -> C -> F
d) E -> B -> C -> D -> A -> F
8. What will be the output of the following code?
v = 80
def display(n):
global v
v = 15
if n%4==0:
v += n
else:
v -= n
print(v, end="#")
display(20)
print(v)
a) 80#80
b) 80#100
c) 80#35
d) 80#20
9. Which of the following file types allows to store large data files in the computer memory?
a) Text Files
b) Binary Files
c) CSV Files
d) None of these
2
Page 4
10. To read 4th line from text file, which of the following statement is true?
a) dt = f.readlines();print(dt[3])
b) dt=f.read(4) ;print(dt[3])
c) dt=f.readline(4);print(dt[3])
d) All of these
11. Which method is used for object serialization?
a) Pickling
b) Unpickling
c) None of the above
d) All of the above
12. Observe the following code and fill the blank in statement1
import csv
with _________ as f: #statement1
r = csv.______(f) #statement2
for row in ______: #statement3
print(_____) #statement4
a) open("data.csv", ‘r’)
b) f=open("data.csv")
c) Both A & B are Correct
d) Both A & B are incorrect
13. The term ___________ is use to refer to a record in a table.
a) Attribute
b) Tuple
c) Row
d) Instance
14. A relational database consists of a collection of
a) Tuples
b) Attributes
c) Keys
d) All of these
15. Consider the following query:
SELECT name FROM stu WHERE subject LIKE ‘_______ Computer Science’;
Which one of the following has to be added into the blank space to select the subject which
has Computer Science as its ending string?
a) $
b) _
c) ||
d) %
16. Which of the following function is not an aggregate function?
a) Round()
b) Sum()
c) Count ()
d) Avg ()
3
Page 5
17. In SQL, which command is used to SELECT only one copy of each set of duplicate rows:
a) SELECT DISTINCT
b) SELECT UNIQUE
c) SELECT DIFFERENT
d) All of the above
SECTION-B [2 MARKS EACH]
18. What possible outputs(s) are expected to be displayed on screen at the time of execution of
the program from the following code? Also specify the maximum values that can be assigned
to each of the variables Lower and Upper.
import random
AR=[20,30,40,50,60,70];
Lower =random.randint(1,3)
Upper =random.randint(2,4)
for K in range(Lower, Upper +1):
print (AR[K],end=”#“)
(i) 10#40#70# (ii) 30#40#50# (iii) 50#60#70# (iv) 40#50#70# (v) None of
these
19. Observe the following code in python:
a=10
b=0
print(a/b)
print(a+b)
Although there is no error in Line-4, still it is not getting executed. Justify the reason.
Rewrite the code by using the concept of exception handling to handle the run time error(if
any).
20. Below is the program code to read the data set. Fill up the blank spaces for the fulfillment of
the same:
import pickle
f=open("student.txt","_____")
data=True
try:
while data:
data=pickle.______(f)
print(data)
except:
pass
f.close()
21. Consider the given program code which reads a file “records.csv” and fill the blank spaces:
import csv
with _________ as f: #statement1
r = csv.______(f) #statement2
for row in ______: #statement3
print(_____) #statement4
4
Page 6
22. Differentiate between Natural Join and Equi Join with suitable example for each.
23. Write output for queries (i) and (ii), which are based on the table (BOOKS):
i. Select Max(Price) from books where qty>=15;
ii. Select count(distinct Publisher) from books where Price>=400;
SECTION-C[ 3 MARKS EACH]
24. Write a function INDEX_LIST(L), where L is the list of elements passed as argument to the
function. The function returns another list named ‘indexList’ that stores the indices of all
Non-Zero Elements of L. For example: If L contains [12,4,0,11,0,56] The indexList will have -
[0,1,3,5]
25. Write a function in python named as primesum(n) which accepts a list of numbers and
returns the sum of all the prime numbers of the list.
26. Write a function in python named as check() which reads a file “student.txt” and count total
number of words which starts with a vowel character.
27. Write a function add(n) which writes ‘n’ number of records of student in a binary file named
as “student. dat” which is in the form of dictionary as given below:
{‘name’:________,’age’:_____, ‘Roll’:________}
(Note: Prefer the entry of one record at a time in the file)
28. Consider the following tables FACULTY and COURSES and give outputs for SQL queries (i)
to (iii)
i) Select COUNT(DISTINCT F_ID) from COURSES;
ii) Select MIN(Salary) from FACULTY,COURSES where COURSES.F_ID
=FACULTY.F_ID;
iii) Select avg(Salary) from FACULTY where Fname like ‘R%’
29. Differentiate between the following in context of mysql:-
i) Where and Having Clause
ii) Group and Order By
iii) IN and BETWEEN Operator
5
Page 7
SECTION-D [4 Marks each]
30. Consider a binary file- “student.dat” which consist of the details of ‘n’ number of students
having their [roll,name,marks] in the form of list. Define a function search(roll) to ask the
user to enter a roll number and display the details of such student. Display appropriate error
message “Roll number does not exist” if the Roll number is not found.
31. Write SQL queries for (a) to (d) on the basis of Teacher relation given below:
(a) To list the names of female teacher who are in Maths department .
(b) To list names of all teachers with their date of joining in ascending order.
(c) To display teacher’s Name, Salary, Age for male teacher only
(d) To count the number of teachers with Age>35.
SECTION-E [5 MARKS EACH]
32. Write a program to input your phone number in the form of string and generate a list which
consists of all the prime digits of your phone number without repeating the same digit.
E.g., if the phone number is “8051153194” then the list should be generated as follows:[5,3]
33. Write a function LShift(Arr,n) in Python, which accepts a list Arr of numbers and n is a
numeric value by which all elements of the list are shifted to left. Sample Input Data of the
list Arr= [ 10,20,30,40,12,11], n=2 Output Arr = [30,40,12,11,10,20]
34. Write SQL Query for (i) to (v).
i. To display all the details of those watches whose name ends with ‘Time’
ii. To display watch’s name and price of those watches which have price range in between
5000 to 15000 (Both inclusive.)
iii. To display total quantity in store of Unisex type watches.
iv. To display watch name and their quantity sold in first quarter.
v. Find the total quantity of each type of Unisex and Gents type of watches.
6
AglaSem Earn while Learn Program. Send your papers and get paid.
Contact: support@
Page 8
QUESTION PAPERS
GET PREVIOUS YEAR QUESTION PAPERS FOR ALL CLASSES FOR CBSE, ISCSE, ISC AND ALL ALL
STATE BOARDS HERE AT
Andhra Pradesh Board Question Papers
BOARD
WISE Assam Board Question Papers
Bihar Board Question Papers
Chhattisgarh Board Question Papers
Goa Board Question Papers
Gujarat Board Question Papers
Haryana Board Question Papers
Himachal Pradesh Board Question Papers
J&K State Board Question Papers
Jharkhand Board Question Papers
Karnataka Board Question Papers
Kerala Board Question Papers
Madhya Pradesh Board Question Papers
Maharashtra State Board Question Papers
Manipur Board Question Papers
Meghalaya Board Question Papers
Mizoram Board Question Papers
Nagaland Board Question Papers
Orissa Board Question Papers
Punjab Board Question Papers
Rajasthan Board Question Papers
Tamil Nadu Board Question Papers
Telangana State Board Question Papers
Tripura Board Question Papers
Uttarakhand Board Question Papers
Uttar Pradesh (UP) Board Question Papers
West Bengal (WB) Board Question Papers