0% found this document useful (0 votes)
33 views8 pages

Hy 2024-25

The document is a question paper for the Class XII Half-Yearly Examination in Computer Science for the D.A.V. Institutions in West Bengal, covering various topics in Python programming and SQL. It consists of five sections with a total of 70 marks, including multiple choice questions, short answer questions, and programming tasks. The paper emphasizes the use of Python for programming questions and includes instructions for each section.
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
33 views8 pages

Hy 2024-25

The document is a question paper for the Class XII Half-Yearly Examination in Computer Science for the D.A.V. Institutions in West Bengal, covering various topics in Python programming and SQL. It consists of five sections with a total of 70 marks, including multiple choice questions, short answer questions, and programming tasks. The paper emphasizes the use of Python for programming questions and includes instructions for each section.
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 8

D.A.V.

INSTITUTIONS, WEST BENGAL ZONE


HALFYEARLY EXAMINATION
SESSION 2024-2025
CLASS:XII
MAXIMUM MARKS : 70
SUBJECT:COMPUTER SCIENCE (083) TIME : 03 HOURS

General Instructions:
1. This question paper containsfive sections, Section Ato E
2. All questions are compulsory.
3. Section A has 18 questions carrying 0l mark each.
4. Section B has 07 Very Short Answer type questions carrying 02 marks each.
S. Section C has 05 Short Answer type questions carrying 03 marks each.
6. Section D has 02 questions carrying 04 marks each.
7. Section E has 03 questions carrying 05 marks each.
8. All programming questions are to be answered using Python Langiuage only

Section:A
1. For a string S declared as S ='PYTHON, which of the following is incorrect? 1
a) N=len(S) b) T=S c) "T inS d) S[0] = M
2. AList is declared as L = ONE, TWO, "THREE ] 1
What willbe the output of the statement?
print(max(L)
3. Evaluate the following expression and identify the correct answer.
26- (8 +2) *5 +3**2*4
a) 54 b)46 c) 12 d) 32
4. Find the output of the following code:
1
Name-"PythoN3.12"
R=n
for x in range (len(Name)):
if Name[x].isupper):
R=R+Name[x].lower)
elif Name[x].islower):
R=R+Name[x].upper)
elif Namex].isdigit):
R-R+Name[x-1]
else:
R-R+"#"
print(R)
a) pYTHOn##@ b) pYTHOnN#1 c)pYTHOn#@ d) pYTHOnN#. 1
5 What will be the output of the given expression: not True and False or True
6. Select the correct output of the code : 1
S= "Mid Term EXAM @2024"
A=S.partition (" ")
print (A)
a) ("Mid Term EXAM'@, 2024")
c) (Mid', "Term EXAM @ 2024') b) 'Mid', Term', 'EXAM, '@, 2024]
d) (Mid', " Term EXAM @ 2024)
Page 1 of 8
1
7. Fillin the blank.
ascending order.
function isused to arrange the elements of a string in
c) sorted( ) d) arrange()
a) asc() b) sort( ) 1
8 What will be the output of the followingcode?
import random
List-["Delhi","Mumbai" "Chennai","Kolkata"]
for y in range(4):
x= random.randint(1,3)
print(List[x],end="#")
a) Delhi#Mumbai#Chennai#Kolkata# b) Mumbai#Chennai#Kolkata#Mumbai#
) Mumbai#Mumbai #Mumbai # Delhi# d) Mumbai# Mumbai #Chennai # Mumbaí
9 Given the following dictionaries 1
dict _exam={"Exam";"AISSCE", "Year":2025)
dict _result="Total":S00, "Pass Marks":165}
Which statement willmerge the contents of both dictionaries?
a) dict exam.update(dict_result) b) dict exam + dict result
c) dict exam.add(dict result) d) dict _exam.merge(dict_result)
10. What will be the output of the following code? 1
def my_ func(varl-100, var2-200):
varl+10
var2 var2 10
return varl+ var2
print(my_ func(50), my func( ))
a) 250 75 b) 250 300 c) 100 200 d) 150 300
11. Suppose content of'Myfile.txt is "Computer Science with PYTHON"
What will be the output of the following code?
myfile = open("Myfile.txt")
vlist = list("aeiou")
vc=0
X= myfile.read( )
for y in x:
if(y in vlist):
ve+=1
print(vc)
myfile.close()
a) 6 b) 7 c) 8 d) 9
12. Assume the content of text file. 'student.txt' is: 1

Sanjiv Roy
Richa Ghosh
Rajen Mondal
Kiran Rao

What will be the data type of data rec after executing the following code?
Page 2 of &
myfile = open("Myfile.txt")
data_ rec= myfile.readlines()
myfile.close()
a) String b) Tuples c) List d) Dictionary
13. Which of the following is true for file objects in text mode? 1
a) They handle the end-of-line character automatically
b) They do not handle the end-of-linecharacter
c) They can read binary data
d) They can write binary data
14. Which of the following is not a valid DML command in SQL?
a) INSERT b) UPDATE c) ALTER d) DELETE
15. Which SQL clause is used to sort the result set in ascending or descending order? 1
a) ORDER BY b) SORTBY c) ASCEND BY d) ARRANGE BY
16. Which of the following SQL queries willc¡rrectly count the number of unique departments in 1
the 'employees' table?
a) SELECT COUNT(department) FROM employees;
b) SELECT COUNT(DISTINCT department) FROM employees;
c) SELECT COUNT(UNIQUE department) FROM employees;
d) SELECT COUNT(DISTINCT ALL department) FROM employees;
Q. 17 &Q. 18 are ASSERTION (A) and REASON(R) based questions. Mark the correct
choice as:
a) BothA and R are True and R is the correct eplanation for A
b) BothA and R are True and R is not the correct explanation for A
) Ais True but Ris False
d) Ais False butR is True
17. Assertion(A): InPython, List and Tuples are defined as an ordered sequence of elements having 1
data of same or different types.
Reason(R): The list elements are separated by commas and enclosed within [] brackets
whereas, the tuple elements are separated by commas and enclosed within() parentheses.
18. Assertion (A): If the arguments in function call statement match the number and order of 1
arguments as defined in the function definition, such arguments are called positional arguments.
Reason(R) During afunction call, the argument list first contains default argument(s) followed
by positional argument(s).
Section : B
19. 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.
define revNumber(num):
rey = 0)
rem = 0
While num > 0:
rem == numn % 10
rey = rem * 10 t rev
num = num/ T0
return rev
print(revNumber(1234)
Page 3 of &
parameter(s) and a formal parameter(s) with a suitable example for
20. Differentiate between actual
each.
QR
Argument of function in python with
Differentiate between Positional Argument and Default
suitable example 2
returns a tuple
21. Write a function lenWords(STRING), that takes a string as an argument and
containing length of cach word of a string.
For example, if the string is "Come let us have some fun", the
tuple will have (4, 3, 2, 4, 4, 3) 2
22. Write the Python statement for each ofthe following tasks using BUILT-IN functions /methods
only:
a) To insert an element 200 at the third posiion, in the list L1.
b) To change the first character of the string in capital letter.
OR
Alist named studentAge stores age of students of aclass. Write the Python command to import
the required module and (using built-in function) to display the most common age value from
the given list.
23. Observe the following code and answer the questions that follow: 2

File = open("Mydata", "a")


#Blankl
File.close)

a) What type (Text/Binary) of file is Mydata? Explain your answer.


b) Fillthe Blankl with statement to write ABC" in the file "Mydata"
OR
Write afunction countmy() in Python to read file Data.txt and count the number of times "my"
Occur in file.
For example, if the file contain:
This is my website. I have di_played my preferences in the choice section.
Output :
The countmy() function should display theoutput as : 'my' occurs 2 times.

What are aggregate functions in SQL? Give examples? 2


24.
OR
What do you mean by Equi-join and Natural join?

SQL to 2
25. An organization SoftSolutions is considering to maintain their employees records using
store the data. As a database administer, Murthy has decided that :
The attributes of the table HRDATA are as follows:
> ECode- Numeric (Primary Key)
º EName - Character of size 30 ( Cannot be empty)
Desig- Character of size 15 (Default value is Admin')
Remn -Numeric

Page 4 of8
a) Write a SQL command to create the table HRDATAWith appropriate constraints.
b)Write command to insert followingdata in the table:
ECode = 80015, Ename "Allen" Remn =43000
Section:C
26. Write a function mergeList(lL1,L2) which takes two lists as argument and create a third list with 3

common elements from both the lists (without duplicates) in ascending order. Make sure your
program works on two lists of different sizes.
e.g.
Ll= [1,1,5,3,2,8,55,2 1,34,13,39]
L2= [20,1,2,3,4,5,6,7,8,9,10,11,12,13]
The output should be: [1,2,3,5,8,13]
27. Write the output of the following Python programcode:
def ChangeList):

Ll-[]
L2=[]
for i in range(1,10):
L.append()
for iin range(10,1,-2):
Ll.append)
for i in range(len(L1):
L2.appendL1i}+L[i)
L2.append(len(L)-len(L1)
print(L2)
ChangeList()
28. Write a function countH) in python that displays the number of lines starting with H' from the 3
file "para.txt".
Example, if the file contains:
Whose w0ods these are I think I know.
His house is in the village though.
He will not see me stopping here.
Towatch his woods fill up with snow.

Output: The lines starting with H'=2.


OR
Write a method/function DISPLAYWORDS) in python to read lines from a text file
STORY.TXT, and display those words, which are less than 4 characters.

29. a) Define Serialization. 3


b) Abinary file emp.DAT" has structure (EID. Ename,designation,salary). Write a function
addemp) to write three more records of emploves in existing file emp.dat. (The details of the
employees must be taken as input from the user.)

Page 5 of 8
3
below:
TECH COURSE given
queries (i) to (i) based on the table,
J0. Write the output of the
Table: TECH COURSE
FEES
START DATE TID
CID CNAME
2022-07-02 101
C201 Animation and VFX 12000
2021-11-15 NULL
C202|CADD 15000
10000 2020-10-01 102
C203| DCA
C204 DDTP 9000 2021-09-15 104
2022-11-01 101
C205| Mobile Application 18000
C206 Digital Marketting 16000 2022-07-25 103

i) SELECT DISTINCT TID FROM TECH COURSE;


ii) SELECT TID, COUNT), MINFEES) FROM TECH COURSE GROUP BY TID
HAVING COUNT(TID)>1;
iii) SELECT CNAME FROM TECH COURSE WHERE FEES>15000 ORDER BY
CNAME;
Section : D
31. Consider a CSV file 'INVENTORY.CSV that stores information about products using the 4

structure [ProductlD, ProductName,Quantity, Price].


Write the following Python functions for different operations.
addProduct(): To write the product details in the. ile(Minimum 3 products)
expensiveProducts(): To readthe contents of "INVENTORY.CSV and display details of
products with a price higher than Rs. 1000. Additionally, calculate and display the sum of such
expensive products.

For example: If the file stores the following data in binary format
[1, 'ABC", 100, 5000]
[2, DEF,250, 1000]
[3, 'GHI, 300, 2000]
then the function should display
Product ID: 1,'ABC, 100, 5000
Product ID: 3, 'GHI, 300, 200
Total expensive products: 7000
in 4
32. Asim creates a table RESULT with a set of records to maintain the marks secured by students
Sem 1, Sem 2, Sem 3 and their division. After creation of the table, he has entered data of 7
students in the table.
Table: RESULT
SEM2 SEM3 DIVISION
ROLL NO SNAME SEM1
101 KARAN 366 410 402
102 NAMAN 300 350 325
103 ISHA 400 410 415 I
104 RENU 350 357 415
105 ARPIT 105 75 178 IV
106 SABINA 100 205 217
107 NEELAM 470 450 471
Page 6 of 8
Rased on the data given above answer th following questions:
) ldentify the most appropriate column, which can be considered as Primary Key, Give
appropriate reason.
i) If two columns are added and 2 rows are deleted from the table RESULT, what will be the
new degree and cardinality of the above table?
ii) Increase the SEM2 marks of the students by 3% whose name begins with 'N',
iv) Add a column REMARKS in the table with datatype as varchar with 50 characters.
Section :E
33. a) Find the output for the following codes given below: 243-5
def func(b):
global x
print(Global x=, x)
y=x+b
X=7
z=x-b
print(Local x =x)
print('y ='y)
print(z 2)
x-5
func(10)
b)Writea function fes count(Festival) in Pythbn, that takes the dictionary, festival as an
argument and displays the names (in lowercase) of the places whose names are longer than 10
characters.
For example, Consider the following dictionary
Festival={1:"Holi",2:"ID-ul-Fiter",3:"Christmas"4:"Diwali",5:"Pongal"}
The output should be: id-ul-fiter
OR
a) What will be the output of the following program:
Msg-"hALFyEARLY Exam @2024"
Msgl="
for i in range(0,len(Msg)):
if Msgli].isupper):
Msgl=Msgl+Msg[i].lower)
elif i%5=-0:
Msgl=Msgl+'$
else:
Msgl=Msgl+Msg[i].upper)
print(Msgl)

b) Write a function swapList) which accents a list as argument and swap the content which is
divisible by 7with the next value. (use the same list to modify. Don't use 2" ist)
Ex: List: 3, 21, 5, 6, 14, 8, 14,3
Resultant List: 3, 5, 21, 6, 8, 14, 3, 14
Page 7 of 8
34. a) Differentiate between rt and w+ file modes in Python,. 2+3=5
b)Consider a file, SPORT.DAT,containing records of the following structure:
[SportName, TeamName, No_Players]
Write afunction, copyData(), that reads contents fYrom the file SPORT.DAT and copies the
records with Sport name as "Basket Ball" to the file named BASKET.DAT. The function should
return the total number of records copied to the file BASKET.DAT.
OR
a) How are text files different from binary files?
b) ABìnary 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
allthe records from the binary file CINEMA.DAT, that have the value of Movie Type as mtype.
35. a) Give one diference between alternate key and candidate key. 2+3-5
b) Sartaj has created a table named Student in MYSQL database, SCHOOL with following
columns:
Omo (Roll number)- integer
Oname (Name) - string
DDOB (Date of birth) - Date
O Fee - float
Note the following to establish connectiity betusen Python and MySQL:
DUsername -root Password-tigerDHost localhost
Sartaj, now wants to display the records of students whose fee is more than 5000. Write the
function to help Sartaj to perform the above task.
********* *****k ********* ***** *****

Page 8 of8

You might also like