0% found this document useful (0 votes)
3K views339 pages

ALL-In-OnE XII CS PB QP MS 2024-25 From Know Python Bytes

Uploaded by

fire1234fire123
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)
3K views339 pages

ALL-In-OnE XII CS PB QP MS 2024-25 From Know Python Bytes

Uploaded by

fire1234fire123
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/ 339

SSS-1207

P-16
Pre-Board-1 Examination 2024-25
Class: XII
Subject: Computer Science (083)
M.M.: 70 Time: 3 hours

General Instructions:
" This question paper contains 37 questions.
Allquestions are compulsory. However, internalchoices have been
provided insome questions. Attempt only one of the choices in such
questions
The paper is divided into 5 Sections- A, B, C, D and E.
" Section Aconsists of 21 questions (1 to 21). Each question carries 1
Mark.
" Section Bconsists 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

Q
No SECTION-A (21X1=21 MARKS) Marks
1 State True or False:"In Python tuple is mutable datatype"
2 What willthe output of the following code
S="text#next"
print(S.strip(""))
(A) ext#nex
SSS-1207 2

(B)ex#nex
(C) text#nex
(D) ext#next
3 What will be the output of the following statement: 1
print( 3-2 **2 **2 + 77/11 )
(A) 6
(B) 6.0
(C) -6.0
(D) Error
4 Consider a list L= [H,U, 'L, K]. Which of the folowing 1
operations will result in an error?
(A)L*2
(B) L + [21
(C) L*[2]
(D) 2*L
5Consider the statements given below and then cho0se the 1
correct output from the given options:
Game="World Cup 2023"
print(Game(-6:-1)
(A)CdrW
(B)ce o
(C) puC dlroW
(D) Error
6Consider the tuple in python named sub=( "cs", "phy", "mat"). 1
Identify the invalid statement(s) from the given below
statements:
(A) s=sub[1]
(B) print(sub[2])
(C) sub[o]= "ip"
(D) list=list(sub)
7 Ifmy_dict is a dictionary as defined below, then which of the 1
following statements willraise an exception?
my_dict =('apple': 10,'banana': 20, 'orange': 30)
(A)my_dict.get('orange')
(B) print(my_dict['apple', 'banana])
3 SSS-1207
(C) my_dict['apple']=20
(D) print(str(my_dict)
Which keyword is used for function in python? 1
(A)Fun
(B) def
(C) DEFINE
(D) Function
Mr. Ravi is creating a field that contains alphanumeric values 1
and fixed lengths. Which MySQL data type should he choose
for the same?
(A)VARCHAR
(B)CHAR
(C) LONG
(D) NUMBER
10 Which is the valid syntaxto write an object onto a binary file 1
opened in the write mode?
(A) pickle.dump(<object to be wrtten>, <file handle of
open file>)
(B) pickle.dump(<file handle of open file>, <object to be
written>)
(C) dump.pickle(<object>,<file handle>)
(D) None of the above
11 The output of the given expression is 1
>>>20 * (20/0)
(A) NameEr ror
(B)TypeError
(C)OverflowError
(D)ZeroDivisionError
12 What will be the output of the following code? 1
a= 15
def update(x):
global a
a t=2
if x%2==0:
a *= X
SSs-1207 4

else:
a l/= x
a=a+5
print(a, end="$")
update(5)
print(a)

(A)20$11
(B)15$4
(C) 20$4
(D) 22$4
13 The structure of the table/relation can be displayed using 1
command.

(A)view
(B) describe
(C) show
(D) select
14 What will be the output of the query? 1

SELECT * FROM products WHERE product_name LIKE


'App%';

(A)Detals of all products whose names start with 'App'


(B)Details of all products whose names end with 'App'
(C) Names of allproducts whose names start with 'App'
(D) Names of allproducts whose nanmes end with 'App'
15 Which of the following statements is FALSE about keys in a 1
relational database?

(A)Any candidate key is eligible to become a primary key.


(B) Aprimary key uniquely identifies the tuples in a relation.
(C)Acandidate key that is not a primary key is a foreign key.
(D) A
foreign key is an attribute whose value is derived from
the primary key of another relation.
16 Which aggregate functioncan be used to find the cardinality of 1
5 SSS-1207
a table?
(A)sum()
(B)count()
(C)avg()
(D)max()
17 Which protocol is used to transfer files over the Internet? 1
(A) HTTP
(B) Telnet
(C) PPP
(D)HTTPS
Which network device is used to connect two networks that use 1
different protocols?
18
(A)Modem
(B)Gateway
(C) Switch
(D) Repeater
When youconnect two mobile phones using Bluetooth to 1
transfer a picture or file which type of network is formed
19
(A) LAN
(B) WAN
(C) PAN
(D) MAN
Q20 and21are ASSERTION AND REASONING based questions. Mark
the correct choice as

(A)Both Aand R are true and Ris the correct explanation for A 4
(B) Both Aand R are true and R is not the correct explanation for A
(C) A is True but R is False
(D) Ais False but R is True
20 Assertion(A): List is an immutable data type 1

Reasoning(R): When an attempt is made to update the value


of an immutable variable, the old variable is destroyed and a
new variable is created by the same name in memory.
21 Assertion (A): A SELECT Command in SQL can have both
SSS-1207 6

WHERE and HAVINGclauses.

Reasoning (R): WHERE and HAVING clauses are used to


check conditions, therefore, these can be used
interchangeably.
SECTION- B (7X2 =14 MARKS)
22 (A) Which of the following is valid arithmetic operator in Python:
2
(i) (ii) ? (ii) < (iv) and

(B) Write the type of tokens from the following:


(0) if (ii) roll_no

23 (A) ldentify the valid declaration of L: 2


L=[1, 23, 'hi, 6].
(()list (i) dictionary
(ii) array (iv) tuple

(B) Which is the correct form of declaration of dictionary?

()Day={1:'monday',2:'tuesday',3:'wednesday')
(i) Day=(1;'monday',2;'tuesday,3;'wednesday')
(ii) Day=[1:'monday',2:'tuesday,3:'wednesday']
(iv) Day={1'monday',2'tuesday',3wednesday']
24 () Consider the List prices L=[23.811,237.81,238.91]|then 2
(Answer using built in function only)
(A)Write astatement to sort the elements of list prices in
ascendingorder

OR

(B)Write the statement to find the minimum or smallest


element from list

(Gi) Consider the List prices L-Jan","Feb',"Mar"] then


7 SSS-1207

(Answer using built in function only)


(A)Add the element "Apr" at the last

OR

(B) Find the index of "Feb


25 What possible output(s) are expected to be displayed on 2
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 FROM and TO.

import random
AR=[20,30,40,50,60,70];
FROM=random.randint(1,3)
TO=random.randint(2,4)
for Kin range(FROM,TO+1):
print (AR[K],end="#")

() 10#40#70# (ü) 30#40#50#


(iii) 50#60#70# (iv) 40#50#70#
26 Kavi has written a function to print Fibonacci series for first 10 2
element. His code is having errors. Rewrite the correct code
and underline the corrections made. Some initial elements of
Fibonacci series are:

def fibonacci()
first-0second=1
print("first no. is", first)
print ("'second no. is,second)
for a in range (1,9):
third=first+second
print(third)
first, second=second,third
fibonacci()
SSS-1207 8

27 ()
(A) What is the key which depends on the primary value of
another table?

OR
(B)What is the keyword to remove duplicate values from
selecting the record from the table?

(i)
(A) There is a column hobby in a table contacts. The
folowing
two statements are giving different outputs. What may be
the
possible reason?
SELECT COUNT (") FROM CONTACTS;
SELECT COUNT(HOBBY) FROM CONTACTS;

OR

(C) Write an SQL command to make the column M ID the


Primary Key of an already existing table, named MOBILE.
28 (A) Expand the following terms: 2
i. SMTP ii. TCP/AP
(B) Give one difference between XML and HTML?
OR
Write one advantage and one disadvantage of each -
() STAR Topology
(ii) Tree Topology

Section-C(3X3=9 Marks)
29 Write a function in python to count the number of lines in a
text 3
file 'STORY.TXT' which is starting with an alphabet 'A'.
SSS-1207

OR

Write amethod/function DISPLAYWORDS() in python to read


lines from a text file STORY.TXT, and display those words,
which are less than 4 characters.
30 Raju has a list containing 10 integers. You need to help him 3
Create a program with separate user defined functions to
perform the following operations based on this list.
Traverse the content of the list and push the even numbers
into a stack.
> Pop and display the content of the stack.
For example:
Ifthe sample content of the list is as follows:
N=[12,13,34,56,21,79,98,22,35,38]
Sample output of the code should be:
38 22 98 56 34 12
OR
Alist, NList contains followingrecord as list elements:
[City,Country, distance from Delhi]
Each of these records are nested together to form a nested list.
Write the following user defined functions in Python to perform
the specifiedoperations on the stack named travel.

() Push element(NList): It takes the nested list as an argument


and pushes a list object containing name of the city and
country, which are not in India and distance is less than3500
km from Delhi.

(ü) Pop _element(): t pops the objects from the stack and
displays them. Also, the function should display "Stack Empty"
when there are no elements in the stack. For example:

If the nested list contains the following data:


SSS-1207 10

NList=["New York", "U.S.A.", 11734),


"Naypyidaw", "Myanmar", 3219],
['Dubai", "UAE",2194),
London", "England", 6693],
'Gangtok", "India", 1580),
"Columbo", "Sri Lanka", 3405]1
The stack should contain:
'Naypyidaw,'Myanmar'],
rDubai, 'UAE],
rColumbo, 'Sri Lanka]
The output should be:
rColumbo', 'Sri Lanka')
[Dubai', "UAE]
(Naypyidaw, 'Myanma']
Stack Empty
31 Predict the output of the following code: 3
d=apple": 15, "banana": 7, "cherry": 9)
str1 = n
for key in d:
str1 = str1 + str(d[key]) + "@" + "n"
str2 = str1[:-1]
print(str2)

OR
tuple1 = (11, 22, 33, 44, 55,66)
list1 =list(tuple1)
new_list=[)
for i in list1:
if i%2==0:

new_list.append(i)
new_tuple =tuple(new_ list)
print(new_tuple)

SECTION-D (4X4=16 MARKS)


11 SSS-1207

32 Consider the table Graduate 4

S.NNAME STIPENSUBJECT AVERAG DI


o
1 oo nw
KARAN 400 PHYSICS 68
2 DIWAKA 450 COMP Sc 68
DIVYA 300 CHEMISTR 62
4 REKHA 350 PHYSICS 63
5 ARJUN 500 MATHS 70
6 SABINA 400 CHEMISTR 55
7 JOHN 250 PHYSICS 64
ROBERT 450 MATHS 68
RUBINA 500 COMP Sc 62
10 VIKAS 400 MATHS 57

(A) Write the following queries


1. List the names of those students who have obtained DIVI
sorted by NAME.
2. Display a report, listing NAME, STIPEND, SUBJECT and
amount of stipend received in a year assuming that the
STIPEND is paid every month.
3. To count the number of students who are either PHYSICS
or COMPUTER SC graduates.
4. To insert a new row in the GRADUATE table: 11,"KAJOL"
300, "computer sc", 75, 1
OR

(B)Give the output of following sql statement based on the


above table

1. Select MIN(AVERAGE) from GRADUATE where


SUBJECT="PHYSICS";
2. Select SUM(STIPEND) from GRADUATE WHERE div=2;
SSS-1207 12

3. Select AVG(STIPEND) from GRADUATE where


AVERAGE>=65;
4. Select COUNT(distinct SUBJECT) from GRADUATE:
33 Sangeeta is a Python programmer working in a computer 4
hardware company. She has to maintain the records of the
peripheral devices. She created CSV file named
Peripheral.csv,to store the details.
The structure of Peripheral.csv is:
P_id,P_name, Price]
where
P_id is Peripheral device ID (integer)
P_name is Peripheral device name (String)
Price is Peripheral device price (integer)

Sangeeta wants to write the following user defined functions so


help her out by creating the following user defined functions:

Add Device() :to accept a record from the user and add it to a
csv file, Peripheral.csv
Count_Device() : To count and display number of peripheral
devices whose price is less than 1000.
34 Consider the following tables FACULTY and COURSES. Write 4
SQL commands for the statements (1)to (4)

FACULTY
F ID Fname Lname Hire date Salary
102 Amit Mishra 12-10-1998 12000
103 Nitin Vyas 24-12-1994 8000
104 Rakshit Soni 18-5-2001 14000
105 Rashmi Malhotra11-9-2004 11000
106 Sulekha Srivastava 5-6-2006 10000

COURSES
13 SSs-1207

C_ID| FID Cname Fees


C21 102Grid Computing 40000
C22106 System Design 16000

c23104 Computer Security| 8000


C24 106Human Biology 15000
C25102Computer Network 20000
C26 105 Visual Basic 6000

1.To display details of those Faculties whose salary is greater


than 12000.
2. To display the details of courses whose fees is in
the range of 15000 to 50000 (both values
included).
3. To increase the fees of all courses by 500 of "System
Design" Course.
4. (A) To display details of those courses which are taught by
'Sulekha' in descending order of courses?
OR
(B) ldentify the Primary Key in FACULTY and COURSES
table
35Sumit wants to write a code in Python so help him by writing 4
the code to display all the details of the passengers from the
table flight in MySQL database, Travel. The table contains the
following attributes:

F_ code : Flight code (String)


F_name: Name of flight (String)
Source: Departure city of flight (String)
Destination: Destination city of flight (String)

Consider the following to establish connectivity between


Python and MySQL:
" Username : root
SSS-1207 14

Password: airplane
" Host: localhost

SECTION-E (2X5=10 MARKS)

36(i) Differentiate between rt and w+ file modes in Python. 5


(2+3
(ii) ABinary file, TRAIN.DAT has the following structure: )
[ TNO, TNAME,TTYPE)
Where TNO-Train Number TNAME-Train Name TTYPE is
Train Type.

Write a user defined function, findType(ttype), that accepts


ttype as parameter and displays all the records from the binary
file TRAIN.DAT, that have the value of Train Type as ttype.
37 Roorkee University is setting up its academic blocks at Naya 5
Raipur and is planning to set up a network. The University has
3 academic blocks and one Human Resource Center and
Head Office at Mumbai as shown in the diagram below:
Naya Raipur Mumbai

BUSINESS BLOCK TECHNOLOGY Head Office

LAW BLOCK HR CENTRE

Center to Center distances between various blocks/center is as


follows :

Law Block to business Block 40m


Law block to Technology Block 80m
Law Block to HR center 105m
Business Block to technology 30m
Block
15 SSS-1207

Business Block to HR Center 35m


Technology block to HR center 15m
Mumbai Head Office to Raipur 800
km

Number of computers in each of the blocks/Center is as follow:

BUSINESS 25
BLOCK
TECHNOLOGY 40
BLOCK
LAW BLOCK 15
HRCENTRE 115

Write the Answers:


1.Suggest the most suitable place (i.e., Block/Centre) to install
the server of this University with a suitable reason.
2. Suggest an ideal layout for connecting these blocks/center
for a wired connectivity.
3. Which device will you suggest to be placed/installed in each
of these blocks/centers to efficiently connect all the computers
within these blocks/centers
4. Suggest the placement of a Repeater in the network with
justification.
5.
(A) The university is planning to connect its admission office in
Delhi, which is more than 1250km from university. Which type
of network out of LAN, MAN, or WAN will be formed? Justify
your answer

OR
SSS-1207 16

(B) What would be your recommendation for enabling live


Visual communication between the Admin Office at the Mumbai
campus and the DELHI Head Office from the following options:
a) Video Conferencing
b)Email
c) Telephony
d) Instant Messaging
Code: - KVS (DR)/2024/JI
KENDRIYA VIDYALAYA SANGTHAN, DELHI REGION
Marking Scheme
Pre-Board 1 Examination 2024-25
Class: XII Subject : Computer Science(083)
M.M.: 70 Time : 3 hours

Q
Section – A (21X1=21 Mark Questions) Marks
No.
1 False 1
2 (A) ext#nex 1
3 (C) -6.0 1
4 (C) L * [2] 1
5 (C) puC dlroW 1
6 (C) sub[0]= “ip” 1
7 (B) print(my_dict['apple', 'banana']) 1
8 (B) def 1
9 (B) CHAR 1
10 (A)pickle.dump(<object to be written>, <file handle of open file>) 1
11 (D) ZeroDivisionError 1
12 (C) 20$4 1
13 (B) describe 1
14 (A) Details of all products whose names start with 'App' 1
15 (C) A candidate key that is not a primary key is a foreign key. 1
16 (B)count() 1
17 (B) Telnet 1
18 (B) Gateway 1
19 (C) PAN 1
20 (D) A is False but R is True 1
21 (C) A is True but R is False 1
22 A (i)// (B) (i) Keyword (ii) Variable 1+1
23 (A) list (B) (i) Day={1:’monday’,2:’tuesday’,3:’wednesday’} 1+1
(i) (A) Lsort() or (B) min(L)
1
24 (ii)
1
(ii) (A) L.append(“Apr”) or (B) L.index(“Feb”)
ii) 30#40#50# Maximum value FROM,TO is 3,4)
25 (1/2 mark each for minimum and maximum value) 2
(1 mark for correct option)
def fibonacci():# missingcolon
first=0 second=1
print(“first no. is “, first) # extra parenthesis
print(“secondno.is”,second) #closing quotes is missing
for a in range (1,9):
26 2
third=first+second
print(third)
first,second=second,third
fibonacci() #fuction calling indentation is wrong
½ marks for each correction
(i) (A) Foreign Key (B) DISTINCT 1 mark
27 2
(iii) (A) May contain NULL value (B) alter table mobile add
constraint primary key(M_ID) 1 mark
Page 1 of 4
(a) (i) SMTP- Simple Mail Transfer Protocol
(ii) TCP/IP - Transmission Control Protocol / Internet Protocol
(b) XML and HTML - any 2 points difference both side - ( 1 point - 1
mark)
HTML : Predefined Tag, Display Web page data etc.
XML : User defined tag, creates structured data etc.

OR
Star Topology-
28 Advantage: The network remains operational even if one of the nodes 2
stops working. Disadvantage: The network stops working if the central
hub stops working.
Or any other valid advantage or disadvantage. Each carries 1 mark
Tree Topology-
Advantages- Allows for better organization of large networks with
various levels of hierarchy.
Disadvantage
Allows for better organization of large networks with various levels of
hierarchy. 1 marks
def COUNTLINES():
file=open('STORY.TXT','r')
lines = file.readlines()
count=0
for w in lines:
if w[0]=="A" or w[0]=="a":
count=count+1
print(“Total lines “,count)
file.close()
(½ mark for correct function header)
(½ mark for correctly opening the file)
(½ mark for correctly reading from the file)
(11/2 mark for correctly displaying the desired words) )
OR
29 3
def DISPLAYWORDS():
c=0
file=open(‘STORY.TXT','r')
line = file.read()
word = line.split()
for w in word:
if len(w)<4:
print( w)
file.close()
(½ mark for correct function header)
(½ mark for correctly opening the file)
(½ mark for correctly reading from the file)
(½ mark for splitting the text into words)
(1 mark for correctly displaying the desired words)
N=[12,12,34,56,21,79,98,22,35,38]
def PUSH(S,N):
S.append() 3
30
def POP(S):
If S!=[]:
Page 2 of 4
return S.pop()
else:
return None
ST=[]
for k in N:
if k%2==0
PUSH(ST,k)
while True:
If ST![]:
print(POP(ST),end=“ ”)
else:
break
OR
travel = []
def push_element(Nlist):
for L in Nlist:
if L[1] !=”India” and L[2] <3500:
travel.append(L[0],L[1])
def pop_element():
while len(travel):
print(travel.pop())
else:
print(“Stack empty”)
(A) 15@
7@
3
31 9@
OR
(22,44,66)
1. SELECT NAME from GRADUATE where DIV = ‘I’ order by NAME;
2. SELECT NAME, STIPEND, SUBJECT, STIPEND*12 from
GRADUATE;
3. SELECT SUBJECT, COUNT (*) from GRADUATE group by
SUBJECT having SUBJECT=’PHYISCS’ or SUBJECT=’COMPUTER
32 4
SC’;
4. INSERT INTO GRADUATE values (11,’KAJOL’,300,’COMPUTER
SC’,75,1);
OR
1. 63 2. 800 3. 475 4. 4
import csv
def Add_Device():
F=open("Peripheral.csv","a",newline='')
csv.writer(F)
P_id=int(input("Enter the Peripheral ID"))
P_name=input("Enter Peripheral Name")
Price=int(input("Enter Price"))
33 L=[P_id,P_name,Price] 4
W.writerow(L)
F.close()
def Count_Device():
F=open("Peripheral.csv","r")
L=list(csv.reader(F))
Count=0
for D in L:
Page 3 of 4
if int(D[2])<1000:
Count+=1
print(Count)
F.close()
OR
Any other correct variation of the code
1. Select * from faculty where salary > 12000;
2.Select * from Courses.where fees between 15000 and 50000;
3. Update courses set fees = fees + 500 where Cname = “System
Design”;
34 4
4. Select * from faculty fac,courses cour where fac.f_id = cour.f_id and
fac.fname = 'Sulekha' order by cname desc;
OR
C_ID F_ID
import pymysql as pm
DB=pm.connect(host="localhost",user="root",\
password="airplane",database="Travel")
MyCursor=DB.cursor()
35 4
MyCursor.execute("SELECT * FROM Flight ")
Rec=MyCursor.fetchall()
for R in Rec:
print (R)
1 mark for each difference (minimum Two difference) 2 marks • if the
file does not exist, it results in an error
r+ mode: Primary function is reading File pointer is at beginning of file
w+ mode: primary function is writing if the file does not exist, it creates
a new file. If the file exists, previous data is overwritten File pointer is
at the beginning of file
(ii)
def findtype (ttype) :
36 f = open (“TRAIN.DAT”, “rb”) 5
try :
while True :
data = pickle.load (f)
if data[2] == ttype :
print (“Train Number :”, data[0] )
print (“Train Name :”, data[1] )
print (“Train Type :”, data[2] )
except EOFError : f.close()
(i) Most suitable place to install the server is HR centre, as this center
has maximum number of computers
(ii) 1 marks for correct layout
(iii) switch
37 5
(iv) 1 mark for correct answer
(v) WAN, as the given distance is more than the range of LAN and MAN.
OR
Video conferencing

Page 4 of 4
SSS-1207

P-16
Pre-Board-1 Examination 2024-25
Class: XII
Subject: Computer Science (083)
M.M.: 70 Time: 3 hours

General Instructions:
" This question paper contains 37 questions.
Allquestions are compulsory. However, internalchoices have been
provided insome questions. Attempt only one of the choices in such
questions
The paper is divided into 5 Sections- A, B, C, D and E.
" Section Aconsists of 21 questions (1 to 21). Each question carries 1
Mark.
" Section Bconsists 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

Q
No SECTION-A (21X1=21 MARKS) Marks
1 State True or False:"In Python tuple is mutable datatype"
2 What willthe output of the following code
S="text#next"
print(S.strip(""))
(A) ext#nex
SSS-1207 2

(B)ex#nex
(C) text#nex
(D) ext#next
3 What will be the output of the following statement: 1
print( 3-2 **2 **2 + 77/11 )
(A) 6
(B) 6.0
(C) -6.0
(D) Error
4 Consider a list L= [H,U, 'L, K]. Which of the folowing 1
operations will result in an error?
(A)L*2
(B) L + [21
(C) L*[2]
(D) 2*L
5Consider the statements given below and then cho0se the 1
correct output from the given options:
Game="World Cup 2023"
print(Game(-6:-1)
(A)CdrW
(B)ce o
(C) puC dlroW
(D) Error
6Consider the tuple in python named sub=( "cs", "phy", "mat"). 1
Identify the invalid statement(s) from the given below
statements:
(A) s=sub[1]
(B) print(sub[2])
(C) sub[o]= "ip"
(D) list=list(sub)
7 Ifmy_dict is a dictionary as defined below, then which of the 1
following statements willraise an exception?
my_dict =('apple': 10,'banana': 20, 'orange': 30)
(A)my_dict.get('orange')
(B) print(my_dict['apple', 'banana])
3 SSS-1207
(C) my_dict['apple']=20
(D) print(str(my_dict)
Which keyword is used for function in python? 1
(A)Fun
(B) def
(C) DEFINE
(D) Function
Mr. Ravi is creating a field that contains alphanumeric values 1
and fixed lengths. Which MySQL data type should he choose
for the same?
(A)VARCHAR
(B)CHAR
(C) LONG
(D) NUMBER
10 Which is the valid syntaxto write an object onto a binary file 1
opened in the write mode?
(A) pickle.dump(<object to be wrtten>, <file handle of
open file>)
(B) pickle.dump(<file handle of open file>, <object to be
written>)
(C) dump.pickle(<object>,<file handle>)
(D) None of the above
11 The output of the given expression is 1
>>>20 * (20/0)
(A) NameEr ror
(B)TypeError
(C)OverflowError
(D)ZeroDivisionError
12 What will be the output of the following code? 1
a= 15
def update(x):
global a
a t=2
if x%2==0:
a *= X
SSs-1207 4

else:
a l/= x
a=a+5
print(a, end="$")
update(5)
print(a)

(A)20$11
(B)15$4
(C) 20$4
(D) 22$4
13 The structure of the table/relation can be displayed using 1
command.

(A)view
(B) describe
(C) show
(D) select
14 What will be the output of the query? 1

SELECT * FROM products WHERE product_name LIKE


'App%';

(A)Detals of all products whose names start with 'App'


(B)Details of all products whose names end with 'App'
(C) Names of allproducts whose names start with 'App'
(D) Names of allproducts whose nanmes end with 'App'
15 Which of the following statements is FALSE about keys in a 1
relational database?

(A)Any candidate key is eligible to become a primary key.


(B) Aprimary key uniquely identifies the tuples in a relation.
(C)Acandidate key that is not a primary key is a foreign key.
(D) A
foreign key is an attribute whose value is derived from
the primary key of another relation.
16 Which aggregate functioncan be used to find the cardinality of 1
5 SSS-1207
a table?
(A)sum()
(B)count()
(C)avg()
(D)max()
17 Which protocol is used to transfer files over the Internet? 1
(A) HTTP
(B) Telnet
(C) PPP
(D)HTTPS
Which network device is used to connect two networks that use 1
different protocols?
18
(A)Modem
(B)Gateway
(C) Switch
(D) Repeater
When youconnect two mobile phones using Bluetooth to 1
transfer a picture or file which type of network is formed
19
(A) LAN
(B) WAN
(C) PAN
(D) MAN
Q20 and21are ASSERTION AND REASONING based questions. Mark
the correct choice as

(A)Both Aand R are true and Ris the correct explanation for A 4
(B) Both Aand R are true and R is not the correct explanation for A
(C) A is True but R is False
(D) Ais False but R is True
20 Assertion(A): List is an immutable data type 1

Reasoning(R): When an attempt is made to update the value


of an immutable variable, the old variable is destroyed and a
new variable is created by the same name in memory.
21 Assertion (A): A SELECT Command in SQL can have both
SSS-1207 6

WHERE and HAVINGclauses.

Reasoning (R): WHERE and HAVING clauses are used to


check conditions, therefore, these can be used
interchangeably.
SECTION- B (7X2 =14 MARKS)
22 (A) Which of the following is valid arithmetic operator in Python:
2
(i) (ii) ? (ii) < (iv) and

(B) Write the type of tokens from the following:


(0) if (ii) roll_no

23 (A) ldentify the valid declaration of L: 2


L=[1, 23, 'hi, 6].
(()list (i) dictionary
(ii) array (iv) tuple

(B) Which is the correct form of declaration of dictionary?

()Day={1:'monday',2:'tuesday',3:'wednesday')
(i) Day=(1;'monday',2;'tuesday,3;'wednesday')
(ii) Day=[1:'monday',2:'tuesday,3:'wednesday']
(iv) Day={1'monday',2'tuesday',3wednesday']
24 () Consider the List prices L=[23.811,237.81,238.91]|then 2
(Answer using built in function only)
(A)Write astatement to sort the elements of list prices in
ascendingorder

OR

(B)Write the statement to find the minimum or smallest


element from list

(Gi) Consider the List prices L-Jan","Feb',"Mar"] then


7 SSS-1207

(Answer using built in function only)


(A)Add the element "Apr" at the last

OR

(B) Find the index of "Feb


25 What possible output(s) are expected to be displayed on 2
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 FROM and TO.

import random
AR=[20,30,40,50,60,70];
FROM=random.randint(1,3)
TO=random.randint(2,4)
for Kin range(FROM,TO+1):
print (AR[K],end="#")

() 10#40#70# (ü) 30#40#50#


(iii) 50#60#70# (iv) 40#50#70#
26 Kavi has written a function to print Fibonacci series for first 10 2
element. His code is having errors. Rewrite the correct code
and underline the corrections made. Some initial elements of
Fibonacci series are:

def fibonacci()
first-0second=1
print("first no. is", first)
print ("'second no. is,second)
for a in range (1,9):
third=first+second
print(third)
first, second=second,third
fibonacci()
SSS-1207 8

27 ()
(A) What is the key which depends on the primary value of
another table?

OR
(B)What is the keyword to remove duplicate values from
selecting the record from the table?

(i)
(A) There is a column hobby in a table contacts. The
folowing
two statements are giving different outputs. What may be
the
possible reason?
SELECT COUNT (") FROM CONTACTS;
SELECT COUNT(HOBBY) FROM CONTACTS;

OR

(C) Write an SQL command to make the column M ID the


Primary Key of an already existing table, named MOBILE.
28 (A) Expand the following terms: 2
i. SMTP ii. TCP/AP
(B) Give one difference between XML and HTML?
OR
Write one advantage and one disadvantage of each -
() STAR Topology
(ii) Tree Topology

Section-C(3X3=9 Marks)
29 Write a function in python to count the number of lines in a
text 3
file 'STORY.TXT' which is starting with an alphabet 'A'.
SSS-1207

OR

Write amethod/function DISPLAYWORDS() in python to read


lines from a text file STORY.TXT, and display those words,
which are less than 4 characters.
30 Raju has a list containing 10 integers. You need to help him 3
Create a program with separate user defined functions to
perform the following operations based on this list.
Traverse the content of the list and push the even numbers
into a stack.
> Pop and display the content of the stack.
For example:
Ifthe sample content of the list is as follows:
N=[12,13,34,56,21,79,98,22,35,38]
Sample output of the code should be:
38 22 98 56 34 12
OR
Alist, NList contains followingrecord as list elements:
[City,Country, distance from Delhi]
Each of these records are nested together to form a nested list.
Write the following user defined functions in Python to perform
the specifiedoperations on the stack named travel.

() Push element(NList): It takes the nested list as an argument


and pushes a list object containing name of the city and
country, which are not in India and distance is less than3500
km from Delhi.

(ü) Pop _element(): t pops the objects from the stack and
displays them. Also, the function should display "Stack Empty"
when there are no elements in the stack. For example:

If the nested list contains the following data:


SSS-1207 10

NList=["New York", "U.S.A.", 11734),


"Naypyidaw", "Myanmar", 3219],
['Dubai", "UAE",2194),
London", "England", 6693],
'Gangtok", "India", 1580),
"Columbo", "Sri Lanka", 3405]1
The stack should contain:
'Naypyidaw,'Myanmar'],
rDubai, 'UAE],
rColumbo, 'Sri Lanka]
The output should be:
rColumbo', 'Sri Lanka')
[Dubai', "UAE]
(Naypyidaw, 'Myanma']
Stack Empty
31 Predict the output of the following code: 3
d=apple": 15, "banana": 7, "cherry": 9)
str1 = n
for key in d:
str1 = str1 + str(d[key]) + "@" + "n"
str2 = str1[:-1]
print(str2)

OR
tuple1 = (11, 22, 33, 44, 55,66)
list1 =list(tuple1)
new_list=[)
for i in list1:
if i%2==0:

new_list.append(i)
new_tuple =tuple(new_ list)
print(new_tuple)

SECTION-D (4X4=16 MARKS)


11 SSS-1207

32 Consider the table Graduate 4

S.NNAME STIPENSUBJECT AVERAG DI


o
1 oo nw
KARAN 400 PHYSICS 68
2 DIWAKA 450 COMP Sc 68
DIVYA 300 CHEMISTR 62
4 REKHA 350 PHYSICS 63
5 ARJUN 500 MATHS 70
6 SABINA 400 CHEMISTR 55
7 JOHN 250 PHYSICS 64
ROBERT 450 MATHS 68
RUBINA 500 COMP Sc 62
10 VIKAS 400 MATHS 57

(A) Write the following queries


1. List the names of those students who have obtained DIVI
sorted by NAME.
2. Display a report, listing NAME, STIPEND, SUBJECT and
amount of stipend received in a year assuming that the
STIPEND is paid every month.
3. To count the number of students who are either PHYSICS
or COMPUTER SC graduates.
4. To insert a new row in the GRADUATE table: 11,"KAJOL"
300, "computer sc", 75, 1
OR

(B)Give the output of following sql statement based on the


above table

1. Select MIN(AVERAGE) from GRADUATE where


SUBJECT="PHYSICS";
2. Select SUM(STIPEND) from GRADUATE WHERE div=2;
SSS-1207 12

3. Select AVG(STIPEND) from GRADUATE where


AVERAGE>=65;
4. Select COUNT(distinct SUBJECT) from GRADUATE:
33 Sangeeta is a Python programmer working in a computer 4
hardware company. She has to maintain the records of the
peripheral devices. She created CSV file named
Peripheral.csv,to store the details.
The structure of Peripheral.csv is:
P_id,P_name, Price]
where
P_id is Peripheral device ID (integer)
P_name is Peripheral device name (String)
Price is Peripheral device price (integer)

Sangeeta wants to write the following user defined functions so


help her out by creating the following user defined functions:

Add Device() :to accept a record from the user and add it to a
csv file, Peripheral.csv
Count_Device() : To count and display number of peripheral
devices whose price is less than 1000.
34 Consider the following tables FACULTY and COURSES. Write 4
SQL commands for the statements (1)to (4)

FACULTY
F ID Fname Lname Hire date Salary
102 Amit Mishra 12-10-1998 12000
103 Nitin Vyas 24-12-1994 8000
104 Rakshit Soni 18-5-2001 14000
105 Rashmi Malhotra11-9-2004 11000
106 Sulekha Srivastava 5-6-2006 10000

COURSES
13 SSs-1207

C_ID| FID Cname Fees


C21 102Grid Computing 40000
C22106 System Design 16000

c23104 Computer Security| 8000


C24 106Human Biology 15000
C25102Computer Network 20000
C26 105 Visual Basic 6000

1.To display details of those Faculties whose salary is greater


than 12000.
2. To display the details of courses whose fees is in
the range of 15000 to 50000 (both values
included).
3. To increase the fees of all courses by 500 of "System
Design" Course.
4. (A) To display details of those courses which are taught by
'Sulekha' in descending order of courses?
OR
(B) ldentify the Primary Key in FACULTY and COURSES
table
35Sumit wants to write a code in Python so help him by writing 4
the code to display all the details of the passengers from the
table flight in MySQL database, Travel. The table contains the
following attributes:

F_ code : Flight code (String)


F_name: Name of flight (String)
Source: Departure city of flight (String)
Destination: Destination city of flight (String)

Consider the following to establish connectivity between


Python and MySQL:
" Username : root
SSS-1207 14

Password: airplane
" Host: localhost

SECTION-E (2X5=10 MARKS)

36(i) Differentiate between rt and w+ file modes in Python. 5


(2+3
(ii) ABinary file, TRAIN.DAT has the following structure: )
[ TNO, TNAME,TTYPE)
Where TNO-Train Number TNAME-Train Name TTYPE is
Train Type.

Write a user defined function, findType(ttype), that accepts


ttype as parameter and displays all the records from the binary
file TRAIN.DAT, that have the value of Train Type as ttype.
37 Roorkee University is setting up its academic blocks at Naya 5
Raipur and is planning to set up a network. The University has
3 academic blocks and one Human Resource Center and
Head Office at Mumbai as shown in the diagram below:
Naya Raipur Mumbai

BUSINESS BLOCK TECHNOLOGY Head Office

LAW BLOCK HR CENTRE

Center to Center distances between various blocks/center is as


follows :

Law Block to business Block 40m


Law block to Technology Block 80m
Law Block to HR center 105m
Business Block to technology 30m
Block
15 SSS-1207

Business Block to HR Center 35m


Technology block to HR center 15m
Mumbai Head Office to Raipur 800
km

Number of computers in each of the blocks/Center is as follow:

BUSINESS 25
BLOCK
TECHNOLOGY 40
BLOCK
LAW BLOCK 15
HRCENTRE 115

Write the Answers:


1.Suggest the most suitable place (i.e., Block/Centre) to install
the server of this University with a suitable reason.
2. Suggest an ideal layout for connecting these blocks/center
for a wired connectivity.
3. Which device will you suggest to be placed/installed in each
of these blocks/centers to efficiently connect all the computers
within these blocks/centers
4. Suggest the placement of a Repeater in the network with
justification.
5.
(A) The university is planning to connect its admission office in
Delhi, which is more than 1250km from university. Which type
of network out of LAN, MAN, or WAN will be formed? Justify
your answer

OR
SSS-1207 16

(B) What would be your recommendation for enabling live


Visual communication between the Admin Office at the Mumbai
campus and the DELHI Head Office from the following options:
a) Video Conferencing
b)Email
c) Telephony
d) Instant Messaging
FIRST PRE BOARD EXAM (2024-25)
CLASS-XII
SUBJECT- COMPUTER SCIENCE(083)
QP12ACS01PB24
TIME-3:00 HRS Max Marks-70
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.
 This question paper contains five sections, Section A to E.
 Section A have 21 questions (1 to 21) carrying 01 mark each.
 Section B has 07 questions (22 to 28) carrying 02 marks each.
 Section C has 03 questions (29 to 31) carrying 03 marks each.
 Section D has 04 questions (32 to 35) carrying 04 marks each.
 Section E has 02 questions (36 to 37) carrying 05 marks each.
 All programming questions are to be answered using Python Language only.
 In case of MCQs, text of the correct answer should also be written.
SECTION A
1. State True or False 1
“Variable declaration is implicit in Python.”
2. Which of the following is an invalid datatype in Python? 1
(a) Set (b) None
(c) Integer (d) Real
3. Given the following dictionaries 1
dict_exam={"Exam":"AISSCE", "Year":2025}
dict_result={"Total":500, "Pass_Marks":165}
Which statement will merge 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)
4. Consider the given expression: 1
not True and False or True
Which of the following will be correct output if the given expression isevaluated?
(a) True (b) False
(c) NONE (d) NULL
5. Select the correct output of the code: 1
a = "Year 2022 at All the best"
a = a.split('2')
b = a[0] + ". " + a[1] + ". " + a[3]
print (b)
(a) Year . 0. at All the best
(b) Year 0. at All the best
(c) Year . 022. at All the best
(d) Year . 0. at all the best
6. Which of the following mode in file opening statement results or generates an error if the 1
file does not exist?
(a) a+ (b) r+ (c) w+ (d) None of the above
7. Fill in the blank: 1
command is used to remove primary key from the table in SQL.
(a) update (b)remove (c) alter (d)drop
8. Which of the following commands will delete the table from MYSQL database? 1
(a) DELETE TABLE (b) DROP TABLE
(c) REMOVE TABLE (d) ALTER TABLE
9. Which of the following statement(s) would give an error after executing the 1
following code?
S="Welcome to class XII" # Statement 1
print(S) # Statement 2
S="Thank you" # Statement 3
S[0]= '@' # Statement 4
S=S+"Thank you" # Statement 5
(a) Statement 3
(b) Statement 4
(c) Statement 5
(d) Statement 4 and 5
10. Fill in the blank: 1
is a non-key attribute, whose values are derived from the primary key of some
other table.
(a) Primary Key (b) Foreign Key
(c) Candidate Key (d) Alternate Key
11. The correct syntax of seek() is: 1
(a) file_object.seek(offset [, reference_point])
(b) seek(offset [, reference_point])
(c) seek(offset, file_object)
(d) seek.file_object(offset)
12. Fill in the blank: 1
The SELECT statement when combined with clause, returns records
without repetition.
(a) DESCRIBE (b) UNIQUE
(c) DISTINCT (d) NULL
13. Fill in the blank: 1
is a communication methodology designed to deliver both voiceand multimedia
communications over Internet protocol.
(a) VoIP (b) SMTP (c) PPP (d)HTTP
14. What will the following expression be evaluated to in Python? 1
print(15.0 / 4 + (8 + 3.0))
(a) 14.75 (b)14.0 (c) 15 (d) 15.5
15. Which function is used to display the total number of records from table in a database? 1
(a) sum(*) (b) total(*)
(c) count(*) (d) return(*)
16. To establish a connection between Python and SQL database, connect() is used. Which of 1
the following arguments may notnecessarily be given while calling connect()?
(a) host (b) database
(c) user (d) Password
17. What is the scope of a variable defined outside of any function? 1
(a) Global scope (b) Local scope
(c) Module- scope (d) Function- scope
18. How do you check if a file exists before opening it in Python? 1
a) Use the exists() function from the os module
b) Use the open() function with the try-except block
c) Use the isfile() function from the os.path module
d) All of the above
19. Which type of network consists of both LANs and MANs? 1
(a) Wide Area Network (b) Local Area Network
(c) Both a and b (d) None of the above
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
20. 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.
Reasoning (R):- During a function call, the argument list first contains default argument(s)
followed by positional argument(s).
21. Assertion (A): CSV (Comma Separated Values) is a file format for datastorage which looks 1
like a text file.
Reason (R): The information is organized with one record on each line and each field is
separated by comma.
SECTION B
22. Rao has written a code to input a number and check whether it is prime or not. His code is 2
having errors. Rewrite the correct code andunderline the corrections made.
def prime():
n=int(input("Enter number to check :: ")
for i in range (2, n//2):
if n%i=0:
print("Number is not prime \n")
break
else:
print("Number is prime \n’)
23. Write two points of difference between Circuit Switching and PacketSwitching. 2

OR

Write two points of difference between XML and HTML.


24. (a) Given is a Python string declaration: 1
myexam="@@CBSE Examination 2022@@"
Write the output of: print(myexam[::-2])
(b) Write the output of the code given below:
my_dict = {"name": "Aman", "age": 26} 1
my_dict['age'] = 27
my_dict['address'] = "Delhi"
print(my_dict.items())
25. Explain the use of „Foreign Key‟ in a Relational Database Management System. Give 2
example to support your answer.
26. (a) Write the full forms of the following: 2
i. SMTP (ii) PPP

(b) What is the use of TELNET?


27. Predict the output of the Python code given below: 2

def Diff(N1,N2):if
N1>N2:
return N1-N2
else:
return N2-N1

NUM= [10,23,14,54,32]
for CNT in range (4,0,-1):
A=NUM[CNT]
B=NUM[CNT-1]
print(Diff(A,B),'#', end=' ')

OR

Predict the output of the Python code given below:

tuple1 = (11, 22, 33, 44, 55 ,66)


list1 =list(tuple1)
new_list = []
for i in list1:if
i%2==0:
new_list.append(i) new_tuple = tuple(new_list)
print(new_tuple)
28. Differentiate between count() and count(*) functions in SQL withappropriate example. 2

OR

Categorize the following commands as DDL or DML:INSERT, UPDATE, ALTER, DROP


SECTION C
29. (a) Consider the following tables – Bank_Account and Branch: 1+2

What will be the output of the following statement?


SELECT * FROM Bank_Account NATURAL JOIN Branch;
(b)Write the output of the queries (i) to (iv) based on the given table,
i. SELECT DISTINCT TID FROM TECH_COURSE;
ii. SELECT TID, COUNT(*), MIN(FEES) FROM TECH_COURSE GROUP BY TID
HAVING COUNT(TID)>1;
iii. SELECT CNAME FROM TECH_COURSE WHERE FEES>15000 ORDER BY
CNAME;
iv. SELECT AVG(FEES) FROM TECH_COURSE WHERE FEES BETWEEN 15000
AND 17000;
30. Write a method COUNTLINES() in Python to read lines from text file „TESTFILE.TXT‟ 3
and display the lines which are not starting with any vowel. Example:
If the file content is as follows:
An apple a day keeps the doctor away.
We all pray for everyone‟s safety.
A marked difference will come in our country. T

he COUNTLINES() function should display the output as:


The number of lines not starting with any vowel - 1

OR

Write a function ETCount() in Python, which should read each character of a text file
“TESTFILE.TXT” and then count and display the count of occurrence of alphabets E
and T individually (includingsmall cases e and t too).

Example:

If the file content is as follows:

Today is a pleasant day. It might


rain today.
It is mentioned on weather sites

The ETCount() function should display the output as:E or e: 6


T or t : 9
31. (a) Write the outputs of the SQL queries (i) to (iv) based on the relations Teacher and 2+1
Placement given below:
i. SELECT Department, avg(salary) FROM Teacher GROUP BY
Department;
ii. SELECT MAX(Date_of_Join),MIN(Date_of_Join) FROM
Teacher;
iii. SELECT Name, Salary, T.Department, Place FROM
Teacher T, Placement P WHERE T.Department =
P.Department AND Salary>20000;
iv. SELECT Name, Place FROM Teacher T, Placement P
WHERE Gender =’F’ AND T.Department=P.Department;
(b) Write the command to view all tables in a database.
SECTION D
32. (a) What will be the output of the following code? 2+2
x = 3
def myfunc():
global x
x+=2
print(x, end=' ')
print(x, end=' ')
myfunc()
print(x, end=' ')
(b)Consider the code given below
Import_______as sqltor
conn=sqltor.connect(host='localhost',user='john',password=''
,database='test')
cursor=_________________
query =__________________
cursor.execute(query)
data=______________
for row in data:
print(row)

The above code displays all details of students present in the table Student whose marks are
more than and grade is „B‟ using Python MySQL connectivity. Complete the missing code
by fill in the blanks.
33. (a) differentiate dump() and load() in the context of binaryfile. 2+2
(b) Write a Program in Python that defines and calls the following user defined functions:
i. add() – To accept and add data of a Product to a CSV file „Product.csv‟.Each record
consists of a list with field elements as pid, pname and price to store Product id,
Product name and Product price respectively.
ii. search()- To display the records of the Product whose price is more than 20000 and
product name starting with a vowel.
34. Write a program to create a Stack of Students containing 5 records each record structured as 4
[Roll, Name, Percentage of marks].Perform the following:
a) Display all the details of the Student who got the highest percentage of marks.
b) Insert a new Record to a Stack.
c) Remove the student details who scored less than 90% and display Stack.
35. A school wants to store its students' records in digital form. For this they want the 2+2
following information of each student to be stored:
- Student_ID – integer
- Student_Name – string
- Class – integer
- House – string

You, as a programmer, have been assigned to do this job for school.


1. Write a function to input the data of a student and append it in a binary file.
2. Write a function to update the data of student whose house is Ashoka and change
it to Raman.
SECTION E
36. Intelligent Hub India is a knowledge community aimed to uplift the standard of skills and 5
knowledge in the society. It is planning to setup its training centers in multiple towns and
villages of India with its head offices in the nearest cities. They have created a model of
their network with a city, a town and 3 villages as given. As a network consultant, you have
to suggest the best network related solution for their issues/problems raised in (a) to (e)
keeping in mind the distance between various locations and given parameters.
a) Suggest the most appropriate location of the SERVER in the YHUB (out of the 4
locations), to getthe best and effective connectivity. Justify your answer.
b) Suggest the best wired medium and draw the cable layout (location to location) to
efficientlyconnect various locations within the YHUB.
c) Which hardware device will you suggest to connect all the computers within each
location ofYHUB?
d) Which server/protocol will be most helpful to conduct live interaction of Experts
from Head officeand people at YHUB locations?
e) Suggest a device/software and its placement that would provide data security for the
entire networkof the YHUB.
37. You are working on a project that involves managing inventory records of a store in a 5
MySQL database. Your task is to create a Python program that performs the following
operations:

1. Connect to the MySQL database: Assume the database is named STOREDB, the
user is admin, and the password is admin123. The MySQL is available on a local
computer, not a remote computer.
2. Create a table: The table INVENTORY should have the following columns:
o ProductID (INTEGER, Primary Key, Auto Increment)
o ProductName (VARCHAR(100))
o Price (FLOAT(8,2))
o PurchaseDate (DATE)
3. Insert data into the table: Insert at least three records with sample data into the
INVENTORY table.
4. Retrieve and display all records: Write a Python function that retrieves all records
from the INVENTORY table and prints them in a readable format.

END
FIRST PRE BOARD EXAM (2024-25)
CLASS-XII
SUBJECT- COMPUTER SCIENCE(083)
MS12ACS01PB24
MARKING SCHEME
SECTION A
1. True 1
2. (d) real 1
3. (a) dict_exam.update(dict_result) 1
4. (a) True 1
5. (a) Year . 0. at All the best 1
6. (b) r+ 1
7. (c) alter 1
8. (b) DROP TABLE 1
9. (b) Statement 4 1
10. (b) Foreign Key 1
11. (a) file_object.seek(offset [, reference_point]) 1
12. (c ) DISTINCT 1
13. (a) VoIP 1
14. (a) 14.75 1
15. (c ) count(*) 1
16. (b) database 1
17. (a) Global scope 1
18. (d) All of the above 1
19. (a) Wide Area Network 1
20. (c ) A is True but R is False 1
21. (a) Both A and R are true and R is the correct explanation for A 1
SECTION B
22. def prime(): 2
n=int(input("Enter number to check :: ")) #bracket missing
for i in range (2, n//2):
if n%i==0: # = missing
print("Number is not prime \n")
break #wrong indent
else:
print("Number is prime \n”) # quote mismatch
(½ mark for each correct correction made and underlined.)
23. Circuit Switching Packet Switching 2
Circuit switching is a method of switching Packet switching is the method of
which is used for establishing a dedicated switching where no dedicated path is
path communication path between the established from the source to the
sender and the receiver destination
Data is processed and transmitted at the Data is processed and transmitted ,not only
source only. at the source but at each switching station.
It is more reliable. It is less reliable.
( 1 mark for each correct point of difference-Any two)

OR
XML(Extensible MarkupLangauge) HTML (Hypertext Markup Langauge)
XML tags are not predefined, they are user HTML tags are pre-defined and it is a
defined markup language
XML stores and transfers data. HTML is about displaying data.
Dynamic in nature Static in nature
(1 mark for each correct difference - Any two)
24. (a) @20 otnmx SC@ 1

(1 mark for the correct answer)

(b) dict_items([('name', 'Aman'), ('age', 27), ('address', 'Delhi')])


1
(1 mark for the correct answer)
25. 2
A foreign key is used to set or represent a relationship between two relations ( or tables) in a
database. Its value is derived from the primary key attribute of another relation.

For example:
In the tables TRAINER and COURSE given below, TID is primary key in TRAINER table
but foreign key in COURSE table.
TRAINER
TID TNAME CITY HIREDATE SALARY
101 Ritu Nagpur 1998-10-15 56700
102 Navin Goa 1994-12-24 80000
103 Murugan Chandigarh 2001-12-21 82000
104 Jyothi Guwahati 2002-12-25 68000
105 Chanu Mumbai 1996-01-12 95000
106 Arbaaz Delhi 2001-12-12 69000

COURSE

CID CNAME FEES STARTDATE TID


C201 Deepa 12000 1998-10-15 101
C202 Sindhu 15000 1994-12-24 103
C203 Neeraj 10000 2001-12-21 102
C204 Prakash 9000 2002-12-25 104
C205 Nikhat 20000 1996-01-12 101
(1 mark for explanation and 1 mark for example) ( Any relevant correct example may be
marked)
26. (a) Write the full forms of the following: 2
(i) SMTP: Simple Mail Transfer Protocol
(ii) PPP: Point to Point Protocol
(½ mark for every correct full form)

(b) TELNET is used to access a remote computer / network.


(1 mark for correct answer)
27. 22 # 40 # 9 # 13 # 2
(½ mark for the correct digit with a #)
OR

(22,44,66)

( ½ mark for each correct digit , ½ mark for enclosing in parenthesis)


28. COUNT(*) returns the count of all rows in the table, whereas COUNT () is used with 2
Column_Name passed as argument and counts the number of non-NULL values in a
column that is given as argument.
Example: Table : EMPL
EMPNO ENAME JOB SAL DEPTNO
8369 SMITH CLERK 2985 10
8499 ANYA NULL 9870 20
8566 AMIR SALESMAN 8760 30
8698 BINA MANAGER 5643 20
8912 SUR NULL 3000 10

e.g. SELECT COUNT(*) FROM EMPL;


output
Count(*)
5

e.g.2 SELECT COUNT(JOB) FROM EMPL;


Output
Count(JOB)
3
Since JOB has 2 NULL values
(1 mark for the difference and 1 mark for appropriate example)

OR

DDL- ALTER,
DROP DML –
INSERT, UPDATE
(½ mark for each correct categorization)

SECTION C
29. (a) output 1+2

Acode Name Type City


A01 Amrita Savings Delhi
A01 Amrita Savings Nagpur
A02 Parthodas Current Mumbai

(1 mark for correct output)


(b)Write the output of the queries (i) to (iv) based on the given table,
i. SELECT DISTINCT TID FROM TECH_COURSE;
DISTINCT ID
101
NULL
102
104
103
( ½ mark for the correct output)

ii. SELECT TID, COUNT(*), MIN(FEES) FROM TECH_COURSE GROUP BY TID


HAVING COUNT(TID)>1;
TID COUNT(*) MIN(FEES)
101 2 12000
( ½ mark for the correct output)

iii. SELECT CNAME FROM TECH_COURSE WHERE FEES>15000 ORDER BY


CNAME;
CNAME
Digital Marketing
Mobile application development
( ½ mark for the correct output)

iv. SELECT AVG(FEES) FROM TECH_COURSE WHERE FEES BETWEEN 15000


AND 17000;
15500.00
( ½ mark for the correct output)

30. def COUNTLINES() : 3


file = open ('TESTFILE.TXT', 'r') lines =
file.readlines()
count=0
for w in lines :
if (w[0]).lower() not in 'aeoiu' count = count
+1
print ("The number of lines not starting with any vowel: ", count)
file.close()
COUNTLINES()

( ½ mark for correctly opening and closing the file


½ for readlines()
½ mar for correct loop
½ for correct if statement
½ mark for correctly incrementing count
½ mark for displaying the correct output

OR

def ETCount():
file = open ('TESTFILE.TXT', 'r')
lines = file.readlines()
countE=0
countT=0
for w in lines :
for ch in w:
if ch in 'Ee':
countE = countE + 1
if ch in 'Tt':
countT=countT + 1
print ("The number of E or e : ", countE)
print ("The number of T or t : ", countT)
file.close()

(½ mark for correctly opening and closing the file


½ for readlines()
½ mark for correct loops
½ for correct if statement
½ mark for correctly incrementing counts
½ mark for displaying the correct output)
Note: Any other relevant and correct code may be marked
31. (a) Write the outputs of the SQL queries (i) to (iv) based on the relations Teacher and 2+1
Placement given below:
i. SELECT Department, avg(salary) FROM Teacher GROUP BY
Department;
Department Avg(Salary)
Computer Sc 16500.00
History 30000.00
Mathematics 25000.00
( ½ mark for the correct output)

ii. SELECT MAX(Date_of_Join),MIN(Date_of_Join) FROM


Teacher;
Max(Date_of_Join) Min(Date_of_Join)
2021-09-05 2017-03-04
( ½ mark for the correct output)

iii. SELECT Name, Salary, T.Department, Place FROM


Teacher T, Placement P WHERE T.Department =
P.Department AND Salary>20000;
Name Salary Department Place
Randeep 30000 Mathematics Jaipur
Samira 40000 History Ahmedabad
Raman 25000 Mathematics Jaipur
Shyam 30000 History Ahmedabad
Shiv 21000 Compuer Sc Nagpur
( ½ mark for the correct output)

iv. SELECT Name, Place FROM Teacher T, Placement P


WHERE Gender =’F’ AND T.Department=P.Department;
Name Place
Samira Ahmedabad
Suman Ahmedabad
Salaka Jaipur
( ½ mark for the correct output)

(b) Write the command to view all tables in a database.


SHOW TABLES;
( 1 mark for correct answer)
SECTION D
32. (a) 3 5 5 2+2
[1 marks for correct output]

(b)Consider the code given below


Import mysql.connector as sqltor
conn=sqltor.connect(host='localhost',user='john',password=''
,database='test')
cursor= conn.cursor()
query =”select * from student where marks>75 and grade=”B”
cursor.execute(query)
data= cur.fetchall()
for row in data:
print(row)

[0.5 mark each for first two fill in balcks and 1 mark each for last two]
33. (a) dump(object , file_handler) - used to write any object to the binary file. 1+3
Object=load(file_handler) - used to read object from the binary file.
[1 mark for correct answer]
(b)
import csv

def add():
l=[]
for i in range(4):
pid=input("Enter
pid")
pname=input("Enter
Pname")
price=int(input("Enter price
of product"))
p=[pid,pname,price]
l.append(p)
f=open("product.csv",'w',delimeter="
\n") w=csv.writer()
w.writerows
(l,f)
f.clsoe()

def search():
f=open("product.c
sv",'r')
r=csv.reader()
for i in r:
if i[2]>20000 and i[1][0] in
"AEIOUaeiou": print(*i)

add()
search()
[1.5 marks each for two functions]
34. DefST(s): 4
max=0 for i
in s:
if
i[2]>m
ax:
max=s[
2]
for i in s:
if
max==i[
2]:
print(*
s)

def push(s):
roll=int(input("Enter
roll number"))
name=input("Enter Name")
per=float(input("Enter
percentage"))
s.append([roll,name,per])
print("Status of stack
after push") for i in s:
print(*i)

def
remove(s
): for i
in s:
if
i[2]<
90:
print
(*i)

st=[] push(st)
push(st)
push(st) ST(st)
remove(st)
[1 mark each for each function and 1 mark for display]

35. i) def append_student_to_file(filename): 4


# Input student details
student_id = int(input("Enter Student_ID (integer):
"))
student_name = input("Enter Student_Name (string):
")
student_class = int(input("Enter Class (integer):
"))
house = input("Enter House (string): ")

# Create a tuple with student data


student_data = (student_id, student_name,
student_class, house)

# Open the file in append binary mode and write the


data
with open(filename, 'ab') as file:
pickle.dump(student_data, file)

print("Student data appended successfully.")


(2 marks for correct otherwise 1 marks for partially correct code)

ii) def update_student_house(filename, old_house,


new_house):
# Read all records from the binary file
records = []
with open(filename, 'rb') as file:
while True:
try:
record = pickle.load(file)
records.append(record)
except EOFError:
break

# Update the house name in the records


for i in range(len(records)):
if records[i][3] == old_house:
records[i] = (records[i][0], records[i][1],
records[i][2], new_house)

# Write updated records back to the file


with open(filename, 'wb') as file:
for record in records:
pickle.dump(record, file)

print(f"Updated house from {old_house} to


{new_house} successfully.")
(2 marks for correct otherwise 1 marks for partially correct code)

SECTION E
36. a) YTOWN as this has maximum number of computers. 5
b) Fiber optic cable as distance is in kms.
c) Swtich
d) VoIP
e) Firewall at YTOWN
(1 mark of each correct answer)
37. 1. Connecting to MySQL Database: 5

import mysql.connector

def connect_to_database():
try:
connection = mysql.connector.connect(
host='localhost',
user='admin',
password='admin123',
database='STOREDB'
)
return connection
except mysql.connector.Error as err:
print(f"Error: {err}")
return None

2. Creating the Table:

def create_table(connection):
cursor = connection.cursor()
cursor.execute("""
CREATE TABLE IF NOT EXISTS INVENTORY (
ProductID INT AUTO_INCREMENT PRIMARY KEY,
ProductName VARCHAR(100),
Price FLOAT(8,2),
PurchaseDate DATE
)
""")
connection.commit()

3. Inserting Data:

def insert_data(connection):
cursor = connection.cursor()
prooducts = [
('PRODUCT-1', 2500.30, '2022/02/12'),
('PRODUCT-2', 78000.00, '2023/12/02'),
('PRODUCT-3', 350.56, '2020/03/25')
]
cursor.executemany("INSERT INTO INVENTORY (ProductName,
Price, PurchaseDate) VALUES (%s, %s, %s)", products)
connection.commit()

4. Retrieving and Displaying Records:

def display_records(connection):
cursor = connection.cursor()
cursor.execute("SELECT * FROM INVENTORY")
results = cursor.fetchall()
for row in results:
print(f"ID: {row[0]}, Product: {row[1]}, Price:
{row[2]}, Purchased On: {row[3]}")

Execution:

def main():
connection = connect_to_database()
if connection:
create_table(connection)
insert_data(connection)
display_records(connection)
connection.close()

if __name__ == "__main__":
main()

(1 mark for each correct code)


END
KENDRIYA VIDYALAYA SANGATHAN:: REGIONAL OFFICE, BHOPAL
SESSION ENDING EXAMINATION: 2024-2025
CLASS-XII
Roll No.

COMPUTER SCIENCE (083)


Time allowed: 3 hours Maximum Marks: 70
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 the case of MCQ, the text of the correct answer should also be written.

SECTION-A
1. TRUE 1
2. a) True, False 1
3. a) True 1
4. a) 19 1
5. a) Welc. me t.rld 1
6. b) del D1["Red"] 1
7. c) r+ 1
8. a) ALTER 1
9. c) Statement 4 1
10. b) Day.pop(2) 1
11. b) length() 1
12. d) Remainder 1
13. b) len() 1
14. c) Foreign Key 1
15. a) Tuple 1
16. b) 6,20 1
17. d) Circuit Switching
18. a) SMTP, POP
19. a) 192.168.2.2

Page 1 of 8
20. (A) Both (A) and (R) are true and (R) is the correct explanation for (A).
21. (A) Both (A) and (R) are true and (R) is the correct explanation for (A).
SECTION-B
22. 1 Mark for correct difference 2
1/2 Mark for any one correct mutable object
[1,2]
{1:1,2:2}
1/2 Mark for any one correct Immutable object
(1,2)
‘123’
23. (i) L1.insert(2,200) 1 Mark for correct statement 2
(ii) message.endswith('.') 1 Mark for Correct statement
OR
import statistics 1 Mark for Correct import
print( statistics.mode(studentAge) ) 1 mark for correct statement
24. b) W#s# 2
25. This will produce an error 2
26. (i) Membership operator (IN) : 1 Mark for Correct operator and definition 2
(ii) Identity operator (IS) : 1 Mark for Correct operator and definition
27. A) 1 Mark for Correct advantage 2
1 Mark for Correct disadvantage.
OR
B) 1 Mark for Correct expansion- Hypertext Transfer Protocol
1 Mark for Correct difference:
HTTPS uses TLS (SSL) to encrypt normal HTTP requests and responses and to digitally
sign those requests and responses.
28. 2
A) 1 Mark for correct difference and 1 Mark for correct example.
OR
2
B) 1 Mark for correct explanation and 1 Mark for correct example
SECTION-C
29. 1 Marks for correct file opening and closing statement. 3
2 Marks for correct definition of function
OR
1 Marks for correct file opening and closing statement.
2 Marks for correct definition of function

Page 2 of 8
30. 3

OR
(B)
def push_even_numbers(N):
EvenNumbers = []
for num in N:
if num % 2 == 0:
EvenNumbers.append(num)
Return EvenNumbers
VALUES = []
for i in range(5):
VALUES.append(int(input("Enter an integer: ")))
EvenNumbers = push_even_numbers(VALUES)
def pop_even():
if not EvenNumbers:
print("Underflow")
else:
Page 3 of 8
print(EvenNumbers.pop())
pop_even()
def Disp_even():
if not EvenNumbers:
print("None")
else: print(EvenNumbers[-1])
Disp_even()
(1/2 for identifying even numbers)
(1/2 mark for correctly adding data to stack)
(1/2 mark for correctly poping data on the stack and 1/2 mark for checking condition)
(1/2 mark for correctly displaying the data with none)
(1/2 mark for function call statements)
31. Predict the output of the following code: 3
15@
15@
7@
15@
7@
9@
OR
Predict the output of the following code:
1 #2 #3 #
1 #2 #3 #
1#
SECTION-D
32. A) Write the following queries: 4
(i) select Product, sum(Quantity) from orders group by product having
sum(quantity)>=5;
(ii) select * from orders order by Price desc;
(iii) select distinct C_Name from orders;
(iv) select sum(price) as total_price from orders where Quantity IS NULL;
OR
C) Write the output:
(i) Select c_name, sum(quantity) as total_quantity from orders group by c_name;

(ii) Select * from orders where product like '%phone%';

Page 4 of 8
(iii) Select o_id, c_name, product, quantity, price from orders where the price between
1500 and 12000;

D) Select max(price) from orders;

33. Write the following Python functions to perform the specified operations on this file: 4
(i) Read all the data from the file in the form of a list and display records of all the
players, whose country is ‘India’. (2 Marks)
def show():
import csv
f=open("players.csv",'r')
records=csv.reader(f)
next(records, None) #To skip the Header row
for i in records:
if (i[3]=='India'):
print(i)
f.close()
(ii) Count the number of records in the file. (2 Marks)
def Count_records():
import csv
f=open("players.csv",'r')
records=csv.reader(f)
next(records, None) #To skip the Header row
count=0
for i in records:
count+=1
print(count)
f.close()
34. (i) To display those company names which have price less than 35000. 4
Page 5 of 8
SELECT C.NAME FROM COMPANY C, CUSTOMER CR WHERE C.CID=CR.CID AND
CR.PRICE < 35000;
(ii) To display the names of the companies in reverse alphabetical order.
SELECT NAME FROM COMPANY ORDER BY NAME DESC;
(iii) To increase the price by 1000 for those customers whose name starts with ‘S’
UPDATE CUSTOMER SET PRICE = PRICE + 1000 WHERE NAME LIKE ‘S%’;
(A) To add one more column totalprice with decimal(10,2) to the table customer.
ALTER TABLE CUSTOMER ADD TOTALPRICE DECIMAL(10,2);
OR
(B) To display the Cartesian Product of these two tables.
SELECT * FROM company CROSS JOIN customer;
(B) Cartesian Product: 9,24
35. 1 Mark for correct import SQL module and connection establishment- connect () 4
import mysql.connector as sqlcon
mycon=sqlcon.connect(host="localhost",user="root",passwd="tiger",database="exams")

a) RecordAttendance() function.1 ½ Marks (no mark deduction for exception handling)


def RecordAttendance():
rollno=input("Enter Roll Number:=")
sname=input("Enter Student Name=")
cname=input("Class=")
adate=input ("Date(in yyyy-mm-dd Format):")
att=input('Attendace:(P or A')
record=(rollno, sname,cname,adate,att)
if mycon.is_connected():
cursor=mycon.cursor()
sqlcmd="""insert into attendance values(%s,%s,%s,%s,%s)"""
cursor.execute(sqlcmd,record)
mycon.commit()
print("Record added Successfully.!!")
cursor.close()
mycon.close()
else:
print("Unable to setup Connection to Database Successful:")

b) DisplayAttendance() Function 1 ½ Marks (no mark deduction for exception handling)


def DisplayAttendance():
adate=input ("Date(in yyyy-mm-dd Format):")
data=(adate)
if mycon.is_connected():
cursor=mycon.cursor()
sqlcmd="""select * from attendance where attendDate = %s"""
cursor.execute(sqlcmd,data)
resultset=cursor.fetchone()

Page 6 of 8
for row in resultset:
print(row)
cursor.close()
mycon.close()
else:
print("Unable to Fetch Attendance!")

36. (i) 2 Mark for correct definition of emp_data( ) function. 5


import pickle
def emp_data():
emp = []
n = int(input("Enter the number of emploeyees You want to add: "))
for i in range(n):
emp_code= int(input("Enter Employee Code: "))
emp_name = input("Enter Employee Name: ")
salary = float(input("Enter Salary: "))
deductions = float(input("Enter Deduction Amount: "))
emp.append([emp_code,emp_name,salary,deductions])
return emp
emp_list = emp_data()
def append_emp(employees):
with open('employees.bin', 'ab') as file:
for empl in employees:
pickle.dump(empl, file)
print("Candidate data appended successfully.")
(ii) 2 Mark for correct definition of cal_salary() function.
import pickle
def cal_salary():
empl=[]
updated_salary = []
with open('employees.bin', 'rb') as file:
while True:
empl = pickle.load(file)
if empl[3] > 0:
empl[2] =empl[2]-empl[3]
updated_salary.append(empl)

with open('employees.bin', 'wb') as file:


for emp in updated_salary:
pickle.dump(emp, file)
print("Salary updated.")
(iii) 1 Mark for correct definition of function
import pickle
def display_record():
Page 7 of 8
with open('employees.bin', 'rb') as file:
while True:
emp = pickle.load(file)
if emp[3] >5000: # Check if not Senior Manager
print(f"Employee Code: {emp[0]}")
print(f"Employee Name: {emp[1]}")
print(f"Salary: {emp[2]}")
print(f"Deductions: {emp[3]}")
print("--------------------")
display_record()
37. (i) ADMIN Block as it has the most number of computers installed. 5
(ii) Switch
(iii) Network Layout
Management Law

Medicine

Admin

(iv) Ethernet Cable


(v) A) Repeater may be required between Management Block and Law Block as distance
is more than 100 metres.
OR
B) LAN

Page 8 of 8
Kendriya Vidyalaya Sangathan, Jaipur Region
PRACTICE PAPER-III
Class: XII Subject: Computer Science (083)
Maximum Marks: 70 Period: 3 Hours
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 the case of MCQ, the text of the correct answer should also be written.

Q. Section-A (21 x 1 = 21 Marks) Mark


1 State True or False: 1
Exception is a compile time error.
2 Identify the output of the following code snippet 1
text = “Comma(,) is a punctuator”
text = text.split(‘,’)
print(text)
a) [ ‘Comma(,)’, ‘is’, ‘a’, ‘punctuator’ ] b) [ ‘Comma(’, ‘) is a punctuator’ ]
c) [ ‘Comma(‘, ‘,’, ‘) is a punctuator’ ] d) Error
3 Which of the following expressions evaluates to True 1
a) False or not False and False b) False and not False or False
c) True or not True and False d) True and not True or not True
4 What is the output of the following code snippet? 1
‘CS’.join(‘IP’)
a) 'ICSP' b) 'CIPS' c) 'IPCIPSIP' d) 'CSICSPCS'
5 What will be the output of the following code? 1
msg = ‘Transcendental’
print(msg[ 10 : -10 : -2 ])
a) 'nde' b) 'ndesaTltenc' c) '' d) error
6 Which statement(s) will result in error? 1
t1=(11,22,33)
t2=(44,) #statement1
t2+=t1 #statement2
t4=t1*2+t2*2 #statement3
t4[0]=45 #statement4
a) statement 4 b) statement 2&4 c) statement 3&4 d) All
7 Which statement will result in error 1
item={‘Cake’:20, ‘Pastry’:30, ‘Burger’:15}
a) item[‘Patties’]=30 b) item.update((‘Patties’,30))
c) item.update({‘Patties’:30}) d) item.setdefault(‘Patties’,30)
8 What does list.pop(x) method do in Python? 1
a) removes and return element x
b) removes first occurrence of element x
c) removes and return element at index x
d) only returns element at index x but does not remove it
9 If a table has 5 Candidate keys then it will have___ Primary keys and ___Alternate 1
keys
a) 1,5 b) 1,1 c) 1,4 d) 4,1
10 Write the missing statement to complete the following code: 1
file = open(‘story.txt’, ‘r+’)
data = file.read(5)
________# Move the file pointer to the end of the file
file.write(‘End’)
file.close()
11 State whether the following statement is True or False: 1
There can be more than one except blocks.
12 What will be the output of the following code? 1
a=5
def fn( ):
global a
a=5
print(a, end = “ ”)
fn()
print(a)
a) 5 error b) 5 5 c) error d) None of the above
13 Which SQL command can be used to set a default value to a column in table? 1
14 What will be the output of the query? 1
SELECT * FROM employees WHERE employee_name LIKE ‘%aa%’ ;
a) Details of all employees with two a’s only in the start of the name.
b) Details of all employees with two a’s only at the end of the name.
c) Details of all employees with two a’s anywhere in the name.
d) Details of all employees with two a’s together only in the name.
15 Literals of which SQL data type are enclosed in quotes? 1
a) Char & Varchar b) Float c) Date d) (a) & (c)
16 What will be the output of following query for the given table named Sports: 1
SELECT AVG(Price) FROM Sports;
Item Price
Football 1000
Volleyball 900
BasketBall 950
Tennis Ball NULL
a) 950 b) 712.5 c) NULL d) Error
17 Which protocol allows users to download emails from a server to a client? 1
a) SMTP b) POP3 c) TELNET d) PPP
18 Which Network device is used to convert Digital signals to Analog signals at 1
sender’s end and convert Analog signals to Digital signals at receiver’s end.
a) Repeater b) Gateway c) Router d) Modem
19 Which switching technique ensures a continuous, reliable connection for the 1
duration of the communication session, uses all the bandwidth of the
transmission channel and doesn’t share it unless the duration of communication
session is over.
Q20 and Q21 are Assertion(A) and Reason(R) 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
20 Assertion (A) : The order of Actual Arguments must conform with order of Formal 1
Parameters in case of Positional Arguments
Reasoning (R): Default Parameters should be written in rightmost side of function
declaration and no non-Default parameter should follow it.
21 Assertion (A) :In SELECT command of SQL order of WHERE and HAVING 1
clause is interchangeable.
Reasoning (R):WHERE clauseworks before aggregation of data and HAVING
clause works after aggregation of data.

Q Section-B ( 7 x 2=14 Marks) Mark


22 Which of the following statement will result in error and why? 2
s = “God is almighty”
s1 = s[0] + s[1]
s[0] = ‘g’
23 Write following type of operators as per the order of Precedence Table for Python. 2
(i) Arithmetic operators (ii) Logical operators
24 If A = [10,20,40,10,30,20] and B = [1,7,3,4,8,6,5,9] then answer the following 2
using built-in methods/functions only
(i)
(A) Write a statement to count the occurrences of 10 in A.
OR
(B) Write a statement to arrange the elements of A in ascending order.
(ii)
(A) Write a statement to add all the elements of B at the end of A.
OR
(B) Write a statement to reverse the elements of B.
25 Identify the correct output(s) of the following code. Also write the minimum and the 2
maximum possible values of the variable r.
import random
l=[10,20,30,40,50,60,70]
p=random.randint(3,5)
q=random.randint(5,6)
r=p-2
s=q+1
for i in range(r,s):
print(l[i],end="#")
a) 30#40#50#60#70# b) 20#30#40#50#
c) 30#40#50# d) 40#50#60#
26 The code provided below is intended to shift the elements to the left by n times of 2
a tuple t. However, there are syntax and logical errors in the code. Rewrite it after
removing all errors. Underline all the corrections made.
deflshift(t,n):
n=n%len(t)
t=t[n:]+t[:n+1]
return t

newt=lshift((1,2,3,4,5,6),13)
print(newt)
Sample example :
lshift((6,7,8,9),2) should give the output (8,9,6,7)
27 (i) 2
(A) What constraint should be applied on a column of a table so that there cannot
be NULL value except for only one row
OR
(B) What constraint should be applied on a column of a table so that a predefined
value is assigned if no value is provided by the user.
(ii)
(A) Write an SQL command to remove the Primary Key constraint from a table,
named STUDENT. Adm_No is the primary key of the table.
OR
(B) Write an SQL command to make the column Rno the Primary Key of an
already existing table named STUDENT.
28 A) List one advantage and one disadvantage of Tree topology. 2
OR
B) Expand the term TELNET. What is the use of TELNET?

Q Section-C ( 3 x 3 = 9 Marks) Mark


29 (A) Write a Python functiongovWeb() that displays all the words containing 3
gov.in from a text file “URLs.txt”
OR
(B) Write a Python function atleast5() that finds and displays all the words
having at least 5 characters from a text file “Story.txt”.
30 (A) You have a stack named StarStudents that contains records of students. 3
Each student record is represented as a dictionary {‘name’: ____, ‘marks’:
____}Write the following user-defined functions in Python to perform the specified
operations on the stack StarStudents:
(i) push_star(StarStudent, AllStudents): This function takes two arguments
the stack StarStudent and a list of dictionaries named AllStudents
containing details of all students in the format [{‘name’: “Ajay”, ‘marks’:
95},{‘name’: “Shambhu”, ‘marks’: 100},…..]and pushes records of only those
students who has scored more than 90.
(ii) pop_star(StarStudent): This function takes the stack StarStudent as
argument and pops the topmost student record from the stack and returns
it. If the stack is already empty, the function should display “Underflow”.
(iii) peek_star(StarStudent): This function takes the stack StarStudent as
argument and displays the topmost element of the stack without deleting it.
If the stack is empty, the function should display “None”.
OR
(B) Write the definition for the following user defined functions
(i) push_positive(N): This function takes a list of integers as parameter ‘N’ and
pushes all positive integers into a Stack named ‘pos_int’ defined in global
scope.
(ii) pop_positive(): This function pops the topmost number from the stack
‘pos_int’ defined in global scope and returns it. If the stack is already empty,
the function should display “Empty”.
(iii) disp_positive(): This function displays all the elements of the stack
‘pos_int’ defined in global scope without deleting them. If the stack is empty,
the function should display “None”.
For example:
If the integers in the list N are:
[ -3, 7, -5, 9, 0 ]
Then the stack pos_int should store:
[7, 9, 0]
and disp_positive() should display:
7 9 0 None
31 Predict the output of the following code: 3
d = { ‘Shoes’ : 10, ‘Gloves’ : 20, ‘Jackets’ : 15 }
s = “”
for k in d:
s = s + k + str(d[k]) + “#” + “\n”
sn = s[:-1]
print(sn)
OR
Predict the output of the following code:
squares=[1,4,9,16,25,36]
for i in squares:
for j in range(i%7,0,-1):
print(j,'#',end=' ')
print()

Q Section-D ( 4 x 4 = 16 Marks) Mark


32 Consider the table EVENTS as given below 4
E_Id E_name Manager Price Capacity
1001 Birthday Prateek 3000 30
1002 Anniversary Manoj 15000 50
1003 Reception Shivansh 25000 NULL
1004 Birthday Prem 3500 35
A) Write the following queries:
i) To display the total Price for each event, excluding events with total Price less
than 100000
ii) To display the EVENTS table sorted by Capacity in descending order.
iii) To display the distinct event names from the EVENTS table.
iv) Display the sum of Price of all the events for which the capacity is not
known.
OR
B) Write the output
i) Select E_name, sum(price) as total_price from events group by e_name;
ii) Select Manager from events where manager like ‘%a%’;
iii)Select e_id, Price from events where price between 1500 and 12000 ;
iv)Select max(price) from events;

33 A csv file “Employment.csv” contains the data of a survey. Each record of the file 4
contains the following data:
• Name of a state
• Population of the state
• Sample size (Number of persons who participated in the survey in that
state)
• Employed (Number of persons employed)

For example, a sample record of the file may be:


[ ‘Rajasthan’, 5674933, 10000, 5679]

Write the following Python functions to perform the specified operations on this file:
(i) Read all the data from the file in the form of a list and display all those records
for which the population is more than 5000000.
(ii) Count the number of records in the file.
34 Manan has been entrusted with the management of ABC School database. He 4
needs to access some information from STUDENT and CLUB tables for a survey
analysis. Help him extract the following information by writing the desired SQL
queries as mentioned below:
Table :STUDENT
Rno Name DateOfBirth Gender Marks ClubId
1 Amit 15-11-2008 M 98 101
2 Divya 27-10-2008 F 78 102
3 Harsh 13-05-2009 M 90 101
4 Manjeet 16-07-2009 M 86 103
5 Aruna 07-08-2009 F 70 102
6 Dinesh 01-03-2009 M 67 103
Table :CLUB
ClubId Cname Fees
101 Eco 300
102 Cyber 500
103 Excursion 700

(i) To display complete details (from both the tables) of those whose marks is
less than 80
(ii) To display the details of those clubs, fees of which is in the range of 400 to
700 (both values included).
(iii) To increase the fees of all clubs by 200 which have ‘o’ in their club name.
(iv) (a) To display Name and Marks of student in Cyber club.
OR
(b) To display the Cartesian Product of these two tables without repeating
ClubId column.
35 A table, named INVENTORY, in SHOP database, has the following structure: 4
Field Type
itemNo int
itemName varchar(15)
price float
qty int
Write the following Python function to perform the specified operation:

addRec(): To input details of an item and store it in the table INVENTORY. The
function should then retrieve and display all records from the INVENTORY table
where the price is greater than 150.

Assume the following for Python-Database connectivity:


Host: localhost, User: root, Password: Chetan

Q Section-E ( 2 x 5 = 10 Marks) Mark


36 Gyandev is manager in an educational institute. He needs to manage the records 5
of various candidates. For this, he wants the following information of each
candidate to be stored in a list:
- Candidate_id – integer
- Cadidate_name – string
- Class – string
- Status – string
You, as a programmer of the institute, have been assigned to do this job for
Gyandev.
(i) Write a function addBin() to input the data of a candidate, create a list of it and
append it in a binary file named “Students.dat”.
(ii) Write a function promoteBin() to change the status to “passed out” for those
students whose class is “XII”
(iii) Write a function activeBin() to read the data from the binary file and display
the data of all those candidates who are not “passed out”.
37 Advent Infotech is planning to set up it India campus in Jaipur with its head 5
office in Delhi. The Jaipur campus will have four blocks/buildings – ADMIN,
FINANCE, SALES and HR. You, as a network expert, need to suggest the best
network-related solutions for them to resolve the issues/problems mention in
points (i) to (v), keepin in mid the distances between various block/buildings and
other given parameters.
Delhi Jaipur
Campus
Head FINANCE
Office
ADMIN SALES

HR

Block to Block distances (in Mtrs)


From To Dista Block No of
nce computers
ADMIN FINANCE 35m ADMIN 120
ADMIN SALES 110m FINANCE 10
ADMIN HR 50m SALES 50
FINANCE SALES 65m HR 30
FINANCE HR 85m
SALES HR 70m
Delhi Jaipur 310
Head Campus Km
Office
a) Draw the cable layout to efficiently connect various blocks of buildings within
the Jaipur campus. Which cable would you suggest for the most efficient data
transfer over the network?
b) Suggest the most appropriate location of the server inside the Jaipur campus.
Justify your choice.
c) Suggest the placement of following devices:
i) Switch/hub
ii) Repeater
d) Which cost efficient wired medium should be used to connect the computers
in Jaipur campus?
e) a )Which type of network is formed by connecting Delhi Head Office with
Jaipur Campus?
OR
b) What would be your recommendation for enabling live visual
communication between the Admin Office at the Jaipur Campurs and
Delhi Head Office from the following options:
(i) Video Conferencing (ii) Email (iii) Telephony (iv) Instant Messaging
Kendriya Vidyalaya Sangathan, Jaipur Region
Practice paper-3
Class: XII Subject: Computer Science (083)
Maximum Marks: 70 Period: 3 Hours

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 the case of MCQ, the text of the correct answer should also be written.

Q. Section-A (21 x 1 = 21 Marks) Mark


1 False 1
2 b) [ ‘Comma(’, ‘) is a punctuator’ ] 1
3 c) True or not True and False 1
4 a) 'ICSP' 1
5 a) 'nde' 1
6 a) statement 4 1
7 b) item.update((‘Patties’,30)) 1
8 c) removes and return element at index x 1
9 c) 1,4 1
10 file.seek(0,2) 1
11 True 1
12 b) 5 5 1
13 Alter command 1
14 d) Details of all employees with two a’s together only in the name. 1
15 d) (a) & (c) 1
16 a) 950 1
17 b) POP3 1
18 d) Modem 1
19 Circuit Switching 1
Q20 and Q21 are Assertion(A) and Reason(R) 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
20 (B) Both A and R are true and R is not the correct explanation for A 1
21 (D) A is False but R is True 1

Q Section-B ( 7 x 2=14 Marks) Mark


22 s[0] = ‘g’ will result in error because string is immutable data type and does not 2
support item assignment.
23 Type Operator 2
**
Arithmetic
/ // % *
+-
not
Logical and
or
24 (i) 2
(A) A.count(10)
OR
(B) A.sort()
(ii)
(A) A.extend(B)
OR
(B) B.sort(reverse=True)
(1 mark each)
25 Minimum value of r – 1 2
Maximum value of r – 3
a) 30#40#50#60#70#
d) 40#50#60#
(1/2 mark each for min and max value & ½ mark each for correct output)
26 def lshift(t,n): 2
n=n%len(t)
t=t[n:]+t[:n] # n in place of n+1
return t # return indentation is removed

newt=lshift((1,2,3,4,5,6),13)
print(newt)
(1 mark for each correction)
27 (i) 2
(A) Unique
OR
(B) Default
(ii)
(A) ALTER TABLE STUDENT DROP PRIMARY KEY;
OR
(B) ALTER TABLE STUDENT ADD PRIMARY KEY(RNO);
(1 mark each)
28 Advantage: 2
Hierarchical connection between the nodes.
Disadvantage:
Less reliable than star and mesh.
(1 mark each)
OR
TELNET : Teletype Network Telnet is a network protocol used to virtually access a
computer and provide a two-way, collaborative and text-based communication
channel between two machines. It follows a user command TCP/IP networking
protocol that creates remote sessions.
(1 mark for expansion and 1 mark for use)

Q Section-C ( 3 x 3 = 9 Marks) Mark


29 (A) 3
def govWeb():
f=open("URLs.txt", 'r')
data=f.read()
low=data.split()
for w in low:
if 'gov.in' in w:
print(w)
f.close()
(1/2 mark for correct function definition)
(1/2 mark for opening file)
(1/2 mark for reading data)
(1/2 mark for correct iteration)
(1/2 mark for correct if )
(1/2 mark for correct print)
OR
(B)
def atleast5():
f=open("Story.txt", 'r')
data=f.read()
low=data.split()
for w in low:
if len(w)>=5:
print(w)
f.close()
(1/2 mark for correct function definition)
(1/2 mark for opening file)
(1/2 mark for reading data)
(1/2 mark for correct iteration)
(1/2 mark for correct if )
(1/2 mark for correct print)
30 (A) 3
def push_star(StarStudent, AllStudents):
for i in AllStudents:
if i['marks']>90:
StarStudent.append(i)

def pop_star(StarStudent):
if StarStudent:
return StarStudent.pop()
else:
print("Underflow")

def peek_star(StarStudent):
if StarStudent:
return StarStudent[-1]
else:
print("None")
(1 mark for each correct function definition)
OR
(B)
pos_int=[ ]
def push_positive(N):
for i in N:
if i>0:
pos_int.append(i)

def pop_positive():
if pos_int:
return pos_int.pop()
else:
print("Empty")

def disp_positive():
for i in range(-len(pos_int),0,-1):
print(pos_int[i], end=“ ”)
else:
print("None")
(1 mark for each correct function definition)
31 Shoes10# 3
Gloves20#
Jackets15#
(1 mark for each correct output)
OR
1#
4# 3# 2# 1#
2# 1#
2# 1#
4# 3# 2# 1#
1#
(1/2 mark for each correct output)

Q Section-D ( 4 x 4 = 16 Marks) Mark


32 (A) 4
(i) SELECT SUM(PRICE) FROM EVENTS GROUP BY E_NAME HAVING
SUM(PRICE) < 100000;
(ii) SELECT * FROM EVENTS ORDER BY CAPACITY DESC;
(iii) SELECT DISTINCT(E_NAME) FROM EVENTS;
(iv) SELECT SUM(PRICE) FROM EVENTS WHERE CAPACITY IS NOT NULL
(1 mark for each correct query, ½ for partially correct)
OR
(B)
(i)
E_name sum(price)
Birthday 6500
Anniversary 15000
Reception 25000
(ii)
Manager
Prateek
Manoj
Shivansh
(iii)
e_id Price
1001 3000
1004 3500
(iv)
max(price)
25000
(1 mark for each correct output, ½ for partially correct)
33 CSV file based question 4
(i)
import csv
f=open("Employment.csv")
ro=csv.reader(f)
for rec in ro:
if rec[1]>5000000:
print(rec)
(1/2 mark for correct file opening)
(1/2 mark for reader object)
(1/2 mark for reading data)
(1/2 mark for correct if and print)
(ii)
import csv
f=open("Employment.csv")
ro=csv.reader(f)
l=list(ro)
print("no. of records = ", len(l))
(1/2 mark for correct file opening)
(1/2 mark for reader object)
(1/2 mark for reading data)
(1/2 mark for correct print)
34 (i) SELECT * FROM STUDENT, CLUB WHERE MARKS<80 AND 4
STUDENT.CLUBID = CLUB.CLUBID;
(ii) SELECT * FROM CLUB WHERE FEES BETWEEN 400 AND 700;
(iii) UPDATE CLUB SET FEES=FEES+200 WHERE CNAME LIKE ‘%O’;
(iv) SELECT NAME, MARKS FROM STUDENT, CLUB WHERE CNAME=’CYBER’
AND STUDENT.CLUBID = CLUB.CLUBID;
OR
SELECT * FROM STUDENT NATURAL JOIN CLUB;
(1 mark for correct query)
35 def addRec(): 4
import mysql.connector as m
con=m.connect(host='localhost', user='root', passwd='Chetan',
database='SHOP')
cur=con.cursor()
ino=int(input("Enter item no."))
iname=input("Enter item name")
p=float(input("Enter price"))
q=int(input("Enter quantity"))
cur.execute("insert into inventory values(%s,%s,%s,%s)", [ino,iname,p,q])
con.commit()
cur.execute("select * from inventory where price>150")
for rec in cur.fetchall():
print(rec)
(1/2 mark for correct connection)
(1/2 mark for cursor)
(1/2 mark for correct intput)
(1/2 mark for correct insert query execution)
(1/2 mark for commit)
(1/2 mark for correct select query execution)
(1/2 mark for correct fetch and iteration)
(1/2 mark for correct print)

Q Section-E ( 2 x 5 = 10 Marks) Mark


36 def addBin(): 5
import pickle
f=open('Students.dat', 'ab')
cid=int(input("Enter candidate id :"))
cname=input("Enter candidate name")
c=input("Enter class")
s=input("Enter status(active/passed out)")
pickle.dumpt([cid,cname,c,s],f)
f.close()
(1/2 mark for correct file open)
(1/2 mark for correct input)
(1/2 mark for correct dump)
def promoteBin():
import pickle
f=open('Students.dat', 'rb+')
try:
while True:
p=f.tell()
d=pickle.load(f)
if d[2]=='xii':
d[3]='passed out'
f.seek(p)
pickle.dump(d,f)
except:
f.close()
(1/2 mark for correct file open)
(1/2 mark for correct iteration and read)
(1/2 mark for correct if and modification)
(1/2 mark for correct seek and dump)
def activeBin():
import pickle
f=open('Students.dat', 'rb')
try:
while True:
d=pickle.load(f)
if d[3]!='passed out':
print(d)
except:
f.close()
(1/2 mark for correct file open)
(1/2 mark for correct iteration and read)
(1/2 mark for correct if and print)
37 (a) Star with ADMIN as center 5
(b) ADMIN block due to maximum number of computers in any block because
of which most of the traffic will be local.
(c) i) Switch/Hub: In every block which has more than 1 device to interconnect
them
ii) Repeater: Between ADMIN and SALES to regenerate the weak signal as
distance is over 80m
(d) Ethernet cable
(e) a) WAN
OR
b) (i) Video conferencing
(1 mark for each correct answer)
Kendriya Vidyalaya Sangathan, Jaipur Region
PRACTICE PAPER-4
Question Paper
Class: XII Subject: Computer Science (083)
Maximum Marks: 70 Period: 3 Hours
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 the case of MCQ, the text of the correct answer should also be written.

Q. Section-A (21 x 1 = 21 Marks) Mark


1 State True/False: The python expression 3.2+2 is evaluated as 3*2+2 1
2 Observe and find output of the following python code: 1
str1 = "Python"
str2 = "Programming"
print(str1[:2] + str2[-4:])
a. Pyming b. Pythming c. Pyogramming d. Pythonming
3 Evaluate the following expression and find correct value of y: 1
y = 3 * 4 + 2**3 // 2 - (7 % 3)
4 What will be the output of following python code: 1
s = 'Programming'
print(s.split("m"))
a. ['Progra', '', 'ing'] b. ['Progra', 'ing']
c. ['Progra', 'm', 'ing'] d. ['Progra', 'ming']
5 What will be the output of following python code: 1
s = “yoBananaBoy”
print(s[: :-1 ])
6 What will be the output of following python code: 1
t1 = 1,2,3
t2 = (1,2,3)
print(t1 is t2)
a. True b. 1 c. False d. 0
7 What would the following code print: 1
fruits = {'apple': 5, 'banana': 3, 'orange': 2, 'grape': 4}
print(fruits.get('mango'))
a. 0 b. None c. Error d. 5

Page 1 of 7
8 Consider the given list L: 1
L = list('All is well in ')
What python code should be written for inserting the word 'Havana' at the end of
the list as separate characters?
a. L.extend('Havana') b. L.append(list('Havana'))
c. both a and b d. None of the above
9 What will be the output of following python code: 1
l2= [1,2,3,'[4,5]']
print(type(l2[-1]))
a. error b. <class ‘list’> c. <class ‘string> d. <class ‘NoneType’>
10 Suppose the content of a text file xyz.txt is as follows: 1
"The best way to Predict the future is to create it."
What will be the output of the following python code?
f = open("xyz.txt")
f.seek(17)
s = f.read(7)
print(s)
f.close()
a. Predict b. The best way to
c. predict the d. to predict the future
11 In Python exception handling, the finally block is executed regardless of whether an 1
exception occurs or not. (True/False)
12 def func(a, b, c=3, d=4): 1
pass
Identify the keyword and positional arguments in the function given above:
a) a and b are positional arguments; c and d are keyword arguments
b) a, b, c, and d are all positional arguments
c) a, b, c, and d are all keyword arguments
d) a, b, and c are positional arguments; d is a keyword argument
13 What is the output of following SQL statement? 1
SELECT Department, COUNT(*) FROM employees
WHERE Salary > 50000 GROUP BY Department;
a. The total number of employees in each department
b. The departments with employees earning over 50,000 and the count of such
employees in each department
c. The departments with average salary over 50,000 and their total number of
employees
d. The number of departments with employees earning over 50,000
14 Consider a table named 'Products' with columns 'product_id', 'product_name', and 1
'category'. Which of the following SQL queries will retrieve all products that are not
in the categories 'Electronics' or 'Furniture'?
a. SELECT product_id, product_name FROM Products
WHERE category NOT IN ('Electronics', 'Furniture');
b. SELECT product_id, product_name FROM Products
WHERE category NOT IN 'Electronics', 'Furniture';
c. SELECT product_id, product_name FROM Products
WHERE category != 'Electronics' AND != 'Furniture';
d. SELECT product_id, product_name FROM Products
WHERE category NOT LIKE ('Electronics', 'Furniture');
15 In MySQL, which command does not change the cardinality of a relation? 1
a. ALTER b. INSERT c. DELETE d. None of these

Page 2 of 7
16 Sita is creating a table for her project. She wants that a particular column always 1
has a unique value. Which constraint should she use?
a. DISTINCT b. UNIQUE c. NOT NULL d. DEFAULT
17 Which of the following is a network protocol? 1
a. Firewall b. HTTP c. Modem d. Switch
18 The Router in a network primarily functions as a __________. 1
a. Converter b. Traffic director c. Amplifier d. Modulato
19 Write the full form of the following: (i) FTP (ii) DNS 1
Q20 and Q21 are Assertion(A) and Reason(R) 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
20 Assertion: Assertion: In Python, a function can return multiple values. 1
Reason: Python functions can return tuples, which can be unpacked into multiple
variables.
21 Assertion: The FOREIGN KEY constraint is used to establish links between tables. 1
Reason: A FOREIGN KEY in one table points to a FOREIGN KEY in another table.

Q Section-B ( 7 x 2=14 Marks) Mark


22 Mark the valid and invalid identifiers in Python from the below options: 2
myVariable, 1st_try, for, _total_sum
23 Rohan is writing a Python program to determine if a year is a leap year. He has 2
written a program, but it's not working correctly. Help him rewrite the code,
underlining the changes.
year = input("Enter a year: ")
if year % 100 == 0:
if year % 400 ==0:
print(year, "is a century and leap year")
else:
print(year,"is a century year but not leap year")
else if year%4==0:
print(year, "is a leap year")
else:
print(year, "is not a leap year")
24 (A) Write a Python program to find the largest and smallest numbers from a list. 2
Assume the list is given as [55, 12, 98, 34, 76, 1, 88].
OR
(B) Write a Python program to check if a string is a palindrome (reads the same
backward as forward). The string should be entered by the user.
25 Identify the correct output(s) of the following code from the choices i to iv. Write 2
incorrect choice. Also specify the maximum values that can be assigned to each
of the variables start and end.
import random
numbers = [10, 20, 30, 40, 50, 60]
start = random.randint(0, 2)
end = random.randint(3, 4)
for i in range(start, end):
print(numbers[i], end=", ")
(i) 10, 20, 30, (ii) 30, 40, (iii) 20, 30, 40, (iv) 40, 50,
Page 3 of 7
26 Define the following in context of MYSQL: (i) Tuple (ii) Cardinality 2
27 (A) Write difference between DISTINCT and GROUP BY clause of SQL. 2
OR
(B) What is the difference in INT and FLOAT?
28 Differentiate between Coaxial Cable and Optical Fiber. 2
OR
What is the use of the following devices?
(i) Modem (ii) Repeater

Q Section-C ( 3 x 3 = 9 Marks) Mark


29 (A) Write a Python function count_vowels() that reads text from a file named 3
"input.txt" and counts the number of vowels (a, e, i, o, u) in the file. The function
should return the vowel count.
OR
(B) Write a Python function longest_word() that reads text from a file "words.txt"
and returns the longest word in the file.
30 (A) A website uses a stack to manage recently viewed products. Each product is represented as 3
a tuple: (product_id, product_name, price). Write the following Python functions to manage
this RecentlyViewed stack:
(I) add_product(RecentlyViewed, new_product): This function adds a new product tuple to the
top of the RecentlyViewed stack.
(II) remove_product(RecentlyViewed): This function removes and returns the most recently
viewed product from the stack. If the stack is empty, it should print "No products recently
viewed."
(III) show_latest_product(RecentlyViewed): This function displays the most recently viewed
product without removing it. If the stack is empty, it should print "No products recently
viewed."
OR
(B)
A hospital is managing patient data using a stack-based system. Patient records
are initially stored in a list. Each record is a tuple containing (patient_id, age,
priority_level). Priority levels are integers, with higher numbers representing
higher priority.
(I) Create a list named patients containing the following patient records:
(101, 65, 2), (102, 32, 4), (103, 78, 1), (104, 45, 3), (105, 52, 5), (106, 28, 2)
(II) Write the definition of a user-defined function push_high_priority(patients,
priority_threshold). It should push only those patient records with a priority level
greater than or equal to the priority_threshold onto a stack called
high_priority_patients.
(III) Write a function get_high_priority() to display all elements of the
high_priority_patients stack while deleting them one by one. If the stack is empty,
the function should display No high-priority patients.

Page 4 of 7
Observe the table Students and write query for (i) to (iii): 3
31 Table: Faculty
F_ID FName LName Department Gender Hire_Date Salary
102 Ibomcha Thounaojam Exam M 10/02/2020 75000
103 Shantanu Fernandes Exam M 11/01/2015 120000
104 Tashi Dorjey ICT F 14/03/2023 50000
105 Bhanwar Singh ICT M 13/12/2019 80000
106 Kanta Kumari HOD F 11/01/2024 140000
(A)
(i) Display Gender wise number of faculties who earn more than 85000.
(ii) Display all data separated by Department and in decreasing order of Salary.
(iii) Display FName and F_ID of faculties from ICT department.
OR
(B)
(i) Display Gender wise average salary of those faculties with average salary
more than 90000.
(ii) Display FName and F_ID of faculties having the string ‘ta’ in the Fname.
(iii) Change data of table to award 5% annual increment in salary.

Q Section-D ( 4 x 4 = 16 Marks) Mark


32 (A) Explain the difference between the `'a'` and `'x'` file opening modes in Python. 4
(B) Observe the following code and predict the output of (i), (ii), and (iii):
def process_data(data):
try:
value = int(data)
if value > 100:
print("Value is greater than 100.")
else:
print("Value is not greater than 100.")
except ValueError:
print("Invalid input: Not an integer.")
finally:
print("Data processing complete.")
(i) process_data(150)
(ii) process_data("abc")
(iii) process_data(50)
33 A librarian is managing book inventory using a CSV file named `Inventory.csv`. 4
The file structure is: `[BookID, Title, Author, Available]` where `BookID` is an
integer, `Title` and `Author` are strings, and `Available` is an integer representing
the number of copies available.
The librarian needs to write the following functions:
- add_book(): This function accepts new book details from the user and adds
them to `Inventory.csv`. The file should be created with column headers if it
doesn't exist.
- check_availability(book_id): This function takes a `book_id` as input and
returns the number of copies available for that book. If the book is not
found, it should return -1.

Page 5 of 7
34 Give output of the following queries as per given table(s): 4
WORKER
WID WNAME JOB SALARY DNO
1001 RAHUL SHARMA CLERK 15000 D03
1002 MUKESH VYAS ELECTRICIAN 11000 D01
1003 SURESH FITTER 9000 D02
1004 ANKUR GUARD 8000 D01
DEPT
DNO DNAME LOC MANAGER
D01 PRODUCTION GROUND FLOOR D K JAIN
D02 ACCOUNTS 1ST FLOOR S ARORA
D03 SECURITY 1ST FLOOR R K SINGH
(i) SELECT DISTINCT JOB FROM WORKER;
(iii) SELECT DNAME, LOC FROM DEPT WHERE SALARY > 10000;
(iv) SELECT W.WNAME, D.MANAGER FROM WORKER AS W, DEPT AS D
WHERE W.DNO = D.DNO;
(v) SELECT WNAME FROM WORKER WHERE WNAME LIKE 'R%';
35 A table named Products in a database named Inventory stores information about 4
products. The table has the following columns: ProductID (integer, primary key),
ProductName (string), Price (float), and Quantity (integer). Assume the database
username is 'admin' and the password is 'secure123'.
Write a Python code that prompts the user to enter a ProductID and updates the
Quantity of that product by adding 10 to the existing quantity. Handle any potential
errors (e.g., the product ID not existing in the table).

Q Section-E ( 2 x 5 = 10 Marks) Mark


36 Simran is developing a Python program to manage customer orders for an online 5
store. Order data (order_id, customer_name, order_date, total_amount) is stored
in a binary file named "Orders.dat". Each order is represented as a tuple. Help
Simran complete the following tasks:
(i) Write a function `add_order()` to input order details from the user (order_id,
customer_name, order_date, total_amount) and store them in "Orders.dat". The
program should allow adding multiple orders until the user chooses to stop.
(ii) Write a function `update_order_amount()` to modify the `total_amount` for
orders placed. The function should increase the `total_amount` of each qualifying
order by 10%.
(iii) Write a function `count_high_value_orders()` to count and display the number
of orders with a `total_amount` greater than 1000.

Page 6 of 7
37 Kendriya Vidyalaya No 1 Jaipur is setting up the network between its Different Wings 5
of school campus. There are 4 wings named as – SENIOR(S), JUNIOR(J), ADMIN(A)
and HOSTEL(H).
Distance between various wings are given below:
Wing A to Wing S 80m
Wing A to Wing J 200m
Wing A to Wing H 400m
Wing S to Wing J 70m
Wing S to Wing H 120m
Wing J to Wing H 450m

Number of Computers installed at various wings are as follows:


Wing No. of Computers
Wing A 20
Wing S 150
Wing J 50
Wing H 25
(i) Suggest a most suitable cable layout for the above connections.
(ii) Suggest the most appropriate topology of the connection between the wings.
(iii) The company wants internet accessibility in all the wings. What type of
network (LAN/MAN/WAN) will be created if we connect all buildings?
(iv) Suggest the placement of the following devices with justification:
(A) Repeater
(B) Firewall
(v) (A) Which building will host the server of the company
OR
(B) Suggest a device to be used for accessing the internet.

Page 7 of 7
Kendriya Vidyalaya Sangathan, Jaipur Region
PRACTICE PAPER -4 (MARKING SCHEME)
Class: XII Subject: Computer Science (083)
Maximum Marks: 70 Period: 3 Hours
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 the case of MCQ, the text of the correct answer should also be written.

Q. Section-A (21 x 1 = 21 Marks) Mark


1 State True/False: The python expression 3.2+2 is evaluated as 3*2+2 (False) 1
2 Observe and find output of the following python code: 1
str1 = "Python"
str2 = "Programming"
print(str1[:2] + str2[-4:])
a. Pyming b. Pythming c. Pyogramming d. Pythonming
3 Evaluate the following expression and find correct value of y: 1
y = 3 * 4 + 2**3 // 2 - (7 % 3)
Ans. 15
4 What will be the output of following python code: 1
s = 'Programming'
print(s.split("m"))
a. ['Progra', '', 'ing'] b. ['Progra', 'ing']
c. ['Progra', 'm', 'ing'] d. ['Progra', 'ming']
5 What will be the output of following python code: 1
s = “yoBananaBoy”
print(s[: :-1 ])
Ans. yoBananaBoy
6 What will be the output of following python code: 1
t1 = 1,2,3
t2 = (1,2,3)
print(t1 is t2)
a. True b. 1 c. False d. 0
7 What would the following code print: 1
fruits = {'apple': 5, 'banana': 3, 'orange': 2, 'grape': 4}
print(fruits.get('mango'))
a. 0 b. None c. Error d. 5
8 Consider the given list L: 1
L = list('All is well in ')
What python code should be written for inserting the word 'Havana' at the end of
the list as separate characters?
a. L.extend('Havana') b. L.append(list('Havana'))
c. both a and b d. None of the above
9 What will be the output of following python code: 1
l2= [1,2,3,'[4,5]']
print(type(l2[-1]))
a. error b. <class ‘list’> c. <class ‘string> d. <class ‘NoneType’>
10 Suppose the content of a text file xyz.txt is as follows: 1
"The best way to predict the future is to create it."
What will be the output of the following python code?
f = open("xyz.txt")
f.seek(18)
s = f.read(7)
print(s)
f.close()
a. Predict b. The best way to
c. predict the d. to predict the future
11 In Python exception handling, the finally block is executed regardless of whether an 1
exception occurs or not. (True/False)
12 def func(a, b, c=3, d=4): 1
pass
Identify the keyword and positional arguments in the function given above:
a) a and b are positional arguments; c and d are keyword arguments
b) a, b, c, and d are all positional arguments
c) a, b, c, and d are all keyword arguments
d) a, b, and c are positional arguments; d is a keyword argument
13 What is the output of following SQL statement? 1
SELECT Department, COUNT(*) FROM employees
WHERE Salary > 50000 GROUP BY Department;
a. The total number of employees in each department
b. The departments with employees earning over 50,000 and the count of
such employees in each department
c. The departments with average salary over 50,000 and their total number of
employees
d. The number of departments with employees earning over 50,000
14 Consider a table named 'Products' with columns 'product_id', 'product_name', and 1
'category'. Which of the following SQL queries will retrieve all products that are not
in the categories 'Electronics' or 'Furniture'?
a. SELECT product_id, product_name FROM Products
WHERE category NOT IN ('Electronics', 'Furniture');
b. SELECT product_id, product_name FROM Products
WHERE category NOT IN 'Electronics', 'Furniture';
c. SELECT product_id, product_name FROM Products
WHERE category != 'Electronics' AND != 'Furniture';
d. SELECT product_id, product_name FROM Products
WHERE category NOT LIKE ('Electronics', 'Furniture');
15 In MySQL, which command does not change the cardinality of a relation? 1
a. ALTER b. INSERT c. DELETE d. None of these
16 Sita is creating a table for her project. She wants that a particular column always 1
has a unique value. Which constraint should she use?
a. DISTINCT b. UNIQUE c. NOT NULL d. DEFAULT
17 Which of the following is a network protocol? 1
a. Firewall b. HTTP c. Modem d. Switch
18 The Router in a network primarily functions as a __________. 1
a. Converter b. Traffic director c. Amplifier d. Modulato
19 Write the full form of the following: 1
(i) FTP: File Transfer Protocol
(ii) DNS: Domain Name Server
Q20 and Q21 are Assertion(A) and Reason(R) 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
20 Assertion: Assertion: In Python, a function can return multiple values. 1
Reason: Python functions can return tuples, which can be unpacked into multiple
variables.
Ans. (A) Both A and R are true and R is the correct explanation for A
21 Assertion: The FOREIGN KEY constraint is used to establish links between tables. 1
Reason: A FOREIGN KEY in one table points to a FOREIGN KEY in another table.

Ans. (C) A is True but R is False

Q Section-B ( 7 x 2=14 Marks) Mark


22 Mark the valid and invalid identifiers in Python from the below options: 2
myVariable : Valid
1st_try: Invalid
For: Invalid
_total_sum: Valid
23 Rohan is writing a Python program to determine if a year is a leap year. He has 2
written a program, but it's not working correctly. Help him rewrite the code,
underlining the changes.
year = input("Enter a year: ") #Input need to be converted into integer
if year % 100 == 0:
if year % 400 ==0:
print(year, "is a century and leap year")
else:
print(year,"is a century year but not leap year")
else if year%4==0: #elif instead of else if
print(year, "is a leap year")
else:
print(year, "is not a leap year")
Correct Code:
year = int(input("Enter a year: ")) #used int() funtion
if year % 100 == 0:
if year % 400 ==0:
print(year, "is a century and leap year")
else:
print(year,"is a century year but not leap year")
elif year%4==0: #elif instead of else if
print(year, "is a leap year")
else:
print(year, "is not a leap year")
24 (A) Write a Python program to find the largest and smallest numbers from a list. 2
Assume the list is given as [55, 12, 98, 34, 76, 1, 88].
Ans.
numbers = [55, 12, 98, 34, 76, 1, 88]
largest_number = max(numbers)
smallest_number = min(numbers)
print("Largest number:", largest_number)
print("Smallest number:", smallest_number)

OR
(B) Write a Python program to check if a string is a palindrome (reads the same
backward as forward). The string should be entered by the user.
Ans.
def is_palindrome(text):
processed_text = text[::-1]
return processed_text

user_input = input("Enter a string: ")


if is_palindrome(user_input):
print(f"'{user_input}' is a palindrome.")
else:
print(f"'{user_input}' is not a palindrome.")
25 Identify the correct output(s) of the following code from the choices i to iv. Write all 2
incorrect choices. Also specify the maximum values that can be assigned to each
of the variables start and end.
import random
numbers = [10, 20, 30, 40, 50, 60]
start = random.randint(0, 2)
end = random.randint(3, 4)
for i in range(start, end):
print(numbers[i], end=", ")
(i) 10, 20, 30, (ii) 30, 40, (iii) 20, 30, 40, (iv) 40, 50,
The maximum value for start is 2, and the maximum value for end is 4.
26 Define the following in context of MYSQL: 2
(i) Tuple: A single row in a MySQL table.
(ii) Cardinality: The number of rows (tuples) in a table.
27 (A) Write difference between DISTINCT and GROUP BY clause of SQL. 2
DISTINCT removes duplicate rows from the result set;
GROUP BY groups rows with the same values in specified columns for aggregate
functions.
OR
(B) What is the difference in INT and FLOAT?
INT stores integers;
FLOAT stores floating-point numbers (numbers with decimal places).
28 Differentiate between Coaxial Cable and Optical Fiber. 2
Coaxial cable uses electrical signals transmitted through a copper core;
Optical fiber uses light signals transmitted through a glass or plastic core,
offering higher bandwidth and less signal degradation.
OR
What is the use of the following devices? (i) Modem (ii) Repeater
(i) A modem modulates and demodulates signals to allow communication
between digital devices and analog lines (like telephone lines).
(ii) A repeater amplifies and retransmits signals to extend the range of a network.

Q Section-C ( 3 x 3 = 9 Marks) Mark


29 (A) Write a Python function count_vowels() that reads text from a file named 3
"input.txt" and counts the number of vowels (a, e, i, o, u) in the file. The function
should return the vowel count.
def count_vowels(filepath):
try:
with open(filepath, 'r') as f:
text = f.read().lower() # Read and convert to lowercase
for i in text:
if i in "aeiou":
vowel_count +=1
return vowel_count
except FileNotFoundError:
return -1
OR
(B) Write a Python function longest_word() that reads text from a file "words.txt"
and returns the longest word in the file.
def longest_word(filepath):
l=[]
try:
with open(filepath, 'r') as f:
words = f.read().split()
if not words: #Handle empty file
return None
else:
for i in words:
l.append(len(i))
val=max(l)
pos=l.find(val)
return words[pos]
except FileNotFoundError:
return None
30 (A) A website uses a stack to manage recently viewed products. Each product is represented as 3
a tuple: (product_id, product_name, price). Write the following Python functions to manage
this RecentlyViewed stack:
(I) add_product(RecentlyViewed, new_product): This function adds a new product tuple to the
top of the RecentlyViewed stack.
(II) remove_product(RecentlyViewed): This function removes and returns the most recently
viewed product from the stack. If the stack is empty, it should print "No products recently
viewed."
(III) show_latest_product(RecentlyViewed): This function displays the most recently viewed
product without removing it. If the stack is empty, it should print "No products recently
viewed."

Ans.
def add_product(RecentlyViewed, new_product):
RecentlyViewed.append(new_product)

def remove_product(RecentlyViewed):
if RecentlyViewed:
return RecentlyViewed.pop()
else:
print("No products recently viewed.")

def show_latest_product(RecentlyViewed):
if RecentlyViewed:
print(RecentlyViewed[-1])
else:
print("No products recently viewed.")
OR
(B)
A hospital is managing patient data using a stack-based system. Patient records
are initially stored in a list. Each record is a tuple containing (patient_id, age,
priority_level). Priority levels are integers, with higher numbers representing
higher priority.
(I) Create a list named patients containing the following patient records:
(101, 65, 2), (102, 32, 4), (103, 78, 1), (104, 45, 3), (105, 52, 5), (106, 28, 2)
(II) Write the definition of a user-defined function push_high_priority(patients,
priority_threshold). It should push only those patient records with a priority level
greater than or equal to the priority_threshold onto a stack called
high_priority_patients.
(III) Write a function get_high_priority() to display all elements of the
high_priority_patients stack while deleting them one by one. If the stack is empty,
the function should display No high-priority patients.

Ans.
# (I) Create the list of patient records
patients = [(101, 65, 2), (102, 32, 4), (103, 78, 1), (104, 45, 3),
(105, 52, 5), (106, 28, 2)]

# Initialize the high_priority_patients stack


high_priority_patients = []

# (II) Function to push high priority patients to stack


def push_high_priority(patients, priority_threshold):
for patient in patients:
if patient[2] >= priority_threshold:
high_priority_patients.append(patient)

# (III) Function to get and display high priority patients


Observe the table Students and write query for (i) to (iii): 3
31 Table: Faculty
F_ID FName LName Department Gender Hire_Date Salary
102 Ibomcha Thounaojam Exam M 10/02/2020 75000
103 Shantanu Fernandes Exam M 11/01/2015 120000
104 Tashi Dorjey ICT F 14/03/2023 50000
105 Bhanwar Singh ICT M 13/12/2019 80000
106 Kanta Kumari HOD F 11/01/2024 140000
(A)
(i) Display Gender wise number of faculties who earn more than 85000:
SELECT Gender, COUNT(*) as Count FROM Faculty
WHERE Salary > 85000 GROUP BY Gender;

(ii) Display all data separated by Department and in decreasing order of Salary:
SELECT * FROM Faculty ORDER BY Department, Salary DESC;

(iii) Display FName and F_ID of faculties from ICT department:


SELECT FName, F_ID FROM Faculty WHERE Department = 'ICT';

OR
(B)
(i) Display Gender wise average salary of those faculties with average salary more
than 90000:
SELECT Gender, AVG(Salary) as AvgSalary FROM Faculty
GROUP BY Gender HAVING AVG(Salary) > 90000;

(ii) Display FName and F_ID of faculties having the string 'ta' in the Fname:
SELECT FName, F_ID FROM Faculty WHERE FName LIKE '%ta%';

(iii) Change data of table to award 5% annual increment in salary:


UPDATE Faculty SET Salary = Salary * 1.05;

Q Section-D ( 4 x 4 = 16 Marks) Mark


32 (A) Explain the difference between the 'a' and 'x' file opening modes in Python. 4
- 'a' (append) mode: Opens the file for appending. If the file exists, it
appends new data to the end. If the file doesn't exist, it creates a new file.
- 'x' (exclusive creation) mode: Opens the file for exclusive creation. If the
file already exists, it raises a FileExistsError. If the file doesn't exist, it
creates a new file.
(B) Observe the following code and predict the output of (i), (ii), and (iii):
def process_data(data):
try:
value = int(data)
if value > 100:
print("Value is greater than 100.")
else:
print("Value is not greater than 100.")
except ValueError:
print("Invalid input: Not an integer.")
finally:
print("Data processing complete.")
(B) Predicted outputs:
(i) process_data(150)
Output:
Value is greater than 100.
Data processing complete.

(ii) process_data("abc")
Output:
Invalid input: Not an integer.
Data processing complete.

(iii) process_data(50)
Output:
Value is not greater than 100.
Data processing complete.
33 A librarian is managing book inventory using a CSV file named `Inventory.csv`. 4
The file structure is: `[BookID, Title, Author, Available]` where `BookID` is an
integer, `Title` and `Author` are strings, and `Available` is an integer representing
the number of copies available.
The librarian needs to write the following functions:
- add_book(): This function accepts new book details from the user and adds
them to `Inventory.csv`. The file should be created with column headers if it
doesn't exist.
- check_availability(book_id): This function takes a `book_id` as input and
returns the number of copies available for that book. If the book is not
found, it should return -1.
Ans.
import csv
import os

def add_book():
file_exists = os.path.isfile('Inventory.csv')
with open('Inventory.csv', 'a', newline='') as file:
writer = csv.writer(file)
if not file_exists:
writer.writerow(['BookID', 'Title', 'Author', 'Available'])
book_id = input("Enter BookID: ")
title = input("Enter Title: ")
author = input("Enter Author: ")
available = input("Enter number of copies available: ")
writer.writerow([book_id, title, author, available])
print("Book added successfully!")

def check_availability(book_id):
try:
with open('Inventory.csv', 'r') as file:
reader = csv.DictReader(file)
for row in reader:
if row['BookID'] == str(book_id):
return int(row['Available'])
except FileNotFoundError:
print("Inventory file not found.")
return -1
34 Give output of the following queries as per given table(s): 4
WORKER
WID WNAME JOB SALARY DNO
1001 RAHUL SHARMA CLERK 15000 D03
1002 MUKESH VYAS ELECTRICIAN 11000 D01
1003 SURESH FITTER 9000 D02
1004 ANKUR GUARD 8000 D01
DEPT
DNO DNAME LOC MANAGER
D01 PRODUCTION GROUND FLOOR
D K JAIN
D02 ACCOUNTS 1ST FLOOR
S ARORA
D03 SECURITY 1ST FLOOR
R K SINGH
Ans.
(i) SELECT DISTINCT JOB FROM WORKER;
JOB
----
CLERK
ELECTRICIAN
FITTER
GUARD
(ii) SELECT DNAME, LOC FROM DEPT WHERE DNO IN (SELECT DNO FROM
WORKER WHERE SALARY > 10000);
DNAME LOC
----------- ------------
PRODUCTION GROUND FLOOR
SECURITY 1ST FLOOR
(iii) SELECT W.WNAME, D.MANAGER
FROM WORKER AS W, DEPT AS D
WHERE W.DNO = D.DNO;
WNAME MANAGER
------------- ---------
RAHUL SHARMA R K SINGH
MUKESH VYAS D K JAIN
SURESH S ARORA
ANKUR D K JAIN
(iv) SELECT WNAME FROM WORKER WHERE WNAME LIKE 'R%';
WNAME
-------------
RAHUL SHARMA
35 A table named Products in a database named Inventory stores information about 4
products. The table has the following columns: ProductID (integer, primary key),
ProductName (string), Price (float), and Quantity (integer). Assume the database
username is 'admin' and the password is 'secure123'.
Write a Python code that prompts the user to enter a ProductID and updates the
Quantity of that product by adding 10 to the existing quantity. Handle any potential
errors (e.g., the product ID not existing in the table).
Ans.
import mysql.connector
from mysql.connector import Error

def update_product_quantity(product_id):
try:
connection = mysql.connector.connect(
host="localhost",
database="Inventory",
user="admin",
password="secure123" )

if connection.is_connected():
cursor = connection.cursor()
cursor.execute("SELECT Quantity FROM Products
WHERE ProductID = %s", (product_id,))
result = cursor.fetchone()
if result:
current_quantity = result[0]
new_quantity = current_quantity + 10
update_query = "UPDATE Products SET Quantity = %s
WHERE ProductID = %s"
cursor.execute(update_query, (new_quantity, product_id))
connection.commit()
print(f"updated successfully. New quantity: {new_quantity}")
else:
print("Product not found.")

except Error as e:
print(f"Error: {e}")

finally:
if connection.is_connected():
cursor.close()
connection.close()

Q Section-E ( 2 x 5 = 10 Marks) Mark


36 Simran is developing a Python program to manage customer orders for an online 5
store. Order data (order_id, customer_name, order_date, total_amount) is stored
in a binary file named "Orders.dat". Each order is represented as a tuple. Help
Simran complete the following tasks:

Ans.
import pickle

(i) Write a function `add_order()` to input order details from the user (order_id,
customer_name, order_date, total_amount) and store them in "Orders.dat". The
program should allow adding multiple orders until the user chooses to stop.
def add_order():
orders = []
try:
with open("Orders.dat", "rb") as file:
orders = pickle.load(file)
except FileNotFoundError:
pass

while True:
order_id = input("Enter order ID: ")
customer_name = input("Enter customer name: ")
order_date = input("Enter order date (YYYY-MM-DD): ")
total_amount = float(input("Enter total amount: "))

order = (order_id, customer_name, order_date, total_amount)


orders.append(order)

if input("Add another order? (y/n): ").lower() != 'y':


break

with open("Orders.dat", "wb") as file:


pickle.dump(orders, file)

(ii) Write a function `update_order_amount()` to modify the `total_amount` for


orders placed. The function should increase the `total_amount` of each qualifying
order by 10%.
def update_order_amount():
try:
with open("Orders.dat", "rb") as file:
orders = pickle.load(file)
updated_orders = []
for order in orders:
new_amount = order[3] * 1.10
updated_order = (order[0], order[1], order[2], new_amount)
updated_orders.append(updated_order)

with open("Orders.dat", "wb") as file:


pickle.dump(updated_orders, file)

print("Orders updated successfully.")


except FileNotFoundError:
print("Orders file not found.")

(iii) Write a function `count_high_value_orders()` to count and display the number


of orders with a `total_amount` greater than 1000.
def count_high_value_orders():
try:
37 Kendriya Vidyalaya No 1 Jaipur is setting up the network between its Different Wings 5
of school campus. There are 4 wings named as – SENIOR(S), JUNIOR(J), ADMIN(A)
and HOSTEL(H).
Distance between various wings are given below:
Wing A to Wing S 80m
Wing A to Wing J 200m
Wing A to Wing H 400m
Wing S to Wing J 70m
Wing S to Wing H 120m
Wing J to Wing H 450m

Number of Computers installed at various wings are as follows:


Wing No. of Computers
Wing A 20
Wing S 150
Wing J 50
Wing H 25
(i) Suggest a most suitable cable layout for the above connections.
A
|
| (80m)
|
J--------S----------R----------H
(70m) (120m)
* R is the repeater
(ii) Suggest the most appropriate topology of the connection between the wings:
Star Topology
(iii) The company wants internet accessibility in all the wings. What type of
network (LAN/MAN/WAN) will be created if we connect all buildings? : LAN
(iv) Suggest the placement of the following devices with justification:
(A) Repeater: Between S and H (the distance is more than 100)
(B) Firewall: in Wing S as it is also suitable for installing a server
(v) (A) Which building will host the server of the company: Wing S
OR
(B) Suggest a device to be used for accessing the internet. Modem
केन्द्रीय विद्यालय संगठन , कोलकाता संभाग
KENDRIYA VIDYALAYA SANGATHAN , KOLKATA REGION
प्री-बोर्ड परीक्षा / PRE BOARD EXAMINATION 2024-25
कक्षा / Class - XII अविकतम अं क / Maximum Marks : 70
विषय / Subject - Computer Science समय / 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.

Q No. Section-A (21 x 1 = 21 Marks) Marks

1. State True or False:


(1)
The Python statement print(‘Alpha’+1) is example of TypeError Error

2. What id the output of following code snippet?

country = "GlobalNetwork" (1)


result = "-".join(country.split("o")).upper()
print(result)
(A) GL-BALNETW-RK
(B) GL-BA-LNET-W-RK
(C) GL-BA-LNET-W-RK
(D) GL-BA-LNETWORK

3. Identify the output of the following code snippet:

text = "The_quick_brown_fox"
index = text.find("quick")
(1)
result = text[:index].replace("_", "") + text[index:].upper()
print(result)

(A) Thequick_brown_fox
(B) TheQUICK_BROWN_FOX

Page: 1/11
(C) TheQUICKBROWNFOX
(D) TheQUICKBROWN_FOX
What will be the output of the following Python expression?
4.
x=5
y = 10
(1)
result = (x ** 2 + y) // x * y - x
print(result)

(A) 0
(B) -5
(C) 65
(D) 265
What will be the output of the following code snippet?
5.
(1)
text = "Python Programming"
print(text[1 : :3])

(A) Ph oai
(B) yoPgmn
(C) yhnPormig
(D) Pto rgamn
6. What will be the output of the following code?
tuple1 = (1, 2, 3)
tuple2 = tuple1 + (4,)
tuple1 += (5,)
print(tuple1, tuple2) (1)

(A) (1, 2, 3) (1, 2, 3, 4)


(B) (1, 2, 3, 5) (1, 2, 3)
(C) (1, 2, 3, 5) (1, 2, 3, 4)
(D) Error
7. Dictionary my_dict as defined below, identify type of error raised by statement
my_dict['grape']?
my_dict = {'apple': 10, 'banana': 20, 'orange': 30}
(A) ValueError (1)
(B) TypeError
(C) KeyError
(D) ValueError
What does the list.pop(x) method do in Python?
8.
A. Removes the first element from the list.
(1)
B. Removes the element at index x from the list and returns it.
C. Adds a new element at index x in the list.
D. Replaces the element at index x with None.

Page: 2/11
In a relational database table with one primary key and three unique constraints
9.
defined on different columns (not primary), how many candidate keys can be
derived from this configuration?
(1)
(A) 1
(B) 3
(C) 4
(D) 2
10. Fill in the blanks to complete the following code snippet choosing the correct
option:

with open("sample.txt", "w+") as file:


(1)
file.write("Hello, World!") # Write a string to the file
position_after_write = file.______ # Get the position after writing
file.seek(0) # Move the pointer to the beginning
content = file.read(5) # Read the first 5 characters
print(content)

(A) tell
(B) seek
(C) read
(D) write
11. State whether the following statement is True or False:
In Python, if an exception is raised inside a try block and not handled, the
program will terminate without executing any remaining code in the finally (1)
block.

12. What will be the output of the following code?


x=4
def reset():
global x
x=2
print(x, end='&')
def update(): (1)
x += 3
print(x, end='@')

update()
x=6
reset()
print(x, end='$')

(A) 7@2&6$
(B) 7@6&6$
(C) 7@2&2$
(D) Error

Page: 3/11
Which SQL command can modify the structure of an existing table, such as adding or
13. (1)
removing columns?

(A) ALTER TABLE


(B) UPDATE TABLE
(C) MODIFY TABLE
(D) CHANGE TABLE
14. What will be the output of the query?
SELECT * FROM orders WHERE order_date LIKE '2024-10-%';
(A) Details of all orders placed in October 2024
(B) Details of all orders placed on October 10th, 2024 (1)
(C) Details of all orders placed in the year 2024
(D) Details of all orders placed on any day in 2024
Which of the following statements about the CHAR and VARCHAR datatypes in SQL
15.
is false?
(A) CHAR is a fixed-length datatype, and it pads extra spaces to match the specified
length. (1)
(B) VARCHAR is a variable-length datatype and does not pad extra spaces.
(C) The maximum length of a VARCHAR column is always less than that of a CHAR
column.
(D) CHAR is generally used for storing data of a known, fixed length.
16. Which of the following aggregate functions can be employed to determine the
number of unique entries in a specific column, effectively ignoring duplicates?
(A) SUM() (1)
(B) COUNT()
(C) AVG()
(D) COUNT(DISTINCT column_name)
17. Which protocol is used to send e-mail over internet?
(A) FTP
(B) TCP
(C) SMTP
(D) SNMP
(1)
18. Which device is primarily used to amplify and regenerate signals in a network,
allowing data to travel longer distances?
(A) Switch
(B) Router (1)
(C) Repeater
(D) Bridge

19. Which communication technique establishes a dedicated communication path


between two devices for the entire duration of a transmission, ensuring a (1)
continuous and consistent connection?

Page: 4/11
Q20 and Q21 are Assertion(A) and Reason(R) 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): Python functions can accept positional, keyword, and default
20.
parameters.

Reasoning (R): Default parameters allow function arguments to be assigned a (1)


default value if no argument is provided during the function call.
Assertion (A): A GROUP BY clause in SQL can be used without any aggregate
21.
functions.
Reasoning (R): The GROUP BY clause is used to group rows that have the same (1)
values in specified columns and must always be paired with
aggregate functions.
Q No Section-B ( 7 x 2=14 Marks) Marks
Consider the following Python code snippet:
22.
a = [1, 2, 3]
b=a (2)
a.append(4)
c = (5, 6, 7)
d = c + (8,)
a. Explain the mutability of a and c in the context of this code.
b. What will be the values of b and d after the code is executed?
Give examples for each of the following types of operators in Python:
23.
(I) Assignment Operators (2)
(II) Identity Operators
If L1 = [10, 20, 30, 40, 20, 10, ...] and L2 = [5, 15, 25, ...], then:
24.
(Answer using builtin functions only)

(I) A) Write a statement to count the occurrences of 20 in L1. (2)


OR
B) Write a statement to find the minimum value in L1.

(II) A) Write a statement to extend L1 with all elements from L2.


OR
B) Write a statement to get a new list that contains the unique elements
from L1.

Page: 5/11
25. Identify the correct output(s) of the following code. Also write the minimum and
the maximum possible values of the variable b.
import random
text = "Adventure"
b = random.randint(1, 5)
for i in range(0, b):
print(text[i], end='*') (2)

(A) A* (B) A*D*

(C) A*d*v* (D) A*d*v*e*n*t*u*

26. The code provided below is intended to reverse the order of elements in a given
list. However, there are syntax and logical errors in the code. Rewrite it after
removing all errors. Underline all the corrections made.

def reverse_list(lst)
if not lst:
return lst (2)
reversed_lst = lst[::-1]
return reversed_lst
print("Reversed list: " reverse_list[1,2,3,4] )

27. (I)
A) What constraint should be applied to a table column to ensure that all values in
that column must be unique and not NULL?
OR
B) What constraint should be applied to a table column to ensure that it can have
multiple NULL values but cannot have any duplicate non-NULL values? (2)
(II)
A) Write an SQL command to drop the unique constraint named unique_email
from a column named email in a table called Users.
OR
B) Write an SQL command to add a unique constraint to the email column of an
existing table named Users, ensuring that all email addresses are unique.

28. A) Explain one advantage and one disadvantage of mesh topology in computer
networks.
OR (2)
B) Expand the term DNS. What role does DNS play in the functioning of the
Internet?

Page: 6/11
Q No. Section-C ( 3 x 3 = 9 Marks) Marks

29. A) Write a Python function that extracts and displays all the words present in a
text file “Vocab.txt” that begins with a vowel.
OR (3)
B) Write a Python function that extracts and displays all the words containing a
hyphen ("-") from a text file "HyphenatedWords.txt", which has a three letter
word before hypen and four letter word after hypen. For example : “for-
them” is such a word.
(A) You have a stack named MovieStack that contains records of movies. Each
30.
movie record is represented as a list containing movie_title, director_name, and
release_year. Write the following user-defined functions in Python to perform the
specified operations on the stack MovieStack:

(I) push_movie(MovieStack, new_movie): This function takes the stack MovieStack


and a new movie record new_movie as arguments and pushes the new movie
record onto the stack.

(II) pop_movie(MovieStack): This function pops the topmost movie record from the
stack and returns it. If the stack is empty, the function should display "Stack is
empty".

(III) peek_movie(MovieStack): This function displays the topmost movie record (3)
from the stack without deleting it. If the stack is empty, the function should display
"None".

OR

(B) Write the definition of a user-defined function push_odd(M) which accepts a list
of integers in a parameter M and pushes all those integers which are odd from the
list M into a Stack named OddNumbers.

Write the function pop_odd() to pop the topmost number from the stack and
return it. If the stack is empty, the function should display "Stack is empty".

Write the function disp_odd() to display all elements of the stack without deleting
them. If the stack is empty, the function should display "None".

For example:

If the integers input into the list NUMBERS are: [7, 12, 9, 4, 15]

Then the stack OddNumbers should store: [7, 9, 15]

Page: 7/11
31. Predict the output of the following code:
data = [3, 5, 7, 2]
result = ""
for num in data:
for i in range(num):
result += str(i) + "*"
result = result[:-1]
print(result)
OR

Predict the output of the following code: (3)


numbers = [10, 15, 20]
for num in numbers:
for j in range(num // 5):
print(j, "+", end="")
print()

Q No. Section-D ( 4 x 4 = 16 Marks) Marks

32. Consider the table ORDERS as given below

O_Id C_Name Product Quantity Price


1001 Jitendra Laptop 1 12000
1002 Mustafa Smartphone 2 10000
1003 Dhwani Headphone 1 1500
1004 Alice Smartphone 1 9000
1005 David Tablet NULL 7000

Note: The table contains many more records than shown here.
(4)
A) Write the following queries:
(I) To display the total Quantity for each Product, excluding Products with total
Quantity less than 5.
(II) To display the ORDERS table sorted by total price in descending order.
(III) To display the distinct customer names from the ORDERS table.
(IV) To display the sum of the Price of all the orders for which the quantity is
NULL.
OR
B) Write the output:
(I) SELECT C_Name, SUM(Quantity) AS Total_Quantity FROM ORDERS GROUP BY
C_Name;
(II) SELECT * FROM ORDERS WHERE Product LIKE '%phone%';
(III) SELECT O_Id, C_Name, Product, Quantity, Price FROM ORDERS WHERE Price
BETWEEN 1500 AND 12000;
(IV) SELECT MAX(Price) FROM ORDERS;

Page: 8/11
A CSV file "HealthData.csv" contains the data of a health survey. Each record of the
33.
file contains the following data:

 Name of a country
 Life Expectancy (average number of years a person is expected to live)
 GDP per capita (Gross Domestic Product per person)
 Percentage of population with access to healthcare

For example, a sample record of the file may be: ['Wonderland', 82.5, 40000, 95].
(4)
Write the following Python functions to perform the specified operations on this
file:

(I) Read all the data from the file in the form of a list and display all those records
for which the life expectancy is greater than 75.

(II) Count the number of records in the file.

Alex has been tasked with managing the Student Database for a High School. He
34.
needs to access some information from the STUDENTS and SUBJECTS tables for a
performance evaluation. Help him extract the following information by writing the
desired SQL queries as mentioned below.
Table: STUDENTS
S_I FNa LNam Enrollment_Dat Mar
D me e e ks
201 John Doe 15-09-2020 85
202 Jane Smith 10-05-2019 90
203 Alex Johns 22-11-2021 75
(4)
on
204 Emily Davis 30-01-2022 60
205 Mich Brown 17-08-2018 95
ael

Table: SUBJECTS

Sub_ID S_ID SubName Credits


301 201 Mathematics 3
302 202 Science 4
303 203 History 2
304 204 Literature 3
305 205 Physics 4
306 201 Computer 3
Science
Write the following SQL queries:
(I) To display complete details (from both the tables) of those students whose
marks are greater than 70.
(II) To display the details of subjects whose credits are in the range of 2 to 4 (both
values included).
(III) To increase the credits of all subjects by 1 which have "Science" in their subject
names.
(IV) (A) To display names (FName and LName) of students enrolled in the
Page: 9/11
"Mathematics" subject.
(OR)
(B) To display the Cartesian Product of these two tables.

A table, named ELECTRONICS, in the PRODUCTDB database, has the following


35.
structure:

Field Type
productID int(11)
productName varchar(20)
price float
stockQty int(11)

Write the following Python function to perform the specified operation: (4)

AddAndDisplay(): To input details of a product and store it in the table


ELECTRONICS. The function should then retrieve and display all records from the
ELECTRONICS table where the price is greater than 150.
Assume the following for Python-Database connectivity:
Host: localhost
User: root
Password: Electro123

Q.No. SECTION E (2 X 5 = 10 Marks) Marks


Raj is a supervisor at a software development company. He needs to manage the
36.
records of various employees. For this, he wants the following information of each
employee to be stored:
Employee_ID – integer
Employee_Name – string
Position – string
Salary – float (5)
You, as a programmer of the company, have been assigned to do this job for Raj.
(I) Write a function to input the data of an employee and append it to a binary file.
(II) Write a function to update the data of employees whose salary is greater than
50000 and change their position to "Team Lead".
(III) Write a function to read the data from the binary file and display the data of all
those employees who are not "Team Lead".
Interstellar Logistics Ltd. is an international shipping company. They are planning to
37
establish a new logistics hub in Chennai, with the head office in Bangalore. The
Chennai hub will have four buildings - OPERATIONS, WAREHOUSE,
CUSTOMER_SUPPORT, and MAINTENANCE. As a network specialist, your task is to
propose the best networking solutions to address the challenges mentioned in
points (I) to (V), considering the distances between the various buildings and the
given requirements.

Building-to-Building Distances (in meters):

Page: 10/11
From To Distance
OPERATIONS WAREHOUSE 40 m
OPERATIONS CUSTOMER_SUPPORT 90 m
OPERATIONS MAINTENANCE 50 m
WAREHOUSE CUSTOMER_SUPPORT 60 m
WAREHOUSE MAINTENANCE 45 m
CUSTOMER_SUPPORT MAINTENANCE 55 m

Distance of Bangalore Head Office from Chennai Hub: 1300 km

Number of Computers in Each Building/Office:

Location Computers
OPERATIONS 40
WAREHOUSE 20
CUSTOMER_SUPPORT 25
MAINTENANCE 22
BANGALORE HEAD OFFICE 15
(I) Suggest the most suitable location for the server within the Chennai hub. Justify
your decision.
(II) Recommend the hardware device to connect all computers within each building (5)
efficiently.
(III) Draw a cable layout to interconnect the buildings at the Chennai hub efficiently.
Which type of cable would you recommend for the fastest and most reliable data
transfer?
(IV) Is there a need for a repeater in the proposed cable layout? Justify your
answer.
(V) A) Recommend the best option for live video communication between the
Operations Office in the Chennai hub and the Bangalore Head Office from the
following choices:
• a) Video Conferencing
• b) Email
• c) Telephony
• d) Instant Messaging
OR
(V) B) What type of network (PAN, LAN, MAN, or WAN) would be set up among the
computers within the Chennai hub?

Page: 11/11
MARKING SCHEME OF 1st PREBOARD ( KVS RO KOLKATA )
2024-25 ( COMPUTER SCIENCE)
Time allowed: 3 Hours Maximum Marks: 70

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 ( No marks should be
provided if student does not write the correct choice )

Q No. Section-A (21 x 1 = 21 Marks) Marks

1. State True or False:


(1)
The Python statement print(‘Alpha’+1) is example of TypeError Error

Ans : True
2. What id the output of following code snippet?

country = "GlobalNetwork" (1)


result = "-".join(country.split("o")).upper()
print(result)
(A) GL-BALNETW-RK
(B) GL-BA-LNET-W-RK
(C) GL-BA-LNET-W-RK
(D) GL-BA-LNETWORK

Ans : A ) GL-BALNETW-RK
3. Identify the output of the following code snippet:

text = "The_quick_brown_fox"
index = text.find("quick")
(1)
result = text[:index].replace("_", "") + text[index:].upper()
print(result)

(A) Thequick_brown_fox
(B) TheQUICK_BROWN_FOX
(C) TheQUICKBROWNFOX
(D) TheQUICKBROWN_FOX

Page: 1/21
Ans : (B) TheQUICK_BROWN_FOX

What will be the output of the following Python expression?


4.
x=5
y = 10
(1)
result = (x ** 2 + y) // x * y - x
print(result)

(A) 0
(B) -5
(C) 65
(D) 265

Ans : ( C ) 65
What will be the output of the following code snippet?
5.
(1)
text = "Python Programming"
print(text[1 : :3])

(A) Ph oai
(B) yoPgmn
(C) yhnPormig
(D) Pto rgamn
Ans : (B)

6. What will be the output of the following code?


tuple1 = (1, 2, 3)
tuple2 = tuple1 + (4,)
tuple1 += (5,)
print(tuple1, tuple2) (1)

(A) (1, 2, 3) (1, 2, 3, 4)


(B) (1, 2, 3, 5) (1, 2, 3)
(C) (1, 2, 3, 5) (1, 2, 3, 4)
(D) Error

Ans : C )
7. Dictionary my_dict as defined below, identify type of error raised by statement
my_dict['grape']?
my_dict = {'apple': 10, 'banana': 20, 'orange': 30}
ValueError (1)
(B) TypeError
(C) KeyError
(D) ValueError
Ans : (C) KeyError

Page: 2/21
What does the list.pop(x) method do in Python?
8.

A. Removes the first element from the list. (1)


B. Removes the element at index x from the list and returns it.
C. Adds a new element at index x in the list.
D. Replaces the element at index x with None.

Ans : B. Removes the element at index x from the list and returns it.

In a relational database table with one primary key and three unique
9. constraints defined on different columns (not primary), how many candidate
keys can be derived from this configuration?
(1)
(A) 1
(B) 3
(C) 4
(D) 2

Ans : C) 4
10. Fill in the blanks to complete the following code snippet choosing the
correct option:

with open("sample.txt", "w+") as file:


(1)
file.write("Hello, World!") # Write a string to the file
position_after_write = file.______ # Get the position after writing
file.seek(0) # Move the pointer to the beginning
content = file.read(5) # Read the first 5 characters
print(content)

(A) tell
(B) seek
(C) read
(D) write

Ans : (A) tell

11. State whether the following statement is True or False:


In Python, if an exception is raised inside a try block and not handled,
the program will terminate without executing any remaining code in the (1)
finally block.

Ans : False

Page: 3/21
12. What will be the output of the following code?
x=4
def reset():
global x
x=2
print(x, end='&')
def update(): (1)
x += 3
print(x, end='@')

update()
x=6
reset()
print(x, end='$')

(A) 7@2&6$
(B) 7@6&6$
(C) 7@2&2$
(D) Error
Ans : (D) Error : Unbound local variable x in function update()
Which SQL command can modify the structure of an existing table, such as
13. adding or removing columns? (1)

(A) ALTER TABLE


(B) UPDATE TABLE
(C) MODIFY TABLE
(D) CHANGE TABLE

Ans. (A) ALTER TABLE


14. What will be the output of the query?
SELECT * FROM orders WHERE order_date LIKE '2024-
10-%';
(A) Details of all orders placed in October 2024 (1)
(B) Details of all orders placed on October 10th, 2024
(C) Details of all orders placed in the year 2024
(D) Details of all orders placed on any day in 2024

Ans : (A) Details of all orders placed in October 2024


Which of the following statements about the CHAR and VARCHAR
15.
datatypes in SQL is false?
(A) CHAR is a fixed-length datatype, and it pads extra spaces to match the
specified length. (1)
(B) VARCHAR is a variable-length datatype and does not pad extra spaces.
(C) The maximum length of a VARCHAR column is always less than that of
a CHAR column.
(D) CHAR is generally used for storing data of a known, fixed length.
Ans : ( C )

Page: 4/21
16. Which of the following aggregate functions can be employed to determine
the number of unique entries in a specific column, effectively ignoring
duplicates?
(1)
(A) SUM()
(B) COUNT()
(C) AVG()
(D) COUNT(DISTINCT column_name)
Ans : (D) COUNT(DISTINCT column_name)

17. Which protocol is used to send e-mail over internet?


(A) FTP
(B) TCP
(C) SMTP
(D) SNMP (1)
Ans. (C) SMTP
18. Which device is primarily used to amplify and regenerate signals in a
network, allowing data to travel longer distances?
(A) Switch
(B) Router (1)
(C) Repeater
(D) Bridge
Ans : ( C) Repeater
19. Which communication technique establishes a dedicated communication
path between two devices for the entire duration of a transmission, (1)
ensuring a continuous and consistent connection?

Ans : Circuit Switching


Q20 and Q21 are Assertion(A) and Reason(R) 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): Python functions can accept positional, keyword, and default
20. parameters.

Reasoning (R): Default parameters allow function arguments to be assigned (1)


a default value if no argument is provided during the function call.

Ans : (B) Both A and R are true and R is not the correct explanantion
for A
Assertion (A): A GROUP BY clause in SQL can be used without any
21.
aggregate functions.
Reasoning (R): The GROUP BY clause is used to group rows that have the (1)
same values in specified columns and must always be paired
with aggregate functions.
Page: 5/21
Ans : ( C ) A is True , but R is False

Q No Section-B ( 7 x 2=14 Marks) Marks


Consider the following Python code snippet:
22.
a = [1, 2, 3]
b=a (2)
a.append(4)
c = (5, 6, 7)
d = c + (8,)
a. Explain the mutability of a and c in the context of this code.
b. What will be the values of b and d after the code is executed?

Ans : a) a is a mutable object (a list), meaning its contents can be


changed after it is created. This is demonstrated by the append()
method that adds an element to the list.
c is an immutable object (a tuple). Once created, its contents cannot
be changed. The operation c + (8,) does not modify c but creates a new
tuple.

b)The value of b will be [1, 2, 3, 4], as b references the same list as a,


which was modified by appending 4.
The value of d will be (5, 6, 7, 8), as the expression c + (8,) creates a
new tuple combining c and (8,).

( 1 marks + 1 Marks )

Give examples for each of the following types of operators in Python:


23.
(2)
(I) Assignment Operators

(II) Identity Operators

Ans :

(I) Assignment Operators: ( 1 Marks for Any one of them)

1. Example 1: = (Simple Assignment) Usage: x = 5 (assigns the


value 5 to x)
2. Example 2: += (Add and Assign) : Usage: x += 3 (equivalent to x
= x + 3)

(II) Identity Operators: ( 1 Marks for any one of them )

1. Example 1: is , Usage: x is y (checks if x and y refer to the


same object)
2. Example 2: is not : Usage: x is not y (checks if x and y do
not refer to the same object)

Page: 6/21
If L1 = [10, 20, 30, 40, 20, 10, ...] and L2 = [5, 15, 25, ...], then:
24.
(Answer using builtin functions only)

(I) A) Write a statement to count the occurrences of 20 in L1. (2)


OR
B) Write a statement to find the minimum value in L1.

(II) A) Write a statement to extend L1 with all elements from L2.


OR
B) Write a statement to get a new list that contains the unique elements
from L1.

Ans : I ( A) : count_20 = L1.count(20)


(B) : min_value = min(L1)

II (A) : L1.extend(L2)
(B) : unique_elements = list(set(L1))

( 1 marks for each correct answer , no marks if did not used


any built in function )
25. Identify the correct output(s) of the following code. Also write the minimum
and the maximum possible values of the variable b.
import random
text = "Adventure"
b = random.randint(1, 5)
for i in range(0, b):
print(text[i], end='*') (2)

(A) A* (B) A*D*

(C) A*d*v* (D) A*d*v*e*n*t*u*


Ans :  Minimum possible value of b: 1 ( 1/2 + 1/2 marks)
 Maximum possible value of b: 5

Possible Outputs : (A) and ( C ) ( 1/2 + 1/2 marks )

Page: 7/21
26. The code provided below is intended to reverse the order of elements in a
given list. However, there are syntax and logical errors in the code. Rewrite
it after removing all errors. Underline all the corrections made.

def reverse_list(lst)
if not lst:
return lst (2)
reversed_lst = lst[::-1]
return reversed_lst
print("Reversed list: " reverse_list[1,2,3,4] )

Ans : Corrections : ( 1/2 x 4 = 2)


iAdded a colon (:) after the function definition.
ii. Indented the if statement and the return statement for proper
structure.
iii. Put ( ) while calling the function reverse_list( )
iv. Added a comma (,) in the print statement for correct syntax.

27. (I)
A) What constraint should be applied to a table column to ensure that all
values in that column must be unique and not NULL?
OR
B) What constraint should be applied to a table column to ensure that it can
have multiple NULL values but cannot have any duplicate non-NULL (2)
values?
(II)
A) Write an SQL command to drop the unique constraint named
unique_email from a column named email in a table called Users.
OR
B) Write an SQL command to add a unique constraint to the email column
of an existing table named Users, ensuring that all email addresses are
unique.

Ans : (I)(A): Use the UNIQUE constraint along with the NOT NULL OR
PRIMARY KEY constraint.
OR
(B): Use the UNIQUE constraint alone, allowing for multiple NULL
values.
Example: column_name INT UNIQUE NULL

(II)(A):ALTER TABLE Users DROP CONSTRAINT unique_email;


OR
(B):ALTER TABLE Users ADD CONSTRAINT unique_email UNIQUE
(email);

( 1 mark each for correct part for each questions any correct example
as an answer is acceptable )

Page: 8/21
28. A) Explain one advantage and one disadvantage of mesh topology in
computer networks.
OR (2)
B) Expand the term DNS. What role does DNS play in the functioning of the
Internet?

Ans :
(A): Advantage of Mesh Topology: High redundancy; if one connection
fails, data can still be transmitted through other nodes.
Disadvantage of Mesh Topology: Complexity and high cost; requires
more cabling and configuration compared to simpler topologies.
OR

(B): · DNS stands for Domain Name System. It translates human-


readable domain names (like www.example.com) into IP addresses that
computers use to identify each other on the network.

( for part A 1/2 + 1/2 )


(for part B 1/2 for correct abbreviation and 1/2 for correct use)

Q No. Section-C ( 3 x 3 = 9 Marks) Marks

29. A) Write a Python function that extracts and displays all the words present in a
text file “Vocab.txt” that begins with a vowel..
OR (3)
B) Write a Python function that extracts and displays all the words
containing a hyphen ("-") from a text file "HyphenatedWords.txt", which
has a three letter word before hypen and four letter word after hypen.
For example : “for-them” is such a word.
Ans : A)
def display_words_starting_with_vowel():
vowels = 'AEIOUaeiou'
with open('Vocab.txt', 'r') as file:
words = file.read().split()
# Loop through the words and check if the first letter is a vowel
for word in words:
if word[0] in vowels:
print(word)

B)
def display_specific_hyphenated_words():
with open('HyphenatedWords.txt', 'r') as file:
words = file.read().split()
# Loop through the words and check if they match the pattern
for word in words:
parts = word.split('-')
# Check if the word is hyphenated and matches the format "XXX-
XXXX"
if len(parts) == 2 and len(parts[0]) == 3 and len(parts[1]) == 4:
print(word)
Page: 9/21
1/2 mark for file opening + 1/2 mark for correct loop +1/2 mark for
correct use of split( ) + 1 mark for correct condition + 1/2 mark for
output

(A) You have a stack named MovieStack that contains records of movies.
30. Each movie record is represented as a list containing movie_title,
director_name, and release_year. Write the following user-defined functions
in Python to perform the specified operations on the stack MovieStack:

(I) push_movie(MovieStack, new_movie): This function takes the stack


MovieStack and a new movie record new_movie as arguments and pushes
the new movie record onto the stack.

(II) pop_movie(MovieStack): This function pops the topmost movie record


from the stack and returns it. If the stack is empty, the function should
display "Stack is empty".

(III) peek_movie(MovieStack): This function displays the topmost movie (3)


record from the stack without deleting it. If the stack is empty, the function
should display "None".

OR

(B) Write the definition of a user-defined function push_odd(M) which


accepts a list of integers in a parameter M and pushes all those integers
which are odd from the list M into a Stack named OddNumbers.

Write the function pop_odd() to pop the topmost number from the stack and
return it. If the stack is empty, the function should display "Stack is empty".

Write the function disp_odd() to display all elements of the stack without
deleting them. If the stack is empty, the function should display "None".

For example:

If the integers input into the list NUMBERS are: [7, 12, 9, 4, 15]

Then the stack OddNumbers should store: [7, 9, 15]

Ans : (A )
def push_movie(movie_stack, new_movie): # 1 mark

movie_stack.append(new_movie)

def pop_movie(movie_stack):

if not movie_stack: # 1 mark

return "Stack is empty"

Page: 10/21
return movie_stack.pop()

def peek_movie(movie_stack):

if not movie_stack: # 1 mark

return "None"

return movie_stack[-1]
OR

(B) def push_odd(M, odd_numbers):

for number in M: # 1mark

if number % 2 != 0:

odd_numbers.append(number)

def pop_odd(odd_numbers):

if not odd_numbers: # 1mark

return "Stack is empty"

return odd_numbers.pop()

def disp_odd(odd_numbers):

if not odd_numbers: # 1mark

return "None"

return odd_numbers

Page: 11/21
31. Predict the output of the following code:
data = [3, 5, 7, 2]
result = ""
for num in data:
for i in range(num):
result += str(i) + "*"
result = result[:-1]
print(result)
OR

Predict the output of the following code: (3)


numbers = [10, 15, 20]
for num in numbers:
for j in range(num // 5):
print(j, "+", end="")
print()

Ans : 0*1*2*0*1*2*3*4*0*1*2*3*4*5*6*0*1
( 1 mark for predicting correct output sequence of
numbers + 1 mark for predicting correct placement
of * + 1 mark for removing last * )

OR
0 +1 +
0 +1 +2 +
0 +1 +2 +3 +
( 1 MARK For putting output in three lines + 1 mark for
predicting correct sequence of numbers in each line (
1/2 for incorrect partially correct) + 1 mark for
correct placement of + )
Q No. Section-D ( 4 x 4 = 16 Marks) Marks

32. Consider the table ORDERS as given below

O_Id C_Name Product Quantity Price


1001 Jitendra Laptop 1 12000
1002 Mustafa Smartphone 2 10000
1003 Dhwani Headphone 1 1500
1004 Alice Smartphone 1 9000
1005 David Tablet NULL 7000

Note: The table contains many more records than shown here. (4)
A) Write the following queries:
(I) To display the total Quantity for each Product, excluding Products with
total Quantity less than 5.
(II) To display the ORDERS table sorted by total price in descending order.
(III) To display the distinct customer names from the ORDERS table.
Page: 12/21
(IV) To display the sum of the Price of all the orders for which the quantity
is NULL.
OR
B) Write the output:
(I) SELECT C_Name, SUM(Quantity) AS Total_Quantity FROM ORDERS
GROUP BY C_Name;
(II) SELECT * FROM ORDERS WHERE Product LIKE '%phone%';
(III) SELECT O_Id, C_Name, Product, Quantity, Price FROM ORDERS
WHERE Price BETWEEN 1500 AND 12000;
(IV) SELECT MAX(Price) FROM ORDERS;

Ans : (A) ( 1 MARK EACH)


(I) SELECT Product, SUM(Quantity) AS Total_Quantity
FROM ORDERS
GROUP BY Product
HAVING SUM(Quantity) >= 5;

(II)SELECT O_Id, C_Name, Product, Quantity, Price


FROM ORDERS
ORDER BY Price DESC;

(III)SELECT DISTINCT C_Name


FROM ORDERS;

(IV)SELECT SUM(Price) AS Total_Price_Null_Quantity


FROM ORDERS
WHERE Quantity IS NULL;

OR
(B) ( 1 MARK EACH )
(I)
C_Name Total_Quantity
Jitendra 1
Mustafa 2
Dhwani 1
Alice 1
David NULL

(II)
O_Id C_Name Product Quantity Price
1002 Mustafa Smartphone 2 10000
1004 Alice Smartphone 1 9000

Page: 13/21
(III)

O_Id C_Name Product Quantity Price


1001 Jitendra Laptop 1 12000
1002 Mustafa Smartphone 2 10000
1003 Dhwani Headphone 1 1500
1004 Alice Smartphone 1 9000
(IV)
MAX(Price)
12000

A CSV file "HealthData.csv" contains the data of a health survey. Each


33. record of the file contains the following data:

 Name of a country
 Life Expectancy (average number of years a person is expected to
live)
 GDP per capita (Gross Domestic Product per person)
 Percentage of population with access to healthcare
(4)
For example, a sample record of the file may be: ['Wonderland', 82.5, 40000,
95].

Write the following Python functions to perform the specified


operations on this file:

(I) Read all the data from the file in the form of a list and display all those
records for which the life expectancy is greater than 75.

(II) Count the number of records in the file.

Ans : (I)
import csv
def read_health_data(filename):
records = []
with open(filename, mode='r') as file:
reader = csv.reader(file)
next(reader) # Skip the header row if present
for row in reader:
country = row[0]
life_expectancy = float(row[1])
gdp_per_capita = float(row[2])
access_to_healthcare = float(row[3])
if life_expectancy > 75 :
records.append([country, life_expectancy, gdp_per_capita,
access_to_healthcare])
return records

Page: 14/21
(II)
def count_records( ):
records = read_health_data(“HealthData.csv”)
return len(records)
Alex has been tasked with managing the Student Database for a High
34. School. He needs to access some information from the STUDENTS and
SUBJECTS tables for a performance evaluation. Help him extract the
following information by writing the desired SQL queries as mentioned
below.
Table: STUDENTS
FNam Mark
S_ID LName Enrollment_Date
e s
201 John Doe 15-09-2020 85
202 Jane Smith 10-05-2019 90 (4)
Johnso
203 Alex 22-11-2021 75
n
204 Emily Davis 30-01-2022 60
Micha
205 Brown 17-08-2018 95
el

Table: SUBJECTS

Sub_ID S_ID SubName Credits


301 201 Mathematics 3
302 202 Science 4
303 203 History 2
304 204 Literature 3
305 205 Physics 4
Computer
306 201 3
Science
Write the following SQL queries:
(I) To display complete details (from both the tables) of those students
whose marks are greater than 70.
(II) To display the details of subjects whose credits are in the range of 2 to 4
(both values included).
(III) To increase the credits of all subjects by 1 which have "Science" in their
subject names.
(IV) (A) To display names (FName and LName) of students enrolled in the
"Mathematics" subject.
(OR)
(B) To display the Cartesian Product of these two tables.

Ans : ( I )
SELECT * FROM STUDENTS S
JOIN SUBJECTS Sub ON S.S_ID = Sub.S_ID
WHERE S.Marks > 70;

Page: 15/21
(II)
SELECT *
FROM SUBJECTS
WHERE Credits BETWEEN 2 AND 4;
(III)
UPDATE SUBJECTS
SET Credits = Credits + 1
WHERE SubName LIKE '%Science%';
(IV) A:
SELECT FName, LName
FROM STUDENTS S
JOIN SUBJECTS Sub ON S.S_ID = Sub.S_ID
WHERE Sub.SubName = 'Mathematics';
OR
B:
SELECT *
FROM STUDENTS, SUBJECTS;

A table, named ELECTRONICS, in the PRODUCTDB database, has the


35. following structure:

Field Type
productID int(11)
productName varchar(20)
price float
stockQty int(11)
(4)
Write the following Python function to perform the specified operation:

AddAndDisplay(): To input details of a product and store it in the table


ELECTRONICS. The function should then retrieve and display all records
from the ELECTRONICS table where the price is greater than 150.
Assume the following for Python-Database connectivity:
Host: localhost
User: root
Password: Electro123

Ans :
import mysql.connector
def AddAndDisplay():
# Connect to the database
conn = mysql.connector.connect(
host='localhost',
user='root',
password='Electro123',
database='PRODUCTDB'
)
cursor = conn.cursor()
productID = int(input("Enter Product ID: "))
Page: 16/21
productName = input("Enter Product Name: ")
price = float(input("Enter Price: "))
stockQty = int(input("Enter Stock Quantity: "))
cursor.execute("INSERT INTO ELECTRONICS
(productID, productName,
price, stockQty) VALUES (%s,
%s, %s, %s)", (productID,
productName, price, stockQty))
conn.commit()
cursor.execute("SELECT * FROM ELECTRONICS
WHERE price > 150")
records = cursor.fetchall()
print("\nRecords with price greater than 150:")
for record in records:
print(record)
cursor.close()
conn.close()|
(1 Mark for Declaration of correct Connection Object
+ 1 Mark for correct input + 1 marks for correctly
using execute( ) method + 1 marks for showing
output using loop )

Q.No. SECTION E (2 X 5 = 10 Marks) Marks


Raj is a supervisor at a software development company. He needs to
36. manage the records of various employees. For this, he wants the following
information of each employee to be stored:
Employee_ID – integer
Employee_Name – string
Position – string
Salary – float (5)
You, as a programmer of the company, have been assigned to do this job for
Raj.
(I) Write a function to input the data of an employee and append it to a binary
file.
(II) Write a function to update the data of employees whose salary is greater
than 50000 and change their position to "Team Lead".
(III) Write a function to read the data from the binary file and display the data
of all those employees who are not "Team Lead".

Ans : (I)
import pickle
def add_employee(filename):
employee_id = int(input("Enter Employee ID: "))
employee_name = input("Enter Employee Name: ")
position = input("Enter Position: ")
salary = float(input("Enter Salary: "))
new_employee = (employee_id, employee_name, position, salary)
with open(filename, 'ab') as file:
pickle.dump(new_employee, file)

(1/2 mark for input + 1 mark for correct use of dump( ) to add new emp
Page: 17/21
data)
(II)
def update_employee(filename):
employees = []
with open(filename, 'rb') as file:
try:
while True:
employees.append(pickle.load(file))
except EOFError:
pass
for i in range(len(employees)):
if employees[i][3] > 50000:
employees[i] = (employees[i][0], employees[i][1], "Team Lead",
employees[i][3])
with open(filename, 'wb') as file:
for employee in employees:
pickle.dump(employee, file)
(1 mark for correct use of load( ) method to retrieve data + 1/2 mark for
correct loop + 1/2 mark for correct condition within loop )

(III)
def display_non_team_leads(filename):
print("\nEmployees who are not Team Leads:")
with open(filename, 'rb') as file:
try:
while True:
employee = pickle.load(file)
if employee[2] != "Team Lead":
print(f"ID: {employee[0]}, Name: {employee[1]}, Position:
{employee[2]}, Salary: {employee[3]}")
except EOFError:
pass
( 1 mark for correct use of Try except block and 1/2 mark for correct
use of while loop )

Page: 18/21
Interstellar Logistics Ltd. is an international shipping company. They are
37. planning to establish a new logistics hub in Chennai, with the head office in
Bangalore. The Chennai hub will have four buildings - OPERATIONS,
WAREHOUSE, CUSTOMER_SUPPORT, and MAINTENANCE. As a
network specialist, your task is to propose the best networking solutions to
address the challenges mentioned in points (I) to (V), considering the
distances between the various buildings and the given requirements.

(5)
Building-to-Building Distances (in meters):

From To Distance
OPERATIONS WAREHOUSE 40 m
OPERATIONS CUSTOMER_SUPPORT 90 m
OPERATIONS MAINTENANCE 50 m
WAREHOUSE CUSTOMER_SUPPORT 60 m
WAREHOUSE MAINTENANCE 45 m
CUSTOMER_SUPPORT MAINTENANCE 55 m

Distance of Bangalore Head Office from Chennai Hub: 1300 km

Number of Computers in Each Building/Office:

Location Computers
OPERATIONS 40
WAREHOUSE 20
CUSTOMER_SUPPORT 25
MAINTENANCE 22
BANGALORE HEAD OFFICE 15

Page: 19/21
(I) Suggest the most suitable location for the server within the Chennai hub.
Justify your decision.

(II) Recommend the hardware device to connect all computers within each
building efficiently.

(III) Draw a cable layout to interconnect the buildings at the Chennai hub
efficiently. Which type of cable would you recommend for the fastest and
most reliable data transfer?

(IV) Is there a need for a repeater in the proposed cable layout? Justify your
answer.

(V) A) Recommend the best option for live video communication between the
Operations Office in the Chennai hub and the Bangalore Head Office from
the following choices:

 a) Video Conferencing
 b) Email
 c) Telephony
 d) Instant Messaging
OR

(V) B) What type of network (PAN, LAN, MAN, or WAN) would be set up
among the computers within the Chennai hub?

Ans :
(I) The server should be placed in the OPERATIONS building.
Justification:

 It has the largest number of computers (40), making it the most


central location in terms of the network load.
 The distances to other buildings are relatively short, ensuring
efficient data transfer. (1 Mark)

(II) A switch should be used within each building to connect all


computers. A switch is ideal for creating a local area network (LAN)
and ensures efficient communication between devices in a single
building. ( 1 Mark)

(III) The most efficient cable layout would involve connecting the
buildings as follows:

 OPERATIONS to WAREHOUSE (40 m)


 OPERATIONS to MAINTENANCE (50 m)
 OPERATIONS to CUSTOMER_SUPPORT (90 m)
 WAREHOUSE to MAINTENANCE (45 m)
 WAREHOUSE to CUSTOMER_SUPPORT (60 m)

Page: 20/21
CUSTOMER_SUPPORT

(90 m)

OPERATIONS

/ | \

(40 m) (50 m) (60 m)

/ | \

WAREHOUSE MAINTENANCE

Cable Recommendation: Fiber optic cable is recommended for high-


speed data transfer and reliable communication over distances. It
offers better bandwidth and lower signal degradation over long
distances than copper cables. ( 1/2 + 1/2 mark)

(III) There is no need for a repeater in this layout. The maximum distance
between any two buildings is 90 meters, which is well within the 100-meter
limit for Ethernet cable or fiber optics before requiring a repeater.

( 1 mark )

(IV) A) The best option for live communication between the Chennai
Operations Office and the Bangalore Head Office would be Video
Conferencing. This allows real-time face-to-face meetings and visual
communication across long distances, which is ideal for inter-office
collaboration.

OR

(V) B) The network type in the Chennai hub would be a LAN (Local Area
Network), as all computers are located within a confined geographical
area (the logistics hub) and are connected to each other for data
communication within the same campus.

(1 mark for any correct part solution )

Page: 21/21
अनक्र
ु म ांक/ROLL NO सेट/SET : 01

केंद्रीय विद्य लय सांगठन ,जयपुर सांभ ग


KENDRIYA VIDYALAYA SANGATHAN, JAIPUR REGION
प्रथम प्री बोर्ड परीक्ष / 1ST PRE BOARD EXAMINATION :2024-25
कक्ष / CLASS :XII
विषय /SUB : कांप्यूटर विज्ञ नां (83) /COMPUTER SCIENCE (83)
अधिकतम अिधि / Time Allowed :03 Hours अधिकतम अांक Maximum Marks : 70
स म न्य ननर्दे श / 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 the case of MCQ, the text of the correct answer should also be written.

Q. Section-A (21 x 1 = 21 Marks) Mark


1 State True or False: 1
The keys of a dictionary must be of immutable types.
2 Identify the output of the following code snippet: 1
str = "KENDRIYA VIDYALAYA"
str=str.replace('YA','*')
print(str)
(a) KENDRIYA VIDYALAYA (b) KENDRI*A VID*ALAYA
(c) KENDRI* VID*LA* (d) * KENDRI* VID*LA*
3 What will be the output of following expression? 1
(5<10 ) and (10< 5) or (3<18) and not 8<18
(a) True (b) False (c) Error (d) No output
4 What is the output of the expression? 1
St1=”abc@pink@city”
print(St1.split("@"))
(a) (“abc”, “@”, “pink”, “@”, “city”) (b) [“abc”, “@”, “pink”,”@’,”city”]
(c) [“abc”, “pink”, “city”] (d) Error
5 What will be the output of the following code snippet? 1
message= "Satyamev Jayate"
print(message[-2::-2])
6 Which of the following options will not result in an error when performed on types in 1
python where tp = (5,2,7,0,3) ?
(a) Tp[1] = 2 (b) tp.append(2)
(c) tp1 = tp+tp (d) tp.sum( )

Page 1 of 7
7 If my_dict is a dictionary as defined below, then which of the following statements will 1
raise an exception?
my_dict = {'aman': 10, 'sumit': 20, 'suresh': 30}
(a) my_dict.get('suresh') (b) print(my_dict['aman', 'sumit'])
(c) my_dict['aman']=20 (d) print(str(my_dict))
8 Which of the following can delete an element from a list if the index of the element is 1
given?
(a) pop( ) (b) remove( )
(c) clear( ) (d) all of these
9 Which of the following attributes can be considered as a choice for primary key? 1
(a) Name (b) Street
(c) Roll No (d) Subject
10 Write the missing statement to complete the following code: 1
file = open("abc.txt", "r")
d = file.read(50)
____________________ #Move the file pointer to the beginning of the file
next_data = file.read(75)
file.close()
11 State whether the following statement is True or False: 1
An exception may be raised even if the program is syntactically correct.
12 What will be the output of the following Python code ? 1
v = 50
def Change(n):
global v
v, n = n, v
print(v, n, sep = “#”, end = “@”)
Change(20)
print(v)
(a) 20#50@20 (b) 50@20#50
(c) 50#50#50 (d) 20@50#20
13 Which statement is used to modify data in a table? 1
(a) CHANGE (b) MODIFY (c) UPDATE (d) ALTER

14 How would you return all the rows from a table named "Item" sorted in descending 1
order on the column "IName"?
(a) SELECT * FROM Item SORT 'IName' DESC;
(b) SELECT * FROM Item ORDER BY IName DESC ;
(c) SELECT * FROM Item ORDER IName DESC ;
(d) SELECT * FROM Item SORT BY 'IName' DESC;
15 LIKE clause is used for. 1
(a) For pattern matching (b) For table matching
(c) For inserting similar data in a table (d) For deleting data from a table
16 Count(*) method count 1
(a) NULL values only (b)Empty Values
(c) ALL the values (d) None of these
17 The term HTTP stands for? 1
(a) Hyper terminal tracing program (b) Hypertext tracing protocol
(c) Hypertext transfer protocol (d) Hypertext transfer program

18 A device that connects networks with different protocols – 1


(a) Switch (b) Hub (c) Gateway (d) Proxy Server
19 Which switching technique follows the store and forward mechanism? 1

Page 2 of 7
Q20 and Q21 are Assertion(A) and Reason(R) 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
20 Assertion :- A parameter having a default value in the function header is known as a 1
default parameter.
Reason:- The default values for parameters are considered only if no value is
provided for that parameter in the function call statement.
21 Assertion :- Both WHERE and HAVING clauses are used to specify conditions.
Reason :- The WHERE and HAVING clauses are interchangeable.

Q Section-B ( 7 x 2=14 Marks) Mark


22 What are immutable and mutable types? List immutable and mutable types of 2
python.
23 If given A=2,B=1,C=3, What will be the output of following expressions: 2
(i) print((A>B) and (B>C) or(C>A))
(ii) print(A**B**C)
24 Write the most appropriate list method to perform the following tasks. 2
(I) A) To delete a given element from the list L1.
OR
B) To sort the elements of list L1 in ascending order.
(II) A) To add an element in the beginning of the list L1.
OR
B) To add elements of a list L2 in the end of a list L1.
25 What possible outputs(s) are expected to be displayed on screen at the time of 2
execution of the program from the following code? Also specify the maximum
values that can be assigned to each of the variables FROM and TO.
import random
AR=[20,30,40,50,60,70]
FROM=random.randint(1,3)
TO=random.randint(2,4)
for K in range(FROM,TO):
print (AR[K],end=”#“)
(i)10#40#70# (ii)30#40#50# (iii)50#60#70# (iv)40#50#70#
26 Rewrite the following code in Python after removing all syntax error(s). Underline 2
each correction done in the code.
p=30
for c in range(0,p)
If c%4==0:
print (c*4)
Elseif c%5==0:
print (c+3)
else
print(c+10)
27 (i) (A) What constraint should be applied on a table column so that duplicate 2
values are not allowed in that column, but NULL is allowed.
OR
Page 3 of 7
(B) What constraint should be applied on a table column so that NULL is not
allowed in that column, but duplicate values are allowed.
(ii)
(A) Write an SQL command to remove the Primary Key constraint from a table,
named MOBILE. M_ID is the primary key of the table.
OR
B) Write an SQL command to make the column M_ID the Primary Key of an
already existing table, named MOBILE.
28 (A) How is it easier to diagnose fault in Star topology than in Bus topology ? 2
OR
(B) Nirmala is a bit confused between the terms Web server and Web browsers.
Help her in understanding both the terms with the help of suitable example.

Q Section-C ( 3 x 3 = 9 Marks) Mark


29 (A) Write a Python function that count the lines start with the word “the” in a file 3
“xyz.txt” and display it at the end.
OR
B) Write a Python function that Count total number of vowels in a file “abc.txt”.
30 (A) Madhuri has a list containing 10 integers. You need to help him create a 3
program
with separate user defined functions to perform the following operations based on
this list.
● Traverse the content of the list and push the ODD numbers into a stack.
● Pop and display the content of the stack.
For Example:
If the sample Content of the list is as follows:
N=[12, 13, 34, 56, 21, 79, 98, 22, 35, 38]
Sample Output of the code should be:
13,21,89,35
OR
(B) Saroj have a list of 10 numbers . You need to help him create a program with
separate user defined functions to perform the following operations based on this
list.
● Traverse the content of the list and push the numbers into a stack which are
divisible by 5.
● Pop and display the content of the stack.
For Example:
If the sample Content of the list is as follows:
N=[2,5,10,13,20,23,45,56,60,78]
Sample Output of the code should be:
5,10,20,45,60
31 (A) Predict the output of the Python code given below: 3
def func(n1 = 1, n2= 2):
n1= n1 * n2
n2= n2 + 2
print(n1, n2)
func( )
func(2,3)

Page 4 of 7
OR
(B) Predict the output of the Python code given below:
T= [“20”, “50”, “30”, “40”]
Counter=3
Total= 0
for I in [7,5,4,6]:
newT=T[Counter]
Total= float (newT) + I
print(Total)
Counter=Counter-1

Q Section-D ( 4 x 4 = 16 Marks) Mark


32 Write SQL queries for (i)to(iv),which are based on the table: ACTIVITY given 4
below:
Table:ACTIVITY
ACode ActivityName ParticipantsNum PrizeMoney ScheduleDate
1001 Relay100x4 16 10000 23-Jan-2004
1002 Highjump 10 12000 12-Dec-2003
1003 ShotPut 12 8000 14-Feb-2004
1005 LongJump 12 9000 01-Jan-2004
1008 DiscussThrow 10 15000 19-Mar-2004
(i) To display the name of all activities with their Acodes in descending order.
(ii) To display sum of PrizeMoney for each of the Number of participants
groupings (as shown in column ParticipantsNum(10,12,16).
(iii) To display the Schedule Date and Participants Number for the activity
Relay100x4.
(iv) To increase PrizeMoney by 500 for High jump activity
OR
Write output for SQL queries(i) to(iii) and query for (iv),which are based on the
table: ACTIVITY:
(i) select count(distinct ParticipantsNum) from ACTIVITY;
(ii) select max(ScheduleDate),min(ScheduleDate) from ACTIVITY;
(iii) select sum(PrizeMoney) from ACTIVITY;
(iv) Write a query to delete the record of Acode 1003.
33 Abhishek is making a software on “Countries & their Capitals” in which various 4
records are to be stored/retrieved in CAPITAL.CSV data file. It consists of some
records. As a programmer, you have to help him to successfully execute the
program.

(A) Write a function in Python named AddNewRec(Country,Capital) to append


following records in the file “CAPITAL.CSV”.
[“FRANCE”,”PARIS”]
[“SRILANKA”,”COLOMBO”]
(B) Write a function in Python named ShowRec( ) that will show all the contents of
CAPITAL.CSV
34 Write SQL commands for the queries (i) to (iii) and output for (iv) & (v) based 4
on a table COMPANY and CUSTOMER .

Page 5 of 7
COMPANY
CID CNAME CITY PRODUCTNAME
111 SONY DELHI TV
222 NOKIA MUMBAI MOBILE
333 ONIDA DELHI TV
444 SONY MUMBAI MOBILE
555 BLACKBERRY MADRAS MOBILE
666 DELL DELHI LAPTOP

CUSTOMER
CUSTID NAME PRICE QTY CID
101 Rohan Sharma 70000 20 222
102 Deepak Kumar 50000 10 666
103 Mohan Kumar 30000 5 111
104 Sahil Bansal 35000 3 333
105 Neha Soni 25000 7 444
106 Sonal Aggarwal 20000 5 333
107 Arjun Singh 50000 15 666
(i) To display those company name along with price which are having price less
than 30000.
(ii) To display the name and price of the companies whose price is between 20000
to 35000.
(iii) To increase the price by 1000 for those customer whose name starts with ‘S’
(iv) To display those product name, city and price which are having product name
as MOBILE.
35 Kabir wants to write a program in Python to insert the following record in the table 4
named Student in MYSQL database, SCHOOL:
- rno(Roll number) – integer
- name(Name) – string
- DOB(Date of Birth) – Date
- Fee – float
Note the following to establish connectivity between Pythonand MySQL:
- Username – root
- Password – tiger
- Host – localhost
The values of fieldsrno, name, DOB and fee has to be accepted from the user.
Help Kabir to write the program in Python.

Q Section-E ( 2 x 5 = 10 Marks) Mark


36 Amit is a manager working in a recruitment agency. He needs to manage the 5
records of various candidates. For this, he wants the following information of each
candidate to be stored: -
Candidate_ID – integer
Candidate_Name – string
Designation – string
Experience – float

Page 6 of 7
You, as a programmer of the company, have been assigned to do this job for Amit.
(i) Write a function to input the data of a candidate and append it in a binary file.
(ii) Write a function to update the data of candidates whose experience is more
than 12 years and change their designation to "Sr. Manager".
(iii) Write a function to read the data from the binary file and display the data of all
those candidates who are not "Sr. Manager".
37 PVS Computers decided to open a new office at Ernakulum, the office consist of 5
Five Buildings and each contains number of computers. The details are shown
below.

Distance between the buildings

Building 1 and 2 20 Meters Building No of computers


1 40
Building 2 and 3 50 Meters
2 45
Building 3 and 4 120 Meters 3 110
4 70
Building 3 and 5 70 Meters
5 60
Building 1 and 5 65 Meters
Building 2 and 5 50 Meters

The Company has now decided to connect network in buildings.


(i)Suggest the most suitable place (i.e. building) to house the server of this
organization. Also give a reason to justify your suggested location.
(ii) Where would you place Hub/Switch? Answer with justification.
(iii) Suggest a cable layout of connection between the buildings (Topology).
(iv) Do you think anywhere Repeaters required in the campus? Why
(v) Suggest a protocol that shall be needed to provide Video Conferencing solution
between Ernakulum Campus and Ranchi Campus.
OR
What type of network (PAN, LAN, MAN, or WAN) will be set up among the
computers connected in the Ernakulum campus?

Page 7 of 7
Kendriya Vidyalaya Sangathan, Jaipur Region
Pre-Board Examination: 2024-25
Marking scheme Set No: 1
Class: XII Subject: Computer Science (083)
Maximum Marks: 70 Period: 3 Hours
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 the case of MCQ, the text of the correct answer should also be written.

Q. Section-A (21 x 1 = 21 Marks) Mark


Ans 1 True 1
(1 mark for correct answer)
Ans 2 (c) KENDRI* VID*LA* 1
(1 mark for correct answer)
Ans 3 (b) False 1
(1 mark for correct answer)
Ans 4 (c) [“abc”, “pink”, “city”] 1
(1 mark for correct answer)
Ans 5 tyJvmya 1
(1 mark for correct answer)
Ans 6 (c) tp1 = tp+tp 1
(1 mark for correct answer)
Ans 7 (b) print(my_dict['aman', 'sumit']) 1
(1 mark for correct answer)
Ans 8 (a) pop( ) 1
(1 mark for correct answer)
Ans 9 (c) Roll No 1
(1 mark for correct answer)
Ans10 file.seek(0) ( OR file.seek(0,0) ) 1
(1 mark for correct answer)
Ans11 True 1
(1 mark for correct answer)
Ans12 (a) 20#50@20 1
(1 mark for correct answer)
Ans13 (c) UPDATE 1
(1 mark for correct answer)
Ans14 (b) SELECT * FROM Item ORDER BY IName DESC ; 1
(1 mark for correct answer)
Ans15 (a) For pattern matching 1
(1 mark for correct answer)
Ans16 (c) ALL the values 1
(1 mark for correct answer)
Ans17 (c) Hypertext transfer protocol 1
(1 mark for correct answer)
Ans18 (c) Gateway 1
(1 mark for correct answer)
Ans19 Message Switching technique 1
(1 mark for correct answer)
Q20 and Q21 are Assertion(A) and Reason(R) 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
Ans20 (b) Both A and R are true and R is not the correct explanation for A 1
(1 mark for correct answer)
Ans21 (c) A is True but R is False
(1 mark for correct answer)

Q Section-B ( 7 x 2=14 Marks) Mark


Ans Immutable types are those that can never change their value in place. These are : 2
22 integers, float, string, tuple
Mutable types are those whose values can be changed in place. These are : lists,
dictionaries
(1 mark for each correct definition and example)
Ans (i) True 2
23 (ii) 2
(1 mark for each correct answer.)
Ans 2
24 (I) A) L1.remove(4)
OR
B) L1.sort( )
(II) A) L1.insert( )
OR
B) L1.extend(L2)
(1 mark for each correct answer)
Ans (ii)30#40#50# 2
25 Maximum value assigned to FROM is 3
Maximum value assigned to TO is 4
(1 mark for each correct answer)
(½ x 2 = 1 Mark for correct Maximum values)
Ans p=30 2
26 for c in range(0,p):
if c%4==0:
print (c*4)
elif c%5==0:
print (c+3)
else:
print(c+10)
(½ mark each for correcting 4 mistakes)
Ans (I) A) UNIQUE 2
27 OR
B) NOT NULL
(1 mark for correct answer)

(II) A) ALTER TABLE MOBILE DROP PRIMARY KEY;


OR
B) ALTER TABLE MOBILE ADD PRIMARY KEY (M_ID);
(1 mark for correct answer)
28 Ans: Fault diagnosis is easier in Star topology as if there is any problem in a node 2
will affect the particular node only. While in bus topology, if problem exists in
common medium it will affect the entire nodes.
OR
Web Server Web browser
A web server is a computer or a group A web browser is an application used
of computers that hosts or stores to access and view websites.
content of website. Common web browsers include
It processes and delivers web pages Microsoft Internet Explores, Google
of the websites to the users. Chrome etc.
The main job of a web server is to
display the website content
(2 mark for correct answer)

Q Section-C ( 3 x 3 = 9 Marks) Mark


29 (A) 3
Logic:- We need to split all the words of a every line and then check first word of
each line.
def count_the():
F=open(“abc.txt”,”r”)
L=F.readlines()
count=0
for x in L: # read all the lines one by one
L1=x.split() # It will split all the lines into words
if L1[0].lower() == “the” :
count=count+1
print(“total lines are :- “,count)
F.close()
(½ mark for correct function header)
(½ mark for correctly opening the file)
(½ mark for correctly reading from the file)
(½ mark for splitting the text into words/character)
(1 mark for correctly displaying the desired counts)
OR
(B)
Read the file character by character
def count_vowels():
F=open(“abc.txt”, “r”)
S=f.read()
Count=0
for x in S:
if x.lower() in “aeiou”:
count=count+1
print(“total number of vowels are :- “, count)
F.close()

(½ mark for correct function header)


(½ mark for correctly opening the file)
(½ mark for correctly reading from the file)
(½ mark for checking vowels)
(1 mark for correctly displaying the desired counts)
30 N=[12, 13, 34, 56, 21, 79, 98, 22,35, 38] 3
def PUSH(S,N):
S.append(N)
def POP(S):
if S!=[ ]:
return S.pop()
else:
return None
ST=[ ]
for k in N:
if k%2!=0:
PUSH(ST,k)
while True:
if ST!=[ ]:
print(POP(ST),end=" ")
else:
break
(2x1 mark for correct function body; 1 mark for function calling)
OR
(B) N= [2,5,10,13,20,23,45,56,60,78]
def PUSH(S,N):
S.append(N)
def POP(S):
if S!=[]:
return S.pop()
else:
return None
ST=[]
for k in N:
if k%5==0:
PUSH(ST,k)
while True:
if ST!=[]:
print(POP(ST),end=" ")
else:
break
(2x1 mark for correct function body; 1 mark for function calling)

31 2 4 3
65
OR
47.0
35.0
54.0
26.0
( 3 Mark for correct output, 1 mark for partial correct)

Q Section-D ( 4 x 4 = 16 Marks) Mark


32 i) Select ActivityName, Acode from ACTIVITY order by Acode desc; 4
ii) Select sum(PrizeMoney) from ACTIVITY group by ParticipantsNum;
iii) Select ScheduleDate, ParticipantsNum from ACTIVITY where
ActivityName = ‘Relay 100 x4’;
iv) Update ACTIVITY set PrizeMoney = PrizeMoney + 500 where
ActivityName = “High jump”;

(1 mark for each correct Query.)


OR
(i)
Count(distinct ParticipantsNum)

3
(ii)
Max(ScheduleDate) Min(ScheduleDate)

2004-03-19 2003-12-12
(iii)
Sum(PrizeMoney)

54000
(iv) delete from ACTIVITY where Acode = 1003;
(1 mark for each correct answer.)
Ans Ans: (a) 4
33 import csv
def AddNewRec(Country,Capital):
f=open("CAPITAL.CSV",'a')
fwriter=csv.writer(f,lineterminator="\n")
fwriter.writerow([Country,Capital])
f.close()
(b)
def ShowRec():
with open("CAPITAL.CSV","r") as NF:
NewReader=csv.reader(NF)
for rec in NewReader:
print(rec[0],rec[1])

AddNewRec(“FRANCE”,”PARIS”)
AddNewRec(“SRILANKA”,”COLOMBO”)
ShowRec()

Ans SQL Two table based question 4


34 (i) SELECT CNAME, PRICE FROM COMPANY, CUSTOMER WHERE
COMPANY.CID = CUSTOMER.CID AND PRICE < 30000;
(ii) SELECT CNAME, PRICE FROM COMPANY, CUSTOMER WHERE
COMPANY.CID = CUSTOMER.CID AND PRICE BETWEEN 20000 AND 35000;
(iii) UPDATE CUSTOMER SET PRICE = PRICE+1000 WHERE NAME LIKE “S%”;
(iv) SELECT PRODUCTNAME,CITY, PRICE FROM COMPANY,CUSTOMER
WHERE COMPANY.CID=CUSTOMER.CID AND PRODUCTNAME=”MOBILE”;
(1 mark for each correct query.)
Ans import mysql.connector as mysql 4
35 con1 = mysql.connect(host = “localhost”, user = “root”, password = “tiger”,
database = “sample”)
mycursor = con1.cursor( )
rno = int(input(“Enter Roll Number : “))
name = input(“Enter the name : “)
DOB = input(“Enter date of Birth : “)
fee = float(input(“Enter Fee : “
query = “INSERT into student values({ }, ‘{ }’, ‘{ }’ , { })”.format(rno,name,DOB,fee)
mycursor.execute(query)
con1.commit( )
print(“Data added successfully”)
con1.close( )
(½ mark for correctly importing the connector object)
(½ mark for correctly creating the connection object)
(½ mark for correctly creating the cursor object)
(½ mark for correctly inputting the data)
(1 mark for correct creation of query)
(½ mark for correctly executing the first query with commit
(½ mark for correctly displaying the data)

Q Section-E ( 2 x 5 = 10 Marks) Mark


Ans (I) import pickle 5
36 def input_candidates():
candidates = [ ]
n = int(input("Enter the number of candidates you want to add: "))
for i in range(n):
candidate_id = int(input("Enter Candidate ID: "))
candidate_name = input("Enter Candidate Name: ")
designation = input("Enter Designation: ")
experience = float(input("Enter Experience (in years): "))
candidates.append([candidate_id, candidate_name, designation,
experience])
return candidates
candidates_list = input_candidates()

def append_candidate_data(candidates):
with open('candidates.bin', 'ab') as file:
for candidate in candidates:
pickle.dump(candidate, file)
print("Candidate data appended successfully.")
append_candidate_data(candidates_list)

(II) import pickle


def update_senior_manager():
updated_candidates = [ ]
try:
with open('candidates.bin', 'rb') as file:
while True:
try:
candidate = pickle.load(file)
if candidate[3] > 10: # If experience > 10 years
candidate[2] = 'Senior Manager'
updated_candidates.append(candidate)
except EOFError:
break # End of file reached
except FileNotFoundError:
print("No candidate data found. Please add candidates first.")
return
with open('candidates.bin', 'wb') as file:
for candidate in updated_candidates:
pickle.dump(candidate, file)
print("Candidates updated to Senior Manager where applicable.")
update_senior_manager()

(III)
import pickle
def display_non_senior_managers():
try:
with open('candidates.bin', 'rb') as file:
while True:
try:
candidate = pickle.load(file)
if candidate[2] != 'Senior Manager': # Check if not Senior Manager
print(f"Candidate ID: {candidate[0]}")
print(f"Candidate Name: {candidate[1]}")
print(f"Designation: {candidate[2]}")
print(f"Experience: {candidate[3]}")
print("--------------------")
except EOFError:
break # End of file reached
except FileNotFoundError:
print("No candidate data found. Please add candidates first.")
display_non_senior_managers()

(1/2 mark of import pickle)


(1/2 mark for input)
(1/2 mark for opening file in append mode and 1/2 mark for using dump)
(1/2 mark for opening file in read mode and 1/2 mark for using load)
(1 mark for checking the condition and updating the value)
(1 mark for checking the condition and displaying data correctly)
(1 mark for try and except block)
37 Networking based question 5
(i) Server should be installed in Building 3 , As maximum computer is there
(ii) Hub/Switch installed in each and every building to connect computers in each
building.
(iii) Bus/ Star topology
(iv) No repeater is required as distance between building is less than 100 meter.
(v) Voip
OR
LAN (Local Area Network)

(1x5=5 mark for each correct answer)


FIRST PRE BOARD EXAM (2024-25)
CLASS-XII
SUBJECT- COMPUTER SCIENCE(083)
QP12ACS01PB24
TIME-3:00 HRS Max Marks-70
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.
 This question paper contains five sections, Section A to E.
 Section A have 21 questions (1 to 21) carrying 01 mark each.
 Section B has 07 questions (22 to 28) carrying 02 marks each.
 Section C has 03 questions (29 to 31) carrying 03 marks each.
 Section D has 04 questions (32 to 35) carrying 04 marks each.
 Section E has 02 questions (36 to 37) carrying 05 marks each.
 All programming questions are to be answered using Python Language only.
 In case of MCQs, text of the correct answer should also be written.
SECTION A
1. State True or False 1
“Variable declaration is implicit in Python.”
2. Which of the following is an invalid datatype in Python? 1
(a) Set (b) None
(c) Integer (d) Real
3. Given the following dictionaries 1
dict_exam={"Exam":"AISSCE", "Year":2025}
dict_result={"Total":500, "Pass_Marks":165}
Which statement will merge 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)
4. Consider the given expression: 1
not True and False or True
Which of the following will be correct output if the given expression isevaluated?
(a) True (b) False
(c) NONE (d) NULL
5. Select the correct output of the code: 1
a = "Year 2022 at All the best"
a = a.split('2')
b = a[0] + ". " + a[1] + ". " + a[3]
print (b)
(a) Year . 0. at All the best
(b) Year 0. at All the best
(c) Year . 022. at All the best
(d) Year . 0. at all the best
6. Which of the following mode in file opening statement results or generates an error if the 1
file does not exist?
(a) a+ (b) r+ (c) w+ (d) None of the above
7. Fill in the blank: 1
command is used to remove primary key from the table in SQL.
(a) update (b)remove (c) alter (d)drop
8. Which of the following commands will delete the table from MYSQL database? 1
(a) DELETE TABLE (b) DROP TABLE
(c) REMOVE TABLE (d) ALTER TABLE
9. Which of the following statement(s) would give an error after executing the 1
following code?
S="Welcome to class XII" # Statement 1
print(S) # Statement 2
S="Thank you" # Statement 3
S[0]= '@' # Statement 4
S=S+"Thank you" # Statement 5
(a) Statement 3
(b) Statement 4
(c) Statement 5
(d) Statement 4 and 5
10. Fill in the blank: 1
is a non-key attribute, whose values are derived from the primary key of some
other table.
(a) Primary Key (b) Foreign Key
(c) Candidate Key (d) Alternate Key
11. The correct syntax of seek() is: 1
(a) file_object.seek(offset [, reference_point])
(b) seek(offset [, reference_point])
(c) seek(offset, file_object)
(d) seek.file_object(offset)
12. Fill in the blank: 1
The SELECT statement when combined with clause, returns records
without repetition.
(a) DESCRIBE (b) UNIQUE
(c) DISTINCT (d) NULL
13. Fill in the blank: 1
is a communication methodology designed to deliver both voiceand multimedia
communications over Internet protocol.
(a) VoIP (b) SMTP (c) PPP (d)HTTP
14. What will the following expression be evaluated to in Python? 1
print(15.0 / 4 + (8 + 3.0))
(a) 14.75 (b)14.0 (c) 15 (d) 15.5
15. Which function is used to display the total number of records from table in a database? 1
(a) sum(*) (b) total(*)
(c) count(*) (d) return(*)
16. To establish a connection between Python and SQL database, connect() is used. Which of 1
the following arguments may notnecessarily be given while calling connect()?
(a) host (b) database
(c) user (d) Password
17. What is the scope of a variable defined outside of any function? 1
(a) Global scope (b) Local scope
(c) Module- scope (d) Function- scope
18. How do you check if a file exists before opening it in Python? 1
a) Use the exists() function from the os module
b) Use the open() function with the try-except block
c) Use the isfile() function from the os.path module
d) All of the above
19. Which type of network consists of both LANs and MANs? 1
(a) Wide Area Network (b) Local Area Network
(c) Both a and b (d) None of the above
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
20. 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.
Reasoning (R):- During a function call, the argument list first contains default argument(s)
followed by positional argument(s).
21. Assertion (A): CSV (Comma Separated Values) is a file format for datastorage which looks 1
like a text file.
Reason (R): The information is organized with one record on each line and each field is
separated by comma.
SECTION B
22. Rao has written a code to input a number and check whether it is prime or not. His code is 2
having errors. Rewrite the correct code andunderline the corrections made.
def prime():
n=int(input("Enter number to check :: ")
for i in range (2, n//2):
if n%i=0:
print("Number is not prime \n")
break
else:
print("Number is prime \n’)
23. Write two points of difference between Circuit Switching and PacketSwitching. 2

OR

Write two points of difference between XML and HTML.


24. (a) Given is a Python string declaration: 1
myexam="@@CBSE Examination 2022@@"
Write the output of: print(myexam[::-2])
(b) Write the output of the code given below:
my_dict = {"name": "Aman", "age": 26} 1
my_dict['age'] = 27
my_dict['address'] = "Delhi"
print(my_dict.items())
25. Explain the use of „Foreign Key‟ in a Relational Database Management System. Give 2
example to support your answer.
26. (a) Write the full forms of the following: 2
i. SMTP (ii) PPP

(b) What is the use of TELNET?


27. Predict the output of the Python code given below: 2

def Diff(N1,N2):if
N1>N2:
return N1-N2
else:
return N2-N1

NUM= [10,23,14,54,32]
for CNT in range (4,0,-1):
A=NUM[CNT]
B=NUM[CNT-1]
print(Diff(A,B),'#', end=' ')

OR

Predict the output of the Python code given below:

tuple1 = (11, 22, 33, 44, 55 ,66)


list1 =list(tuple1)
new_list = []
for i in list1:if
i%2==0:
new_list.append(i) new_tuple = tuple(new_list)
print(new_tuple)
28. Differentiate between count() and count(*) functions in SQL withappropriate example. 2

OR

Categorize the following commands as DDL or DML:INSERT, UPDATE, ALTER, DROP


SECTION C
29. (a) Consider the following tables – Bank_Account and Branch: 1+2

What will be the output of the following statement?


SELECT * FROM Bank_Account NATURAL JOIN Branch;
(b)Write the output of the queries (i) to (iv) based on the given table,
i. SELECT DISTINCT TID FROM TECH_COURSE;
ii. SELECT TID, COUNT(*), MIN(FEES) FROM TECH_COURSE GROUP BY TID
HAVING COUNT(TID)>1;
iii. SELECT CNAME FROM TECH_COURSE WHERE FEES>15000 ORDER BY
CNAME;
iv. SELECT AVG(FEES) FROM TECH_COURSE WHERE FEES BETWEEN 15000
AND 17000;
30. Write a method COUNTLINES() in Python to read lines from text file „TESTFILE.TXT‟ 3
and display the lines which are not starting with any vowel. Example:
If the file content is as follows:
An apple a day keeps the doctor away.
We all pray for everyone‟s safety.
A marked difference will come in our country. T

he COUNTLINES() function should display the output as:


The number of lines not starting with any vowel - 1

OR

Write a function ETCount() in Python, which should read each character of a text file
“TESTFILE.TXT” and then count and display the count of occurrence of alphabets E
and T individually (includingsmall cases e and t too).

Example:

If the file content is as follows:

Today is a pleasant day. It might


rain today.
It is mentioned on weather sites

The ETCount() function should display the output as:E or e: 6


T or t : 9
31. (a) Write the outputs of the SQL queries (i) to (iv) based on the relations Teacher and 2+1
Placement given below:
i. SELECT Department, avg(salary) FROM Teacher GROUP BY
Department;
ii. SELECT MAX(Date_of_Join),MIN(Date_of_Join) FROM
Teacher;
iii. SELECT Name, Salary, T.Department, Place FROM
Teacher T, Placement P WHERE T.Department =
P.Department AND Salary>20000;
iv. SELECT Name, Place FROM Teacher T, Placement P
WHERE Gender =’F’ AND T.Department=P.Department;
(b) Write the command to view all tables in a database.
SECTION D
32. (a) What will be the output of the following code? 2+2
x = 3
def myfunc():
global x
x+=2
print(x, end=' ')
print(x, end=' ')
myfunc()
print(x, end=' ')
(b)Consider the code given below
Import_______as sqltor
conn=sqltor.connect(host='localhost',user='john',password=''
,database='test')
cursor=_________________
query =__________________
cursor.execute(query)
data=______________
for row in data:
print(row)

The above code displays all details of students present in the table Student whose marks are
more than and grade is „B‟ using Python MySQL connectivity. Complete the missing code
by fill in the blanks.
33. (a) differentiate dump() and load() in the context of binaryfile. 2+2
(b) Write a Program in Python that defines and calls the following user defined functions:
i. add() – To accept and add data of a Product to a CSV file „Product.csv‟.Each record
consists of a list with field elements as pid, pname and price to store Product id,
Product name and Product price respectively.
ii. search()- To display the records of the Product whose price is more than 20000 and
product name starting with a vowel.
34. Write a program to create a Stack of Students containing 5 records each record structured as 4
[Roll, Name, Percentage of marks].Perform the following:
a) Display all the details of the Student who got the highest percentage of marks.
b) Insert a new Record to a Stack.
c) Remove the student details who scored less than 90% and display Stack.
35. A school wants to store its students' records in digital form. For this they want the 2+2
following information of each student to be stored:
- Student_ID – integer
- Student_Name – string
- Class – integer
- House – string

You, as a programmer, have been assigned to do this job for school.


1. Write a function to input the data of a student and append it in a binary file.
2. Write a function to update the data of student whose house is Ashoka and change
it to Raman.
SECTION E
36. Intelligent Hub India is a knowledge community aimed to uplift the standard of skills and 5
knowledge in the society. It is planning to setup its training centers in multiple towns and
villages of India with its head offices in the nearest cities. They have created a model of
their network with a city, a town and 3 villages as given. As a network consultant, you have
to suggest the best network related solution for their issues/problems raised in (a) to (e)
keeping in mind the distance between various locations and given parameters.
a) Suggest the most appropriate location of the SERVER in the YHUB (out of the 4
locations), to getthe best and effective connectivity. Justify your answer.
b) Suggest the best wired medium and draw the cable layout (location to location) to
efficientlyconnect various locations within the YHUB.
c) Which hardware device will you suggest to connect all the computers within each
location ofYHUB?
d) Which server/protocol will be most helpful to conduct live interaction of Experts
from Head officeand people at YHUB locations?
e) Suggest a device/software and its placement that would provide data security for the
entire networkof the YHUB.
37. You are working on a project that involves managing inventory records of a store in a 5
MySQL database. Your task is to create a Python program that performs the following
operations:

1. Connect to the MySQL database: Assume the database is named STOREDB, the
user is admin, and the password is admin123. The MySQL is available on a local
computer, not a remote computer.
2. Create a table: The table INVENTORY should have the following columns:
o ProductID (INTEGER, Primary Key, Auto Increment)
o ProductName (VARCHAR(100))
o Price (FLOAT(8,2))
o PurchaseDate (DATE)
3. Insert data into the table: Insert at least three records with sample data into the
INVENTORY table.
4. Retrieve and display all records: Write a Python function that retrieves all records
from the INVENTORY table and prints them in a readable format.

END
FIRST PRE BOARD EXAM (2024-25)
CLASS-XII
SUBJECT- COMPUTER SCIENCE(083)
MS12ACS01PB24
MARKING SCHEME
SECTION A
1. True 1
2. (d) real 1
3. (a) dict_exam.update(dict_result) 1
4. (a) True 1
5. (a) Year . 0. at All the best 1
6. (b) r+ 1
7. (c) alter 1
8. (b) DROP TABLE 1
9. (b) Statement 4 1
10. (b) Foreign Key 1
11. (a) file_object.seek(offset [, reference_point]) 1
12. (c ) DISTINCT 1
13. (a) VoIP 1
14. (a) 14.75 1
15. (c ) count(*) 1
16. (b) database 1
17. (a) Global scope 1
18. (d) All of the above 1
19. (a) Wide Area Network 1
20. (c ) A is True but R is False 1
21. (a) Both A and R are true and R is the correct explanation for A 1
SECTION B
22. def prime(): 2
n=int(input("Enter number to check :: ")) #bracket missing
for i in range (2, n//2):
if n%i==0: # = missing
print("Number is not prime \n")
break #wrong indent
else:
print("Number is prime \n”) # quote mismatch
(½ mark for each correct correction made and underlined.)
23. Circuit Switching Packet Switching 2
Circuit switching is a method of switching Packet switching is the method of
which is used for establishing a dedicated switching where no dedicated path is
path communication path between the established from the source to the
sender and the receiver destination
Data is processed and transmitted at the Data is processed and transmitted ,not only
source only. at the source but at each switching station.
It is more reliable. It is less reliable.
( 1 mark for each correct point of difference-Any two)

OR
XML(Extensible MarkupLangauge) HTML (Hypertext Markup Langauge)
XML tags are not predefined, they are user HTML tags are pre-defined and it is a
defined markup language
XML stores and transfers data. HTML is about displaying data.
Dynamic in nature Static in nature
(1 mark for each correct difference - Any two)
24. (a) @20 otnmx SC@ 1

(1 mark for the correct answer)

(b) dict_items([('name', 'Aman'), ('age', 27), ('address', 'Delhi')])


1
(1 mark for the correct answer)
25. 2
A foreign key is used to set or represent a relationship between two relations ( or tables) in a
database. Its value is derived from the primary key attribute of another relation.

For example:
In the tables TRAINER and COURSE given below, TID is primary key in TRAINER table
but foreign key in COURSE table.
TRAINER
TID TNAME CITY HIREDATE SALARY
101 Ritu Nagpur 1998-10-15 56700
102 Navin Goa 1994-12-24 80000
103 Murugan Chandigarh 2001-12-21 82000
104 Jyothi Guwahati 2002-12-25 68000
105 Chanu Mumbai 1996-01-12 95000
106 Arbaaz Delhi 2001-12-12 69000

COURSE

CID CNAME FEES STARTDATE TID


C201 Deepa 12000 1998-10-15 101
C202 Sindhu 15000 1994-12-24 103
C203 Neeraj 10000 2001-12-21 102
C204 Prakash 9000 2002-12-25 104
C205 Nikhat 20000 1996-01-12 101
(1 mark for explanation and 1 mark for example) ( Any relevant correct example may be
marked)
26. (a) Write the full forms of the following: 2
(i) SMTP: Simple Mail Transfer Protocol
(ii) PPP: Point to Point Protocol
(½ mark for every correct full form)

(b) TELNET is used to access a remote computer / network.


(1 mark for correct answer)
27. 22 # 40 # 9 # 13 # 2
(½ mark for the correct digit with a #)
OR

(22,44,66)

( ½ mark for each correct digit , ½ mark for enclosing in parenthesis)


28. COUNT(*) returns the count of all rows in the table, whereas COUNT () is used with 2
Column_Name passed as argument and counts the number of non-NULL values in a
column that is given as argument.
Example: Table : EMPL
EMPNO ENAME JOB SAL DEPTNO
8369 SMITH CLERK 2985 10
8499 ANYA NULL 9870 20
8566 AMIR SALESMAN 8760 30
8698 BINA MANAGER 5643 20
8912 SUR NULL 3000 10

e.g. SELECT COUNT(*) FROM EMPL;


output
Count(*)
5

e.g.2 SELECT COUNT(JOB) FROM EMPL;


Output
Count(JOB)
3
Since JOB has 2 NULL values
(1 mark for the difference and 1 mark for appropriate example)

OR

DDL- ALTER,
DROP DML –
INSERT, UPDATE
(½ mark for each correct categorization)

SECTION C
29. (a) output 1+2

Acode Name Type City


A01 Amrita Savings Delhi
A01 Amrita Savings Nagpur
A02 Parthodas Current Mumbai

(1 mark for correct output)


(b)Write the output of the queries (i) to (iv) based on the given table,
i. SELECT DISTINCT TID FROM TECH_COURSE;
DISTINCT ID
101
NULL
102
104
103
( ½ mark for the correct output)

ii. SELECT TID, COUNT(*), MIN(FEES) FROM TECH_COURSE GROUP BY TID


HAVING COUNT(TID)>1;
TID COUNT(*) MIN(FEES)
101 2 12000
( ½ mark for the correct output)

iii. SELECT CNAME FROM TECH_COURSE WHERE FEES>15000 ORDER BY


CNAME;
CNAME
Digital Marketing
Mobile application development
( ½ mark for the correct output)

iv. SELECT AVG(FEES) FROM TECH_COURSE WHERE FEES BETWEEN 15000


AND 17000;
15500.00
( ½ mark for the correct output)

30. def COUNTLINES() : 3


file = open ('TESTFILE.TXT', 'r') lines =
file.readlines()
count=0
for w in lines :
if (w[0]).lower() not in 'aeoiu' count = count
+1
print ("The number of lines not starting with any vowel: ", count)
file.close()
COUNTLINES()

( ½ mark for correctly opening and closing the file


½ for readlines()
½ mar for correct loop
½ for correct if statement
½ mark for correctly incrementing count
½ mark for displaying the correct output

OR

def ETCount():
file = open ('TESTFILE.TXT', 'r')
lines = file.readlines()
countE=0
countT=0
for w in lines :
for ch in w:
if ch in 'Ee':
countE = countE + 1
if ch in 'Tt':
countT=countT + 1
print ("The number of E or e : ", countE)
print ("The number of T or t : ", countT)
file.close()

(½ mark for correctly opening and closing the file


½ for readlines()
½ mark for correct loops
½ for correct if statement
½ mark for correctly incrementing counts
½ mark for displaying the correct output)
Note: Any other relevant and correct code may be marked
31. (a) Write the outputs of the SQL queries (i) to (iv) based on the relations Teacher and 2+1
Placement given below:
i. SELECT Department, avg(salary) FROM Teacher GROUP BY
Department;
Department Avg(Salary)
Computer Sc 16500.00
History 30000.00
Mathematics 25000.00
( ½ mark for the correct output)

ii. SELECT MAX(Date_of_Join),MIN(Date_of_Join) FROM


Teacher;
Max(Date_of_Join) Min(Date_of_Join)
2021-09-05 2017-03-04
( ½ mark for the correct output)

iii. SELECT Name, Salary, T.Department, Place FROM


Teacher T, Placement P WHERE T.Department =
P.Department AND Salary>20000;
Name Salary Department Place
Randeep 30000 Mathematics Jaipur
Samira 40000 History Ahmedabad
Raman 25000 Mathematics Jaipur
Shyam 30000 History Ahmedabad
Shiv 21000 Compuer Sc Nagpur
( ½ mark for the correct output)

iv. SELECT Name, Place FROM Teacher T, Placement P


WHERE Gender =’F’ AND T.Department=P.Department;
Name Place
Samira Ahmedabad
Suman Ahmedabad
Salaka Jaipur
( ½ mark for the correct output)

(b) Write the command to view all tables in a database.


SHOW TABLES;
( 1 mark for correct answer)
SECTION D
32. (a) 3 5 5 2+2
[1 marks for correct output]

(b)Consider the code given below


Import mysql.connector as sqltor
conn=sqltor.connect(host='localhost',user='john',password=''
,database='test')
cursor= conn.cursor()
query =”select * from student where marks>75 and grade=”B”
cursor.execute(query)
data= cur.fetchall()
for row in data:
print(row)

[0.5 mark each for first two fill in balcks and 1 mark each for last two]
33. (a) dump(object , file_handler) - used to write any object to the binary file. 1+3
Object=load(file_handler) - used to read object from the binary file.
[1 mark for correct answer]
(b)
import csv

def add():
l=[]
for i in range(4):
pid=input("Enter
pid")
pname=input("Enter
Pname")
price=int(input("Enter price
of product"))
p=[pid,pname,price]
l.append(p)
f=open("product.csv",'w',delimeter="
\n") w=csv.writer()
w.writerows
(l,f)
f.clsoe()

def search():
f=open("product.c
sv",'r')
r=csv.reader()
for i in r:
if i[2]>20000 and i[1][0] in
"AEIOUaeiou": print(*i)

add()
search()
[1.5 marks each for two functions]
34. DefST(s): 4
max=0 for i
in s:
if
i[2]>m
ax:
max=s[
2]
for i in s:
if
max==i[
2]:
print(*
s)

def push(s):
roll=int(input("Enter
roll number"))
name=input("Enter Name")
per=float(input("Enter
percentage"))
s.append([roll,name,per])
print("Status of stack
after push") for i in s:
print(*i)

def
remove(s
): for i
in s:
if
i[2]<
90:
print
(*i)

st=[] push(st)
push(st)
push(st) ST(st)
remove(st)
[1 mark each for each function and 1 mark for display]

35. i) def append_student_to_file(filename): 4


# Input student details
student_id = int(input("Enter Student_ID (integer):
"))
student_name = input("Enter Student_Name (string):
")
student_class = int(input("Enter Class (integer):
"))
house = input("Enter House (string): ")

# Create a tuple with student data


student_data = (student_id, student_name,
student_class, house)

# Open the file in append binary mode and write the


data
with open(filename, 'ab') as file:
pickle.dump(student_data, file)

print("Student data appended successfully.")


(2 marks for correct otherwise 1 marks for partially correct code)

ii) def update_student_house(filename, old_house,


new_house):
# Read all records from the binary file
records = []
with open(filename, 'rb') as file:
while True:
try:
record = pickle.load(file)
records.append(record)
except EOFError:
break

# Update the house name in the records


for i in range(len(records)):
if records[i][3] == old_house:
records[i] = (records[i][0], records[i][1],
records[i][2], new_house)

# Write updated records back to the file


with open(filename, 'wb') as file:
for record in records:
pickle.dump(record, file)

print(f"Updated house from {old_house} to


{new_house} successfully.")
(2 marks for correct otherwise 1 marks for partially correct code)

SECTION E
36. a) YTOWN as this has maximum number of computers. 5
b) Fiber optic cable as distance is in kms.
c) Swtich
d) VoIP
e) Firewall at YTOWN
(1 mark of each correct answer)
37. 1. Connecting to MySQL Database: 5

import mysql.connector

def connect_to_database():
try:
connection = mysql.connector.connect(
host='localhost',
user='admin',
password='admin123',
database='STOREDB'
)
return connection
except mysql.connector.Error as err:
print(f"Error: {err}")
return None

2. Creating the Table:

def create_table(connection):
cursor = connection.cursor()
cursor.execute("""
CREATE TABLE IF NOT EXISTS INVENTORY (
ProductID INT AUTO_INCREMENT PRIMARY KEY,
ProductName VARCHAR(100),
Price FLOAT(8,2),
PurchaseDate DATE
)
""")
connection.commit()

3. Inserting Data:

def insert_data(connection):
cursor = connection.cursor()
prooducts = [
('PRODUCT-1', 2500.30, '2022/02/12'),
('PRODUCT-2', 78000.00, '2023/12/02'),
('PRODUCT-3', 350.56, '2020/03/25')
]
cursor.executemany("INSERT INTO INVENTORY (ProductName,
Price, PurchaseDate) VALUES (%s, %s, %s)", products)
connection.commit()

4. Retrieving and Displaying Records:

def display_records(connection):
cursor = connection.cursor()
cursor.execute("SELECT * FROM INVENTORY")
results = cursor.fetchall()
for row in results:
print(f"ID: {row[0]}, Product: {row[1]}, Price:
{row[2]}, Purchased On: {row[3]}")

Execution:

def main():
connection = connect_to_database()
if connection:
create_table(connection)
insert_data(connection)
display_records(connection)
connection.close()

if __name__ == "__main__":
main()

(1 mark for each correct code)


END
KENDRIYA VIDYALAYA SANGATHAN:: REGIONAL OFFICE, BHOPAL
SESSION ENDING EXAMINATION: 2024-2025
CLASS-XII
Roll No.

COMPUTER SCIENCE (083)


Time allowed: 3 hours Maximum Marks: 70
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 the case of MCQ, the text of the correct answer should also be written.

SECTION-A
1. TRUE 1
2. a) True, False 1
3. a) True 1
4. a) 19 1
5. a) Welc. me t.rld 1
6. b) del D1["Red"] 1
7. c) r+ 1
8. a) ALTER 1
9. c) Statement 4 1
10. b) Day.pop(2) 1
11. b) length() 1
12. d) Remainder 1
13. b) len() 1
14. c) Foreign Key 1
15. a) Tuple 1
16. b) 6,20 1
17. d) Circuit Switching
18. a) SMTP, POP
19. a) 192.168.2.2

Page 1 of 8
20. (A) Both (A) and (R) are true and (R) is the correct explanation for (A).
21. (A) Both (A) and (R) are true and (R) is the correct explanation for (A).
SECTION-B
22. 1 Mark for correct difference 2
1/2 Mark for any one correct mutable object
[1,2]
{1:1,2:2}
1/2 Mark for any one correct Immutable object
(1,2)
‘123’
23. (i) L1.insert(2,200) 1 Mark for correct statement 2
(ii) message.endswith('.') 1 Mark for Correct statement
OR
import statistics 1 Mark for Correct import
print( statistics.mode(studentAge) ) 1 mark for correct statement
24. b) W#s# 2
25. This will produce an error 2
26. (i) Membership operator (IN) : 1 Mark for Correct operator and definition 2
(ii) Identity operator (IS) : 1 Mark for Correct operator and definition
27. A) 1 Mark for Correct advantage 2
1 Mark for Correct disadvantage.
OR
B) 1 Mark for Correct expansion- Hypertext Transfer Protocol
1 Mark for Correct difference:
HTTPS uses TLS (SSL) to encrypt normal HTTP requests and responses and to digitally
sign those requests and responses.
28. 2
A) 1 Mark for correct difference and 1 Mark for correct example.
OR
2
B) 1 Mark for correct explanation and 1 Mark for correct example
SECTION-C
29. 1 Marks for correct file opening and closing statement. 3
2 Marks for correct definition of function
OR
1 Marks for correct file opening and closing statement.
2 Marks for correct definition of function

Page 2 of 8
30. 3

OR
(B)
def push_even_numbers(N):
EvenNumbers = []
for num in N:
if num % 2 == 0:
EvenNumbers.append(num)
Return EvenNumbers
VALUES = []
for i in range(5):
VALUES.append(int(input("Enter an integer: ")))
EvenNumbers = push_even_numbers(VALUES)
def pop_even():
if not EvenNumbers:
print("Underflow")
else:
Page 3 of 8
print(EvenNumbers.pop())
pop_even()
def Disp_even():
if not EvenNumbers:
print("None")
else: print(EvenNumbers[-1])
Disp_even()
(1/2 for identifying even numbers)
(1/2 mark for correctly adding data to stack)
(1/2 mark for correctly poping data on the stack and 1/2 mark for checking condition)
(1/2 mark for correctly displaying the data with none)
(1/2 mark for function call statements)
31. Predict the output of the following code: 3
15@
15@
7@
15@
7@
9@
OR
Predict the output of the following code:
1 #2 #3 #
1 #2 #3 #
1#
SECTION-D
32. A) Write the following queries: 4
(i) select Product, sum(Quantity) from orders group by product having
sum(quantity)>=5;
(ii) select * from orders order by Price desc;
(iii) select distinct C_Name from orders;
(iv) select sum(price) as total_price from orders where Quantity IS NULL;
OR
C) Write the output:
(i) Select c_name, sum(quantity) as total_quantity from orders group by c_name;

(ii) Select * from orders where product like '%phone%';

Page 4 of 8
(iii) Select o_id, c_name, product, quantity, price from orders where the price between
1500 and 12000;

D) Select max(price) from orders;

33. Write the following Python functions to perform the specified operations on this file: 4
(i) Read all the data from the file in the form of a list and display records of all the
players, whose country is ‘India’. (2 Marks)
def show():
import csv
f=open("players.csv",'r')
records=csv.reader(f)
next(records, None) #To skip the Header row
for i in records:
if (i[3]=='India'):
print(i)
f.close()
(ii) Count the number of records in the file. (2 Marks)
def Count_records():
import csv
f=open("players.csv",'r')
records=csv.reader(f)
next(records, None) #To skip the Header row
count=0
for i in records:
count+=1
print(count)
f.close()
34. (i) To display those company names which have price less than 35000. 4
Page 5 of 8
SELECT C.NAME FROM COMPANY C, CUSTOMER CR WHERE C.CID=CR.CID AND
CR.PRICE < 35000;
(ii) To display the names of the companies in reverse alphabetical order.
SELECT NAME FROM COMPANY ORDER BY NAME DESC;
(iii) To increase the price by 1000 for those customers whose name starts with ‘S’
UPDATE CUSTOMER SET PRICE = PRICE + 1000 WHERE NAME LIKE ‘S%’;
(A) To add one more column totalprice with decimal(10,2) to the table customer.
ALTER TABLE CUSTOMER ADD TOTALPRICE DECIMAL(10,2);
OR
(B) To display the Cartesian Product of these two tables.
SELECT * FROM company CROSS JOIN customer;
(B) Cartesian Product: 9,24
35. 1 Mark for correct import SQL module and connection establishment- connect () 4
import mysql.connector as sqlcon
mycon=sqlcon.connect(host="localhost",user="root",passwd="tiger",database="exams")

a) RecordAttendance() function.1 ½ Marks (no mark deduction for exception handling)


def RecordAttendance():
rollno=input("Enter Roll Number:=")
sname=input("Enter Student Name=")
cname=input("Class=")
adate=input ("Date(in yyyy-mm-dd Format):")
att=input('Attendace:(P or A')
record=(rollno, sname,cname,adate,att)
if mycon.is_connected():
cursor=mycon.cursor()
sqlcmd="""insert into attendance values(%s,%s,%s,%s,%s)"""
cursor.execute(sqlcmd,record)
mycon.commit()
print("Record added Successfully.!!")
cursor.close()
mycon.close()
else:
print("Unable to setup Connection to Database Successful:")

b) DisplayAttendance() Function 1 ½ Marks (no mark deduction for exception handling)


def DisplayAttendance():
adate=input ("Date(in yyyy-mm-dd Format):")
data=(adate)
if mycon.is_connected():
cursor=mycon.cursor()
sqlcmd="""select * from attendance where attendDate = %s"""
cursor.execute(sqlcmd,data)
resultset=cursor.fetchone()

Page 6 of 8
for row in resultset:
print(row)
cursor.close()
mycon.close()
else:
print("Unable to Fetch Attendance!")

36. (i) 2 Mark for correct definition of emp_data( ) function. 5


import pickle
def emp_data():
emp = []
n = int(input("Enter the number of emploeyees You want to add: "))
for i in range(n):
emp_code= int(input("Enter Employee Code: "))
emp_name = input("Enter Employee Name: ")
salary = float(input("Enter Salary: "))
deductions = float(input("Enter Deduction Amount: "))
emp.append([emp_code,emp_name,salary,deductions])
return emp
emp_list = emp_data()
def append_emp(employees):
with open('employees.bin', 'ab') as file:
for empl in employees:
pickle.dump(empl, file)
print("Candidate data appended successfully.")
(ii) 2 Mark for correct definition of cal_salary() function.
import pickle
def cal_salary():
empl=[]
updated_salary = []
with open('employees.bin', 'rb') as file:
while True:
empl = pickle.load(file)
if empl[3] > 0:
empl[2] =empl[2]-empl[3]
updated_salary.append(empl)

with open('employees.bin', 'wb') as file:


for emp in updated_salary:
pickle.dump(emp, file)
print("Salary updated.")
(iii) 1 Mark for correct definition of function
import pickle
def display_record():
Page 7 of 8
with open('employees.bin', 'rb') as file:
while True:
emp = pickle.load(file)
if emp[3] >5000: # Check if not Senior Manager
print(f"Employee Code: {emp[0]}")
print(f"Employee Name: {emp[1]}")
print(f"Salary: {emp[2]}")
print(f"Deductions: {emp[3]}")
print("--------------------")
display_record()
37. (i) ADMIN Block as it has the most number of computers installed. 5
(ii) Switch
(iii) Network Layout
Management Law

Medicine

Admin

(iv) Ethernet Cable


(v) A) Repeater may be required between Management Block and Law Block as distance
is more than 100 metres.
OR
B) LAN

Page 8 of 8
Kendriya Vidyalaya Sangathan, Jaipur Region
PRACTICE PAPER-III
Class: XII Subject: Computer Science (083)
Maximum Marks: 70 Period: 3 Hours
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 the case of MCQ, the text of the correct answer should also be written.

Q. Section-A (21 x 1 = 21 Marks) Mark


1 State True or False: 1
Exception is a compile time error.
2 Identify the output of the following code snippet 1
text = “Comma(,) is a punctuator”
text = text.split(‘,’)
print(text)
a) [ ‘Comma(,)’, ‘is’, ‘a’, ‘punctuator’ ] b) [ ‘Comma(’, ‘) is a punctuator’ ]
c) [ ‘Comma(‘, ‘,’, ‘) is a punctuator’ ] d) Error
3 Which of the following expressions evaluates to True 1
a) False or not False and False b) False and not False or False
c) True or not True and False d) True and not True or not True
4 What is the output of the following code snippet? 1
‘CS’.join(‘IP’)
a) 'ICSP' b) 'CIPS' c) 'IPCIPSIP' d) 'CSICSPCS'
5 What will be the output of the following code? 1
msg = ‘Transcendental’
print(msg[ 10 : -10 : -2 ])
a) 'nde' b) 'ndesaTltenc' c) '' d) error
6 Which statement(s) will result in error? 1
t1=(11,22,33)
t2=(44,) #statement1
t2+=t1 #statement2
t4=t1*2+t2*2 #statement3
t4[0]=45 #statement4
a) statement 4 b) statement 2&4 c) statement 3&4 d) All
7 Which statement will result in error 1
item={‘Cake’:20, ‘Pastry’:30, ‘Burger’:15}
a) item[‘Patties’]=30 b) item.update((‘Patties’,30))
c) item.update({‘Patties’:30}) d) item.setdefault(‘Patties’,30)
8 What does list.pop(x) method do in Python? 1
a) removes and return element x
b) removes first occurrence of element x
c) removes and return element at index x
d) only returns element at index x but does not remove it
9 If a table has 5 Candidate keys then it will have___ Primary keys and ___Alternate 1
keys
a) 1,5 b) 1,1 c) 1,4 d) 4,1
10 Write the missing statement to complete the following code: 1
file = open(‘story.txt’, ‘r+’)
data = file.read(5)
________# Move the file pointer to the end of the file
file.write(‘End’)
file.close()
11 State whether the following statement is True or False: 1
There can be more than one except blocks.
12 What will be the output of the following code? 1
a=5
def fn( ):
global a
a=5
print(a, end = “ ”)
fn()
print(a)
a) 5 error b) 5 5 c) error d) None of the above
13 Which SQL command can be used to set a default value to a column in table? 1
14 What will be the output of the query? 1
SELECT * FROM employees WHERE employee_name LIKE ‘%aa%’ ;
a) Details of all employees with two a’s only in the start of the name.
b) Details of all employees with two a’s only at the end of the name.
c) Details of all employees with two a’s anywhere in the name.
d) Details of all employees with two a’s together only in the name.
15 Literals of which SQL data type are enclosed in quotes? 1
a) Char & Varchar b) Float c) Date d) (a) & (c)
16 What will be the output of following query for the given table named Sports: 1
SELECT AVG(Price) FROM Sports;
Item Price
Football 1000
Volleyball 900
BasketBall 950
Tennis Ball NULL
a) 950 b) 712.5 c) NULL d) Error
17 Which protocol allows users to download emails from a server to a client? 1
a) SMTP b) POP3 c) TELNET d) PPP
18 Which Network device is used to convert Digital signals to Analog signals at 1
sender’s end and convert Analog signals to Digital signals at receiver’s end.
a) Repeater b) Gateway c) Router d) Modem
19 Which switching technique ensures a continuous, reliable connection for the 1
duration of the communication session, uses all the bandwidth of the
transmission channel and doesn’t share it unless the duration of communication
session is over.
Q20 and Q21 are Assertion(A) and Reason(R) 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
20 Assertion (A) : The order of Actual Arguments must conform with order of Formal 1
Parameters in case of Positional Arguments
Reasoning (R): Default Parameters should be written in rightmost side of function
declaration and no non-Default parameter should follow it.
21 Assertion (A) :In SELECT command of SQL order of WHERE and HAVING 1
clause is interchangeable.
Reasoning (R):WHERE clauseworks before aggregation of data and HAVING
clause works after aggregation of data.

Q Section-B ( 7 x 2=14 Marks) Mark


22 Which of the following statement will result in error and why? 2
s = “God is almighty”
s1 = s[0] + s[1]
s[0] = ‘g’
23 Write following type of operators as per the order of Precedence Table for Python. 2
(i) Arithmetic operators (ii) Logical operators
24 If A = [10,20,40,10,30,20] and B = [1,7,3,4,8,6,5,9] then answer the following 2
using built-in methods/functions only
(i)
(A) Write a statement to count the occurrences of 10 in A.
OR
(B) Write a statement to arrange the elements of A in ascending order.
(ii)
(A) Write a statement to add all the elements of B at the end of A.
OR
(B) Write a statement to reverse the elements of B.
25 Identify the correct output(s) of the following code. Also write the minimum and the 2
maximum possible values of the variable r.
import random
l=[10,20,30,40,50,60,70]
p=random.randint(3,5)
q=random.randint(5,6)
r=p-2
s=q+1
for i in range(r,s):
print(l[i],end="#")
a) 30#40#50#60#70# b) 20#30#40#50#
c) 30#40#50# d) 40#50#60#
26 The code provided below is intended to shift the elements to the left by n times of 2
a tuple t. However, there are syntax and logical errors in the code. Rewrite it after
removing all errors. Underline all the corrections made.
deflshift(t,n):
n=n%len(t)
t=t[n:]+t[:n+1]
return t

newt=lshift((1,2,3,4,5,6),13)
print(newt)
Sample example :
lshift((6,7,8,9),2) should give the output (8,9,6,7)
27 (i) 2
(A) What constraint should be applied on a column of a table so that there cannot
be NULL value except for only one row
OR
(B) What constraint should be applied on a column of a table so that a predefined
value is assigned if no value is provided by the user.
(ii)
(A) Write an SQL command to remove the Primary Key constraint from a table,
named STUDENT. Adm_No is the primary key of the table.
OR
(B) Write an SQL command to make the column Rno the Primary Key of an
already existing table named STUDENT.
28 A) List one advantage and one disadvantage of Tree topology. 2
OR
B) Expand the term TELNET. What is the use of TELNET?

Q Section-C ( 3 x 3 = 9 Marks) Mark


29 (A) Write a Python functiongovWeb() that displays all the words containing 3
gov.in from a text file “URLs.txt”
OR
(B) Write a Python function atleast5() that finds and displays all the words
having at least 5 characters from a text file “Story.txt”.
30 (A) You have a stack named StarStudents that contains records of students. 3
Each student record is represented as a dictionary {‘name’: ____, ‘marks’:
____}Write the following user-defined functions in Python to perform the specified
operations on the stack StarStudents:
(i) push_star(StarStudent, AllStudents): This function takes two arguments
the stack StarStudent and a list of dictionaries named AllStudents
containing details of all students in the format [{‘name’: “Ajay”, ‘marks’:
95},{‘name’: “Shambhu”, ‘marks’: 100},…..]and pushes records of only those
students who has scored more than 90.
(ii) pop_star(StarStudent): This function takes the stack StarStudent as
argument and pops the topmost student record from the stack and returns
it. If the stack is already empty, the function should display “Underflow”.
(iii) peek_star(StarStudent): This function takes the stack StarStudent as
argument and displays the topmost element of the stack without deleting it.
If the stack is empty, the function should display “None”.
OR
(B) Write the definition for the following user defined functions
(i) push_positive(N): This function takes a list of integers as parameter ‘N’ and
pushes all positive integers into a Stack named ‘pos_int’ defined in global
scope.
(ii) pop_positive(): This function pops the topmost number from the stack
‘pos_int’ defined in global scope and returns it. If the stack is already empty,
the function should display “Empty”.
(iii) disp_positive(): This function displays all the elements of the stack
‘pos_int’ defined in global scope without deleting them. If the stack is empty,
the function should display “None”.
For example:
If the integers in the list N are:
[ -3, 7, -5, 9, 0 ]
Then the stack pos_int should store:
[7, 9, 0]
and disp_positive() should display:
7 9 0 None
31 Predict the output of the following code: 3
d = { ‘Shoes’ : 10, ‘Gloves’ : 20, ‘Jackets’ : 15 }
s = “”
for k in d:
s = s + k + str(d[k]) + “#” + “\n”
sn = s[:-1]
print(sn)
OR
Predict the output of the following code:
squares=[1,4,9,16,25,36]
for i in squares:
for j in range(i%7,0,-1):
print(j,'#',end=' ')
print()

Q Section-D ( 4 x 4 = 16 Marks) Mark


32 Consider the table EVENTS as given below 4
E_Id E_name Manager Price Capacity
1001 Birthday Prateek 3000 30
1002 Anniversary Manoj 15000 50
1003 Reception Shivansh 25000 NULL
1004 Birthday Prem 3500 35
A) Write the following queries:
i) To display the total Price for each event, excluding events with total Price less
than 100000
ii) To display the EVENTS table sorted by Capacity in descending order.
iii) To display the distinct event names from the EVENTS table.
iv) Display the sum of Price of all the events for which the capacity is not
known.
OR
B) Write the output
i) Select E_name, sum(price) as total_price from events group by e_name;
ii) Select Manager from events where manager like ‘%a%’;
iii)Select e_id, Price from events where price between 1500 and 12000 ;
iv)Select max(price) from events;

33 A csv file “Employment.csv” contains the data of a survey. Each record of the file 4
contains the following data:
• Name of a state
• Population of the state
• Sample size (Number of persons who participated in the survey in that
state)
• Employed (Number of persons employed)

For example, a sample record of the file may be:


[ ‘Rajasthan’, 5674933, 10000, 5679]

Write the following Python functions to perform the specified operations on this file:
(i) Read all the data from the file in the form of a list and display all those records
for which the population is more than 5000000.
(ii) Count the number of records in the file.
34 Manan has been entrusted with the management of ABC School database. He 4
needs to access some information from STUDENT and CLUB tables for a survey
analysis. Help him extract the following information by writing the desired SQL
queries as mentioned below:
Table :STUDENT
Rno Name DateOfBirth Gender Marks ClubId
1 Amit 15-11-2008 M 98 101
2 Divya 27-10-2008 F 78 102
3 Harsh 13-05-2009 M 90 101
4 Manjeet 16-07-2009 M 86 103
5 Aruna 07-08-2009 F 70 102
6 Dinesh 01-03-2009 M 67 103
Table :CLUB
ClubId Cname Fees
101 Eco 300
102 Cyber 500
103 Excursion 700

(i) To display complete details (from both the tables) of those whose marks is
less than 80
(ii) To display the details of those clubs, fees of which is in the range of 400 to
700 (both values included).
(iii) To increase the fees of all clubs by 200 which have ‘o’ in their club name.
(iv) (a) To display Name and Marks of student in Cyber club.
OR
(b) To display the Cartesian Product of these two tables without repeating
ClubId column.
35 A table, named INVENTORY, in SHOP database, has the following structure: 4
Field Type
itemNo int
itemName varchar(15)
price float
qty int
Write the following Python function to perform the specified operation:

addRec(): To input details of an item and store it in the table INVENTORY. The
function should then retrieve and display all records from the INVENTORY table
where the price is greater than 150.

Assume the following for Python-Database connectivity:


Host: localhost, User: root, Password: Chetan

Q Section-E ( 2 x 5 = 10 Marks) Mark


36 Gyandev is manager in an educational institute. He needs to manage the records 5
of various candidates. For this, he wants the following information of each
candidate to be stored in a list:
- Candidate_id – integer
- Cadidate_name – string
- Class – string
- Status – string
You, as a programmer of the institute, have been assigned to do this job for
Gyandev.
(i) Write a function addBin() to input the data of a candidate, create a list of it and
append it in a binary file named “Students.dat”.
(ii) Write a function promoteBin() to change the status to “passed out” for those
students whose class is “XII”
(iii) Write a function activeBin() to read the data from the binary file and display
the data of all those candidates who are not “passed out”.
37 Advent Infotech is planning to set up it India campus in Jaipur with its head 5
office in Delhi. The Jaipur campus will have four blocks/buildings – ADMIN,
FINANCE, SALES and HR. You, as a network expert, need to suggest the best
network-related solutions for them to resolve the issues/problems mention in
points (i) to (v), keepin in mid the distances between various block/buildings and
other given parameters.
Delhi Jaipur
Campus
Head FINANCE
Office
ADMIN SALES

HR

Block to Block distances (in Mtrs)


From To Dista Block No of
nce computers
ADMIN FINANCE 35m ADMIN 120
ADMIN SALES 110m FINANCE 10
ADMIN HR 50m SALES 50
FINANCE SALES 65m HR 30
FINANCE HR 85m
SALES HR 70m
Delhi Jaipur 310
Head Campus Km
Office
a) Draw the cable layout to efficiently connect various blocks of buildings within
the Jaipur campus. Which cable would you suggest for the most efficient data
transfer over the network?
b) Suggest the most appropriate location of the server inside the Jaipur campus.
Justify your choice.
c) Suggest the placement of following devices:
i) Switch/hub
ii) Repeater
d) Which cost efficient wired medium should be used to connect the computers
in Jaipur campus?
e) a )Which type of network is formed by connecting Delhi Head Office with
Jaipur Campus?
OR
b) What would be your recommendation for enabling live visual
communication between the Admin Office at the Jaipur Campurs and
Delhi Head Office from the following options:
(i) Video Conferencing (ii) Email (iii) Telephony (iv) Instant Messaging
Kendriya Vidyalaya Sangathan, Jaipur Region
Practice paper-3
Class: XII Subject: Computer Science (083)
Maximum Marks: 70 Period: 3 Hours

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 the case of MCQ, the text of the correct answer should also be written.

Q. Section-A (21 x 1 = 21 Marks) Mark


1 False 1
2 b) [ ‘Comma(’, ‘) is a punctuator’ ] 1
3 c) True or not True and False 1
4 a) 'ICSP' 1
5 a) 'nde' 1
6 a) statement 4 1
7 b) item.update((‘Patties’,30)) 1
8 c) removes and return element at index x 1
9 c) 1,4 1
10 file.seek(0,2) 1
11 True 1
12 b) 5 5 1
13 Alter command 1
14 d) Details of all employees with two a’s together only in the name. 1
15 d) (a) & (c) 1
16 a) 950 1
17 b) POP3 1
18 d) Modem 1
19 Circuit Switching 1
Q20 and Q21 are Assertion(A) and Reason(R) 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
20 (B) Both A and R are true and R is not the correct explanation for A 1
21 (D) A is False but R is True 1

Q Section-B ( 7 x 2=14 Marks) Mark


22 s[0] = ‘g’ will result in error because string is immutable data type and does not 2
support item assignment.
23 Type Operator 2
**
Arithmetic
/ // % *
+-
not
Logical and
or
24 (i) 2
(A) A.count(10)
OR
(B) A.sort()
(ii)
(A) A.extend(B)
OR
(B) B.sort(reverse=True)
(1 mark each)
25 Minimum value of r – 1 2
Maximum value of r – 3
a) 30#40#50#60#70#
d) 40#50#60#
(1/2 mark each for min and max value & ½ mark each for correct output)
26 def lshift(t,n): 2
n=n%len(t)
t=t[n:]+t[:n] # n in place of n+1
return t # return indentation is removed

newt=lshift((1,2,3,4,5,6),13)
print(newt)
(1 mark for each correction)
27 (i) 2
(A) Unique
OR
(B) Default
(ii)
(A) ALTER TABLE STUDENT DROP PRIMARY KEY;
OR
(B) ALTER TABLE STUDENT ADD PRIMARY KEY(RNO);
(1 mark each)
28 Advantage: 2
Hierarchical connection between the nodes.
Disadvantage:
Less reliable than star and mesh.
(1 mark each)
OR
TELNET : Teletype Network Telnet is a network protocol used to virtually access a
computer and provide a two-way, collaborative and text-based communication
channel between two machines. It follows a user command TCP/IP networking
protocol that creates remote sessions.
(1 mark for expansion and 1 mark for use)

Q Section-C ( 3 x 3 = 9 Marks) Mark


29 (A) 3
def govWeb():
f=open("URLs.txt", 'r')
data=f.read()
low=data.split()
for w in low:
if 'gov.in' in w:
print(w)
f.close()
(1/2 mark for correct function definition)
(1/2 mark for opening file)
(1/2 mark for reading data)
(1/2 mark for correct iteration)
(1/2 mark for correct if )
(1/2 mark for correct print)
OR
(B)
def atleast5():
f=open("Story.txt", 'r')
data=f.read()
low=data.split()
for w in low:
if len(w)>=5:
print(w)
f.close()
(1/2 mark for correct function definition)
(1/2 mark for opening file)
(1/2 mark for reading data)
(1/2 mark for correct iteration)
(1/2 mark for correct if )
(1/2 mark for correct print)
30 (A) 3
def push_star(StarStudent, AllStudents):
for i in AllStudents:
if i['marks']>90:
StarStudent.append(i)

def pop_star(StarStudent):
if StarStudent:
return StarStudent.pop()
else:
print("Underflow")

def peek_star(StarStudent):
if StarStudent:
return StarStudent[-1]
else:
print("None")
(1 mark for each correct function definition)
OR
(B)
pos_int=[ ]
def push_positive(N):
for i in N:
if i>0:
pos_int.append(i)

def pop_positive():
if pos_int:
return pos_int.pop()
else:
print("Empty")

def disp_positive():
for i in range(-len(pos_int),0,-1):
print(pos_int[i], end=“ ”)
else:
print("None")
(1 mark for each correct function definition)
31 Shoes10# 3
Gloves20#
Jackets15#
(1 mark for each correct output)
OR
1#
4# 3# 2# 1#
2# 1#
2# 1#
4# 3# 2# 1#
1#
(1/2 mark for each correct output)

Q Section-D ( 4 x 4 = 16 Marks) Mark


32 (A) 4
(i) SELECT SUM(PRICE) FROM EVENTS GROUP BY E_NAME HAVING
SUM(PRICE) < 100000;
(ii) SELECT * FROM EVENTS ORDER BY CAPACITY DESC;
(iii) SELECT DISTINCT(E_NAME) FROM EVENTS;
(iv) SELECT SUM(PRICE) FROM EVENTS WHERE CAPACITY IS NOT NULL
(1 mark for each correct query, ½ for partially correct)
OR
(B)
(i)
E_name sum(price)
Birthday 6500
Anniversary 15000
Reception 25000
(ii)
Manager
Prateek
Manoj
Shivansh
(iii)
e_id Price
1001 3000
1004 3500
(iv)
max(price)
25000
(1 mark for each correct output, ½ for partially correct)
33 CSV file based question 4
(i)
import csv
f=open("Employment.csv")
ro=csv.reader(f)
for rec in ro:
if rec[1]>5000000:
print(rec)
(1/2 mark for correct file opening)
(1/2 mark for reader object)
(1/2 mark for reading data)
(1/2 mark for correct if and print)
(ii)
import csv
f=open("Employment.csv")
ro=csv.reader(f)
l=list(ro)
print("no. of records = ", len(l))
(1/2 mark for correct file opening)
(1/2 mark for reader object)
(1/2 mark for reading data)
(1/2 mark for correct print)
34 (i) SELECT * FROM STUDENT, CLUB WHERE MARKS<80 AND 4
STUDENT.CLUBID = CLUB.CLUBID;
(ii) SELECT * FROM CLUB WHERE FEES BETWEEN 400 AND 700;
(iii) UPDATE CLUB SET FEES=FEES+200 WHERE CNAME LIKE ‘%O’;
(iv) SELECT NAME, MARKS FROM STUDENT, CLUB WHERE CNAME=’CYBER’
AND STUDENT.CLUBID = CLUB.CLUBID;
OR
SELECT * FROM STUDENT NATURAL JOIN CLUB;
(1 mark for correct query)
35 def addRec(): 4
import mysql.connector as m
con=m.connect(host='localhost', user='root', passwd='Chetan',
database='SHOP')
cur=con.cursor()
ino=int(input("Enter item no."))
iname=input("Enter item name")
p=float(input("Enter price"))
q=int(input("Enter quantity"))
cur.execute("insert into inventory values(%s,%s,%s,%s)", [ino,iname,p,q])
con.commit()
cur.execute("select * from inventory where price>150")
for rec in cur.fetchall():
print(rec)
(1/2 mark for correct connection)
(1/2 mark for cursor)
(1/2 mark for correct intput)
(1/2 mark for correct insert query execution)
(1/2 mark for commit)
(1/2 mark for correct select query execution)
(1/2 mark for correct fetch and iteration)
(1/2 mark for correct print)

Q Section-E ( 2 x 5 = 10 Marks) Mark


36 def addBin(): 5
import pickle
f=open('Students.dat', 'ab')
cid=int(input("Enter candidate id :"))
cname=input("Enter candidate name")
c=input("Enter class")
s=input("Enter status(active/passed out)")
pickle.dumpt([cid,cname,c,s],f)
f.close()
(1/2 mark for correct file open)
(1/2 mark for correct input)
(1/2 mark for correct dump)
def promoteBin():
import pickle
f=open('Students.dat', 'rb+')
try:
while True:
p=f.tell()
d=pickle.load(f)
if d[2]=='xii':
d[3]='passed out'
f.seek(p)
pickle.dump(d,f)
except:
f.close()
(1/2 mark for correct file open)
(1/2 mark for correct iteration and read)
(1/2 mark for correct if and modification)
(1/2 mark for correct seek and dump)
def activeBin():
import pickle
f=open('Students.dat', 'rb')
try:
while True:
d=pickle.load(f)
if d[3]!='passed out':
print(d)
except:
f.close()
(1/2 mark for correct file open)
(1/2 mark for correct iteration and read)
(1/2 mark for correct if and print)
37 (a) Star with ADMIN as center 5
(b) ADMIN block due to maximum number of computers in any block because
of which most of the traffic will be local.
(c) i) Switch/Hub: In every block which has more than 1 device to interconnect
them
ii) Repeater: Between ADMIN and SALES to regenerate the weak signal as
distance is over 80m
(d) Ethernet cable
(e) a) WAN
OR
b) (i) Video conferencing
(1 mark for each correct answer)
Kendriya Vidyalaya Sangathan, Jaipur Region
PRACTICE PAPER-4
Question Paper
Class: XII Subject: Computer Science (083)
Maximum Marks: 70 Period: 3 Hours
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 the case of MCQ, the text of the correct answer should also be written.

Q. Section-A (21 x 1 = 21 Marks) Mark


1 State True/False: The python expression 3.2+2 is evaluated as 3*2+2 1
2 Observe and find output of the following python code: 1
str1 = "Python"
str2 = "Programming"
print(str1[:2] + str2[-4:])
a. Pyming b. Pythming c. Pyogramming d. Pythonming
3 Evaluate the following expression and find correct value of y: 1
y = 3 * 4 + 2**3 // 2 - (7 % 3)
4 What will be the output of following python code: 1
s = 'Programming'
print(s.split("m"))
a. ['Progra', '', 'ing'] b. ['Progra', 'ing']
c. ['Progra', 'm', 'ing'] d. ['Progra', 'ming']
5 What will be the output of following python code: 1
s = “yoBananaBoy”
print(s[: :-1 ])
6 What will be the output of following python code: 1
t1 = 1,2,3
t2 = (1,2,3)
print(t1 is t2)
a. True b. 1 c. False d. 0
7 What would the following code print: 1
fruits = {'apple': 5, 'banana': 3, 'orange': 2, 'grape': 4}
print(fruits.get('mango'))
a. 0 b. None c. Error d. 5

Page 1 of 7
8 Consider the given list L: 1
L = list('All is well in ')
What python code should be written for inserting the word 'Havana' at the end of
the list as separate characters?
a. L.extend('Havana') b. L.append(list('Havana'))
c. both a and b d. None of the above
9 What will be the output of following python code: 1
l2= [1,2,3,'[4,5]']
print(type(l2[-1]))
a. error b. <class ‘list’> c. <class ‘string> d. <class ‘NoneType’>
10 Suppose the content of a text file xyz.txt is as follows: 1
"The best way to Predict the future is to create it."
What will be the output of the following python code?
f = open("xyz.txt")
f.seek(17)
s = f.read(7)
print(s)
f.close()
a. Predict b. The best way to
c. predict the d. to predict the future
11 In Python exception handling, the finally block is executed regardless of whether an 1
exception occurs or not. (True/False)
12 def func(a, b, c=3, d=4): 1
pass
Identify the keyword and positional arguments in the function given above:
a) a and b are positional arguments; c and d are keyword arguments
b) a, b, c, and d are all positional arguments
c) a, b, c, and d are all keyword arguments
d) a, b, and c are positional arguments; d is a keyword argument
13 What is the output of following SQL statement? 1
SELECT Department, COUNT(*) FROM employees
WHERE Salary > 50000 GROUP BY Department;
a. The total number of employees in each department
b. The departments with employees earning over 50,000 and the count of such
employees in each department
c. The departments with average salary over 50,000 and their total number of
employees
d. The number of departments with employees earning over 50,000
14 Consider a table named 'Products' with columns 'product_id', 'product_name', and 1
'category'. Which of the following SQL queries will retrieve all products that are not
in the categories 'Electronics' or 'Furniture'?
a. SELECT product_id, product_name FROM Products
WHERE category NOT IN ('Electronics', 'Furniture');
b. SELECT product_id, product_name FROM Products
WHERE category NOT IN 'Electronics', 'Furniture';
c. SELECT product_id, product_name FROM Products
WHERE category != 'Electronics' AND != 'Furniture';
d. SELECT product_id, product_name FROM Products
WHERE category NOT LIKE ('Electronics', 'Furniture');
15 In MySQL, which command does not change the cardinality of a relation? 1
a. ALTER b. INSERT c. DELETE d. None of these

Page 2 of 7
16 Sita is creating a table for her project. She wants that a particular column always 1
has a unique value. Which constraint should she use?
a. DISTINCT b. UNIQUE c. NOT NULL d. DEFAULT
17 Which of the following is a network protocol? 1
a. Firewall b. HTTP c. Modem d. Switch
18 The Router in a network primarily functions as a __________. 1
a. Converter b. Traffic director c. Amplifier d. Modulato
19 Write the full form of the following: (i) FTP (ii) DNS 1
Q20 and Q21 are Assertion(A) and Reason(R) 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
20 Assertion: Assertion: In Python, a function can return multiple values. 1
Reason: Python functions can return tuples, which can be unpacked into multiple
variables.
21 Assertion: The FOREIGN KEY constraint is used to establish links between tables. 1
Reason: A FOREIGN KEY in one table points to a FOREIGN KEY in another table.

Q Section-B ( 7 x 2=14 Marks) Mark


22 Mark the valid and invalid identifiers in Python from the below options: 2
myVariable, 1st_try, for, _total_sum
23 Rohan is writing a Python program to determine if a year is a leap year. He has 2
written a program, but it's not working correctly. Help him rewrite the code,
underlining the changes.
year = input("Enter a year: ")
if year % 100 == 0:
if year % 400 ==0:
print(year, "is a century and leap year")
else:
print(year,"is a century year but not leap year")
else if year%4==0:
print(year, "is a leap year")
else:
print(year, "is not a leap year")
24 (A) Write a Python program to find the largest and smallest numbers from a list. 2
Assume the list is given as [55, 12, 98, 34, 76, 1, 88].
OR
(B) Write a Python program to check if a string is a palindrome (reads the same
backward as forward). The string should be entered by the user.
25 Identify the correct output(s) of the following code from the choices i to iv. Write 2
incorrect choice. Also specify the maximum values that can be assigned to each
of the variables start and end.
import random
numbers = [10, 20, 30, 40, 50, 60]
start = random.randint(0, 2)
end = random.randint(3, 4)
for i in range(start, end):
print(numbers[i], end=", ")
(i) 10, 20, 30, (ii) 30, 40, (iii) 20, 30, 40, (iv) 40, 50,
Page 3 of 7
26 Define the following in context of MYSQL: (i) Tuple (ii) Cardinality 2
27 (A) Write difference between DISTINCT and GROUP BY clause of SQL. 2
OR
(B) What is the difference in INT and FLOAT?
28 Differentiate between Coaxial Cable and Optical Fiber. 2
OR
What is the use of the following devices?
(i) Modem (ii) Repeater

Q Section-C ( 3 x 3 = 9 Marks) Mark


29 (A) Write a Python function count_vowels() that reads text from a file named 3
"input.txt" and counts the number of vowels (a, e, i, o, u) in the file. The function
should return the vowel count.
OR
(B) Write a Python function longest_word() that reads text from a file "words.txt"
and returns the longest word in the file.
30 (A) A website uses a stack to manage recently viewed products. Each product is represented as 3
a tuple: (product_id, product_name, price). Write the following Python functions to manage
this RecentlyViewed stack:
(I) add_product(RecentlyViewed, new_product): This function adds a new product tuple to the
top of the RecentlyViewed stack.
(II) remove_product(RecentlyViewed): This function removes and returns the most recently
viewed product from the stack. If the stack is empty, it should print "No products recently
viewed."
(III) show_latest_product(RecentlyViewed): This function displays the most recently viewed
product without removing it. If the stack is empty, it should print "No products recently
viewed."
OR
(B)
A hospital is managing patient data using a stack-based system. Patient records
are initially stored in a list. Each record is a tuple containing (patient_id, age,
priority_level). Priority levels are integers, with higher numbers representing
higher priority.
(I) Create a list named patients containing the following patient records:
(101, 65, 2), (102, 32, 4), (103, 78, 1), (104, 45, 3), (105, 52, 5), (106, 28, 2)
(II) Write the definition of a user-defined function push_high_priority(patients,
priority_threshold). It should push only those patient records with a priority level
greater than or equal to the priority_threshold onto a stack called
high_priority_patients.
(III) Write a function get_high_priority() to display all elements of the
high_priority_patients stack while deleting them one by one. If the stack is empty,
the function should display No high-priority patients.

Page 4 of 7
Observe the table Students and write query for (i) to (iii): 3
31 Table: Faculty
F_ID FName LName Department Gender Hire_Date Salary
102 Ibomcha Thounaojam Exam M 10/02/2020 75000
103 Shantanu Fernandes Exam M 11/01/2015 120000
104 Tashi Dorjey ICT F 14/03/2023 50000
105 Bhanwar Singh ICT M 13/12/2019 80000
106 Kanta Kumari HOD F 11/01/2024 140000
(A)
(i) Display Gender wise number of faculties who earn more than 85000.
(ii) Display all data separated by Department and in decreasing order of Salary.
(iii) Display FName and F_ID of faculties from ICT department.
OR
(B)
(i) Display Gender wise average salary of those faculties with average salary
more than 90000.
(ii) Display FName and F_ID of faculties having the string ‘ta’ in the Fname.
(iii) Change data of table to award 5% annual increment in salary.

Q Section-D ( 4 x 4 = 16 Marks) Mark


32 (A) Explain the difference between the `'a'` and `'x'` file opening modes in Python. 4
(B) Observe the following code and predict the output of (i), (ii), and (iii):
def process_data(data):
try:
value = int(data)
if value > 100:
print("Value is greater than 100.")
else:
print("Value is not greater than 100.")
except ValueError:
print("Invalid input: Not an integer.")
finally:
print("Data processing complete.")
(i) process_data(150)
(ii) process_data("abc")
(iii) process_data(50)
33 A librarian is managing book inventory using a CSV file named `Inventory.csv`. 4
The file structure is: `[BookID, Title, Author, Available]` where `BookID` is an
integer, `Title` and `Author` are strings, and `Available` is an integer representing
the number of copies available.
The librarian needs to write the following functions:
- add_book(): This function accepts new book details from the user and adds
them to `Inventory.csv`. The file should be created with column headers if it
doesn't exist.
- check_availability(book_id): This function takes a `book_id` as input and
returns the number of copies available for that book. If the book is not
found, it should return -1.

Page 5 of 7
34 Give output of the following queries as per given table(s): 4
WORKER
WID WNAME JOB SALARY DNO
1001 RAHUL SHARMA CLERK 15000 D03
1002 MUKESH VYAS ELECTRICIAN 11000 D01
1003 SURESH FITTER 9000 D02
1004 ANKUR GUARD 8000 D01
DEPT
DNO DNAME LOC MANAGER
D01 PRODUCTION GROUND FLOOR D K JAIN
D02 ACCOUNTS 1ST FLOOR S ARORA
D03 SECURITY 1ST FLOOR R K SINGH
(i) SELECT DISTINCT JOB FROM WORKER;
(iii) SELECT DNAME, LOC FROM DEPT WHERE SALARY > 10000;
(iv) SELECT W.WNAME, D.MANAGER FROM WORKER AS W, DEPT AS D
WHERE W.DNO = D.DNO;
(v) SELECT WNAME FROM WORKER WHERE WNAME LIKE 'R%';
35 A table named Products in a database named Inventory stores information about 4
products. The table has the following columns: ProductID (integer, primary key),
ProductName (string), Price (float), and Quantity (integer). Assume the database
username is 'admin' and the password is 'secure123'.
Write a Python code that prompts the user to enter a ProductID and updates the
Quantity of that product by adding 10 to the existing quantity. Handle any potential
errors (e.g., the product ID not existing in the table).

Q Section-E ( 2 x 5 = 10 Marks) Mark


36 Simran is developing a Python program to manage customer orders for an online 5
store. Order data (order_id, customer_name, order_date, total_amount) is stored
in a binary file named "Orders.dat". Each order is represented as a tuple. Help
Simran complete the following tasks:
(i) Write a function `add_order()` to input order details from the user (order_id,
customer_name, order_date, total_amount) and store them in "Orders.dat". The
program should allow adding multiple orders until the user chooses to stop.
(ii) Write a function `update_order_amount()` to modify the `total_amount` for
orders placed. The function should increase the `total_amount` of each qualifying
order by 10%.
(iii) Write a function `count_high_value_orders()` to count and display the number
of orders with a `total_amount` greater than 1000.

Page 6 of 7
37 Kendriya Vidyalaya No 1 Jaipur is setting up the network between its Different Wings 5
of school campus. There are 4 wings named as – SENIOR(S), JUNIOR(J), ADMIN(A)
and HOSTEL(H).
Distance between various wings are given below:
Wing A to Wing S 80m
Wing A to Wing J 200m
Wing A to Wing H 400m
Wing S to Wing J 70m
Wing S to Wing H 120m
Wing J to Wing H 450m

Number of Computers installed at various wings are as follows:


Wing No. of Computers
Wing A 20
Wing S 150
Wing J 50
Wing H 25
(i) Suggest a most suitable cable layout for the above connections.
(ii) Suggest the most appropriate topology of the connection between the wings.
(iii) The company wants internet accessibility in all the wings. What type of
network (LAN/MAN/WAN) will be created if we connect all buildings?
(iv) Suggest the placement of the following devices with justification:
(A) Repeater
(B) Firewall
(v) (A) Which building will host the server of the company
OR
(B) Suggest a device to be used for accessing the internet.

Page 7 of 7
Kendriya Vidyalaya Sangathan, Jaipur Region
PRACTICE PAPER -4 (MARKING SCHEME)
Class: XII Subject: Computer Science (083)
Maximum Marks: 70 Period: 3 Hours
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 the case of MCQ, the text of the correct answer should also be written.

Q. Section-A (21 x 1 = 21 Marks) Mark


1 State True/False: The python expression 3.2+2 is evaluated as 3*2+2 (False) 1
2 Observe and find output of the following python code: 1
str1 = "Python"
str2 = "Programming"
print(str1[:2] + str2[-4:])
a. Pyming b. Pythming c. Pyogramming d. Pythonming
3 Evaluate the following expression and find correct value of y: 1
y = 3 * 4 + 2**3 // 2 - (7 % 3)
Ans. 15
4 What will be the output of following python code: 1
s = 'Programming'
print(s.split("m"))
a. ['Progra', '', 'ing'] b. ['Progra', 'ing']
c. ['Progra', 'm', 'ing'] d. ['Progra', 'ming']
5 What will be the output of following python code: 1
s = “yoBananaBoy”
print(s[: :-1 ])
Ans. yoBananaBoy
6 What will be the output of following python code: 1
t1 = 1,2,3
t2 = (1,2,3)
print(t1 is t2)
a. True b. 1 c. False d. 0
7 What would the following code print: 1
fruits = {'apple': 5, 'banana': 3, 'orange': 2, 'grape': 4}
print(fruits.get('mango'))
a. 0 b. None c. Error d. 5
8 Consider the given list L: 1
L = list('All is well in ')
What python code should be written for inserting the word 'Havana' at the end of
the list as separate characters?
a. L.extend('Havana') b. L.append(list('Havana'))
c. both a and b d. None of the above
9 What will be the output of following python code: 1
l2= [1,2,3,'[4,5]']
print(type(l2[-1]))
a. error b. <class ‘list’> c. <class ‘string> d. <class ‘NoneType’>
10 Suppose the content of a text file xyz.txt is as follows: 1
"The best way to predict the future is to create it."
What will be the output of the following python code?
f = open("xyz.txt")
f.seek(18)
s = f.read(7)
print(s)
f.close()
a. Predict b. The best way to
c. predict the d. to predict the future
11 In Python exception handling, the finally block is executed regardless of whether an 1
exception occurs or not. (True/False)
12 def func(a, b, c=3, d=4): 1
pass
Identify the keyword and positional arguments in the function given above:
a) a and b are positional arguments; c and d are keyword arguments
b) a, b, c, and d are all positional arguments
c) a, b, c, and d are all keyword arguments
d) a, b, and c are positional arguments; d is a keyword argument
13 What is the output of following SQL statement? 1
SELECT Department, COUNT(*) FROM employees
WHERE Salary > 50000 GROUP BY Department;
a. The total number of employees in each department
b. The departments with employees earning over 50,000 and the count of
such employees in each department
c. The departments with average salary over 50,000 and their total number of
employees
d. The number of departments with employees earning over 50,000
14 Consider a table named 'Products' with columns 'product_id', 'product_name', and 1
'category'. Which of the following SQL queries will retrieve all products that are not
in the categories 'Electronics' or 'Furniture'?
a. SELECT product_id, product_name FROM Products
WHERE category NOT IN ('Electronics', 'Furniture');
b. SELECT product_id, product_name FROM Products
WHERE category NOT IN 'Electronics', 'Furniture';
c. SELECT product_id, product_name FROM Products
WHERE category != 'Electronics' AND != 'Furniture';
d. SELECT product_id, product_name FROM Products
WHERE category NOT LIKE ('Electronics', 'Furniture');
15 In MySQL, which command does not change the cardinality of a relation? 1
a. ALTER b. INSERT c. DELETE d. None of these
16 Sita is creating a table for her project. She wants that a particular column always 1
has a unique value. Which constraint should she use?
a. DISTINCT b. UNIQUE c. NOT NULL d. DEFAULT
17 Which of the following is a network protocol? 1
a. Firewall b. HTTP c. Modem d. Switch
18 The Router in a network primarily functions as a __________. 1
a. Converter b. Traffic director c. Amplifier d. Modulato
19 Write the full form of the following: 1
(i) FTP: File Transfer Protocol
(ii) DNS: Domain Name Server
Q20 and Q21 are Assertion(A) and Reason(R) 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
20 Assertion: Assertion: In Python, a function can return multiple values. 1
Reason: Python functions can return tuples, which can be unpacked into multiple
variables.
Ans. (A) Both A and R are true and R is the correct explanation for A
21 Assertion: The FOREIGN KEY constraint is used to establish links between tables. 1
Reason: A FOREIGN KEY in one table points to a FOREIGN KEY in another table.

Ans. (C) A is True but R is False

Q Section-B ( 7 x 2=14 Marks) Mark


22 Mark the valid and invalid identifiers in Python from the below options: 2
myVariable : Valid
1st_try: Invalid
For: Invalid
_total_sum: Valid
23 Rohan is writing a Python program to determine if a year is a leap year. He has 2
written a program, but it's not working correctly. Help him rewrite the code,
underlining the changes.
year = input("Enter a year: ") #Input need to be converted into integer
if year % 100 == 0:
if year % 400 ==0:
print(year, "is a century and leap year")
else:
print(year,"is a century year but not leap year")
else if year%4==0: #elif instead of else if
print(year, "is a leap year")
else:
print(year, "is not a leap year")
Correct Code:
year = int(input("Enter a year: ")) #used int() funtion
if year % 100 == 0:
if year % 400 ==0:
print(year, "is a century and leap year")
else:
print(year,"is a century year but not leap year")
elif year%4==0: #elif instead of else if
print(year, "is a leap year")
else:
print(year, "is not a leap year")
24 (A) Write a Python program to find the largest and smallest numbers from a list. 2
Assume the list is given as [55, 12, 98, 34, 76, 1, 88].
Ans.
numbers = [55, 12, 98, 34, 76, 1, 88]
largest_number = max(numbers)
smallest_number = min(numbers)
print("Largest number:", largest_number)
print("Smallest number:", smallest_number)

OR
(B) Write a Python program to check if a string is a palindrome (reads the same
backward as forward). The string should be entered by the user.
Ans.
def is_palindrome(text):
processed_text = text[::-1]
return processed_text

user_input = input("Enter a string: ")


if is_palindrome(user_input):
print(f"'{user_input}' is a palindrome.")
else:
print(f"'{user_input}' is not a palindrome.")
25 Identify the correct output(s) of the following code from the choices i to iv. Write all 2
incorrect choices. Also specify the maximum values that can be assigned to each
of the variables start and end.
import random
numbers = [10, 20, 30, 40, 50, 60]
start = random.randint(0, 2)
end = random.randint(3, 4)
for i in range(start, end):
print(numbers[i], end=", ")
(i) 10, 20, 30, (ii) 30, 40, (iii) 20, 30, 40, (iv) 40, 50,
The maximum value for start is 2, and the maximum value for end is 4.
26 Define the following in context of MYSQL: 2
(i) Tuple: A single row in a MySQL table.
(ii) Cardinality: The number of rows (tuples) in a table.
27 (A) Write difference between DISTINCT and GROUP BY clause of SQL. 2
DISTINCT removes duplicate rows from the result set;
GROUP BY groups rows with the same values in specified columns for aggregate
functions.
OR
(B) What is the difference in INT and FLOAT?
INT stores integers;
FLOAT stores floating-point numbers (numbers with decimal places).
28 Differentiate between Coaxial Cable and Optical Fiber. 2
Coaxial cable uses electrical signals transmitted through a copper core;
Optical fiber uses light signals transmitted through a glass or plastic core,
offering higher bandwidth and less signal degradation.
OR
What is the use of the following devices? (i) Modem (ii) Repeater
(i) A modem modulates and demodulates signals to allow communication
between digital devices and analog lines (like telephone lines).
(ii) A repeater amplifies and retransmits signals to extend the range of a network.

Q Section-C ( 3 x 3 = 9 Marks) Mark


29 (A) Write a Python function count_vowels() that reads text from a file named 3
"input.txt" and counts the number of vowels (a, e, i, o, u) in the file. The function
should return the vowel count.
def count_vowels(filepath):
try:
with open(filepath, 'r') as f:
text = f.read().lower() # Read and convert to lowercase
for i in text:
if i in "aeiou":
vowel_count +=1
return vowel_count
except FileNotFoundError:
return -1
OR
(B) Write a Python function longest_word() that reads text from a file "words.txt"
and returns the longest word in the file.
def longest_word(filepath):
l=[]
try:
with open(filepath, 'r') as f:
words = f.read().split()
if not words: #Handle empty file
return None
else:
for i in words:
l.append(len(i))
val=max(l)
pos=l.find(val)
return words[pos]
except FileNotFoundError:
return None
30 (A) A website uses a stack to manage recently viewed products. Each product is represented as 3
a tuple: (product_id, product_name, price). Write the following Python functions to manage
this RecentlyViewed stack:
(I) add_product(RecentlyViewed, new_product): This function adds a new product tuple to the
top of the RecentlyViewed stack.
(II) remove_product(RecentlyViewed): This function removes and returns the most recently
viewed product from the stack. If the stack is empty, it should print "No products recently
viewed."
(III) show_latest_product(RecentlyViewed): This function displays the most recently viewed
product without removing it. If the stack is empty, it should print "No products recently
viewed."

Ans.
def add_product(RecentlyViewed, new_product):
RecentlyViewed.append(new_product)

def remove_product(RecentlyViewed):
if RecentlyViewed:
return RecentlyViewed.pop()
else:
print("No products recently viewed.")

def show_latest_product(RecentlyViewed):
if RecentlyViewed:
print(RecentlyViewed[-1])
else:
print("No products recently viewed.")
OR
(B)
A hospital is managing patient data using a stack-based system. Patient records
are initially stored in a list. Each record is a tuple containing (patient_id, age,
priority_level). Priority levels are integers, with higher numbers representing
higher priority.
(I) Create a list named patients containing the following patient records:
(101, 65, 2), (102, 32, 4), (103, 78, 1), (104, 45, 3), (105, 52, 5), (106, 28, 2)
(II) Write the definition of a user-defined function push_high_priority(patients,
priority_threshold). It should push only those patient records with a priority level
greater than or equal to the priority_threshold onto a stack called
high_priority_patients.
(III) Write a function get_high_priority() to display all elements of the
high_priority_patients stack while deleting them one by one. If the stack is empty,
the function should display No high-priority patients.

Ans.
# (I) Create the list of patient records
patients = [(101, 65, 2), (102, 32, 4), (103, 78, 1), (104, 45, 3),
(105, 52, 5), (106, 28, 2)]

# Initialize the high_priority_patients stack


high_priority_patients = []

# (II) Function to push high priority patients to stack


def push_high_priority(patients, priority_threshold):
for patient in patients:
if patient[2] >= priority_threshold:
high_priority_patients.append(patient)

# (III) Function to get and display high priority patients


Observe the table Students and write query for (i) to (iii): 3
31 Table: Faculty
F_ID FName LName Department Gender Hire_Date Salary
102 Ibomcha Thounaojam Exam M 10/02/2020 75000
103 Shantanu Fernandes Exam M 11/01/2015 120000
104 Tashi Dorjey ICT F 14/03/2023 50000
105 Bhanwar Singh ICT M 13/12/2019 80000
106 Kanta Kumari HOD F 11/01/2024 140000
(A)
(i) Display Gender wise number of faculties who earn more than 85000:
SELECT Gender, COUNT(*) as Count FROM Faculty
WHERE Salary > 85000 GROUP BY Gender;

(ii) Display all data separated by Department and in decreasing order of Salary:
SELECT * FROM Faculty ORDER BY Department, Salary DESC;

(iii) Display FName and F_ID of faculties from ICT department:


SELECT FName, F_ID FROM Faculty WHERE Department = 'ICT';

OR
(B)
(i) Display Gender wise average salary of those faculties with average salary more
than 90000:
SELECT Gender, AVG(Salary) as AvgSalary FROM Faculty
GROUP BY Gender HAVING AVG(Salary) > 90000;

(ii) Display FName and F_ID of faculties having the string 'ta' in the Fname:
SELECT FName, F_ID FROM Faculty WHERE FName LIKE '%ta%';

(iii) Change data of table to award 5% annual increment in salary:


UPDATE Faculty SET Salary = Salary * 1.05;

Q Section-D ( 4 x 4 = 16 Marks) Mark


32 (A) Explain the difference between the 'a' and 'x' file opening modes in Python. 4
- 'a' (append) mode: Opens the file for appending. If the file exists, it
appends new data to the end. If the file doesn't exist, it creates a new file.
- 'x' (exclusive creation) mode: Opens the file for exclusive creation. If the
file already exists, it raises a FileExistsError. If the file doesn't exist, it
creates a new file.
(B) Observe the following code and predict the output of (i), (ii), and (iii):
def process_data(data):
try:
value = int(data)
if value > 100:
print("Value is greater than 100.")
else:
print("Value is not greater than 100.")
except ValueError:
print("Invalid input: Not an integer.")
finally:
print("Data processing complete.")
(B) Predicted outputs:
(i) process_data(150)
Output:
Value is greater than 100.
Data processing complete.

(ii) process_data("abc")
Output:
Invalid input: Not an integer.
Data processing complete.

(iii) process_data(50)
Output:
Value is not greater than 100.
Data processing complete.
33 A librarian is managing book inventory using a CSV file named `Inventory.csv`. 4
The file structure is: `[BookID, Title, Author, Available]` where `BookID` is an
integer, `Title` and `Author` are strings, and `Available` is an integer representing
the number of copies available.
The librarian needs to write the following functions:
- add_book(): This function accepts new book details from the user and adds
them to `Inventory.csv`. The file should be created with column headers if it
doesn't exist.
- check_availability(book_id): This function takes a `book_id` as input and
returns the number of copies available for that book. If the book is not
found, it should return -1.
Ans.
import csv
import os

def add_book():
file_exists = os.path.isfile('Inventory.csv')
with open('Inventory.csv', 'a', newline='') as file:
writer = csv.writer(file)
if not file_exists:
writer.writerow(['BookID', 'Title', 'Author', 'Available'])
book_id = input("Enter BookID: ")
title = input("Enter Title: ")
author = input("Enter Author: ")
available = input("Enter number of copies available: ")
writer.writerow([book_id, title, author, available])
print("Book added successfully!")

def check_availability(book_id):
try:
with open('Inventory.csv', 'r') as file:
reader = csv.DictReader(file)
for row in reader:
if row['BookID'] == str(book_id):
return int(row['Available'])
except FileNotFoundError:
print("Inventory file not found.")
return -1
34 Give output of the following queries as per given table(s): 4
WORKER
WID WNAME JOB SALARY DNO
1001 RAHUL SHARMA CLERK 15000 D03
1002 MUKESH VYAS ELECTRICIAN 11000 D01
1003 SURESH FITTER 9000 D02
1004 ANKUR GUARD 8000 D01
DEPT
DNO DNAME LOC MANAGER
D01 PRODUCTION GROUND FLOOR
D K JAIN
D02 ACCOUNTS 1ST FLOOR
S ARORA
D03 SECURITY 1ST FLOOR
R K SINGH
Ans.
(i) SELECT DISTINCT JOB FROM WORKER;
JOB
----
CLERK
ELECTRICIAN
FITTER
GUARD
(ii) SELECT DNAME, LOC FROM DEPT WHERE DNO IN (SELECT DNO FROM
WORKER WHERE SALARY > 10000);
DNAME LOC
----------- ------------
PRODUCTION GROUND FLOOR
SECURITY 1ST FLOOR
(iii) SELECT W.WNAME, D.MANAGER
FROM WORKER AS W, DEPT AS D
WHERE W.DNO = D.DNO;
WNAME MANAGER
------------- ---------
RAHUL SHARMA R K SINGH
MUKESH VYAS D K JAIN
SURESH S ARORA
ANKUR D K JAIN
(iv) SELECT WNAME FROM WORKER WHERE WNAME LIKE 'R%';
WNAME
-------------
RAHUL SHARMA
35 A table named Products in a database named Inventory stores information about 4
products. The table has the following columns: ProductID (integer, primary key),
ProductName (string), Price (float), and Quantity (integer). Assume the database
username is 'admin' and the password is 'secure123'.
Write a Python code that prompts the user to enter a ProductID and updates the
Quantity of that product by adding 10 to the existing quantity. Handle any potential
errors (e.g., the product ID not existing in the table).
Ans.
import mysql.connector
from mysql.connector import Error

def update_product_quantity(product_id):
try:
connection = mysql.connector.connect(
host="localhost",
database="Inventory",
user="admin",
password="secure123" )

if connection.is_connected():
cursor = connection.cursor()
cursor.execute("SELECT Quantity FROM Products
WHERE ProductID = %s", (product_id,))
result = cursor.fetchone()
if result:
current_quantity = result[0]
new_quantity = current_quantity + 10
update_query = "UPDATE Products SET Quantity = %s
WHERE ProductID = %s"
cursor.execute(update_query, (new_quantity, product_id))
connection.commit()
print(f"updated successfully. New quantity: {new_quantity}")
else:
print("Product not found.")

except Error as e:
print(f"Error: {e}")

finally:
if connection.is_connected():
cursor.close()
connection.close()

Q Section-E ( 2 x 5 = 10 Marks) Mark


36 Simran is developing a Python program to manage customer orders for an online 5
store. Order data (order_id, customer_name, order_date, total_amount) is stored
in a binary file named "Orders.dat". Each order is represented as a tuple. Help
Simran complete the following tasks:

Ans.
import pickle

(i) Write a function `add_order()` to input order details from the user (order_id,
customer_name, order_date, total_amount) and store them in "Orders.dat". The
program should allow adding multiple orders until the user chooses to stop.
def add_order():
orders = []
try:
with open("Orders.dat", "rb") as file:
orders = pickle.load(file)
except FileNotFoundError:
pass

while True:
order_id = input("Enter order ID: ")
customer_name = input("Enter customer name: ")
order_date = input("Enter order date (YYYY-MM-DD): ")
total_amount = float(input("Enter total amount: "))

order = (order_id, customer_name, order_date, total_amount)


orders.append(order)

if input("Add another order? (y/n): ").lower() != 'y':


break

with open("Orders.dat", "wb") as file:


pickle.dump(orders, file)

(ii) Write a function `update_order_amount()` to modify the `total_amount` for


orders placed. The function should increase the `total_amount` of each qualifying
order by 10%.
def update_order_amount():
try:
with open("Orders.dat", "rb") as file:
orders = pickle.load(file)
updated_orders = []
for order in orders:
new_amount = order[3] * 1.10
updated_order = (order[0], order[1], order[2], new_amount)
updated_orders.append(updated_order)

with open("Orders.dat", "wb") as file:


pickle.dump(updated_orders, file)

print("Orders updated successfully.")


except FileNotFoundError:
print("Orders file not found.")

(iii) Write a function `count_high_value_orders()` to count and display the number


of orders with a `total_amount` greater than 1000.
def count_high_value_orders():
try:
37 Kendriya Vidyalaya No 1 Jaipur is setting up the network between its Different Wings 5
of school campus. There are 4 wings named as – SENIOR(S), JUNIOR(J), ADMIN(A)
and HOSTEL(H).
Distance between various wings are given below:
Wing A to Wing S 80m
Wing A to Wing J 200m
Wing A to Wing H 400m
Wing S to Wing J 70m
Wing S to Wing H 120m
Wing J to Wing H 450m

Number of Computers installed at various wings are as follows:


Wing No. of Computers
Wing A 20
Wing S 150
Wing J 50
Wing H 25
(i) Suggest a most suitable cable layout for the above connections.
A
|
| (80m)
|
J--------S----------R----------H
(70m) (120m)
* R is the repeater
(ii) Suggest the most appropriate topology of the connection between the wings:
Star Topology
(iii) The company wants internet accessibility in all the wings. What type of
network (LAN/MAN/WAN) will be created if we connect all buildings? : LAN
(iv) Suggest the placement of the following devices with justification:
(A) Repeater: Between S and H (the distance is more than 100)
(B) Firewall: in Wing S as it is also suitable for installing a server
(v) (A) Which building will host the server of the company: Wing S
OR
(B) Suggest a device to be used for accessing the internet. Modem
केन्द्रीय विद्यालय संगठन , कोलकाता संभाग
KENDRIYA VIDYALAYA SANGATHAN , KOLKATA REGION
प्री-बोर्ड परीक्षा / PRE BOARD EXAMINATION 2024-25
कक्षा / Class - XII अविकतम अं क / Maximum Marks : 70
विषय / Subject - Computer Science समय / 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.

Q No. Section-A (21 x 1 = 21 Marks) Marks

1. State True or False:


(1)
The Python statement print(‘Alpha’+1) is example of TypeError Error

2. What id the output of following code snippet?

country = "GlobalNetwork" (1)


result = "-".join(country.split("o")).upper()
print(result)
(A) GL-BALNETW-RK
(B) GL-BA-LNET-W-RK
(C) GL-BA-LNET-W-RK
(D) GL-BA-LNETWORK

3. Identify the output of the following code snippet:

text = "The_quick_brown_fox"
index = text.find("quick")
(1)
result = text[:index].replace("_", "") + text[index:].upper()
print(result)

(A) Thequick_brown_fox
(B) TheQUICK_BROWN_FOX

Page: 1/11
(C) TheQUICKBROWNFOX
(D) TheQUICKBROWN_FOX
What will be the output of the following Python expression?
4.
x=5
y = 10
(1)
result = (x ** 2 + y) // x * y - x
print(result)

(A) 0
(B) -5
(C) 65
(D) 265
What will be the output of the following code snippet?
5.
(1)
text = "Python Programming"
print(text[1 : :3])

(A) Ph oai
(B) yoPgmn
(C) yhnPormig
(D) Pto rgamn
6. What will be the output of the following code?
tuple1 = (1, 2, 3)
tuple2 = tuple1 + (4,)
tuple1 += (5,)
print(tuple1, tuple2) (1)

(A) (1, 2, 3) (1, 2, 3, 4)


(B) (1, 2, 3, 5) (1, 2, 3)
(C) (1, 2, 3, 5) (1, 2, 3, 4)
(D) Error
7. Dictionary my_dict as defined below, identify type of error raised by statement
my_dict['grape']?
my_dict = {'apple': 10, 'banana': 20, 'orange': 30}
(A) ValueError (1)
(B) TypeError
(C) KeyError
(D) ValueError
What does the list.pop(x) method do in Python?
8.
A. Removes the first element from the list.
(1)
B. Removes the element at index x from the list and returns it.
C. Adds a new element at index x in the list.
D. Replaces the element at index x with None.

Page: 2/11
In a relational database table with one primary key and three unique constraints
9.
defined on different columns (not primary), how many candidate keys can be
derived from this configuration?
(1)
(A) 1
(B) 3
(C) 4
(D) 2
10. Fill in the blanks to complete the following code snippet choosing the correct
option:

with open("sample.txt", "w+") as file:


(1)
file.write("Hello, World!") # Write a string to the file
position_after_write = file.______ # Get the position after writing
file.seek(0) # Move the pointer to the beginning
content = file.read(5) # Read the first 5 characters
print(content)

(A) tell
(B) seek
(C) read
(D) write
11. State whether the following statement is True or False:
In Python, if an exception is raised inside a try block and not handled, the
program will terminate without executing any remaining code in the finally (1)
block.

12. What will be the output of the following code?


x=4
def reset():
global x
x=2
print(x, end='&')
def update(): (1)
x += 3
print(x, end='@')

update()
x=6
reset()
print(x, end='$')

(A) 7@2&6$
(B) 7@6&6$
(C) 7@2&2$
(D) Error

Page: 3/11
Which SQL command can modify the structure of an existing table, such as adding or
13. (1)
removing columns?

(A) ALTER TABLE


(B) UPDATE TABLE
(C) MODIFY TABLE
(D) CHANGE TABLE
14. What will be the output of the query?
SELECT * FROM orders WHERE order_date LIKE '2024-10-%';
(A) Details of all orders placed in October 2024
(B) Details of all orders placed on October 10th, 2024 (1)
(C) Details of all orders placed in the year 2024
(D) Details of all orders placed on any day in 2024
Which of the following statements about the CHAR and VARCHAR datatypes in SQL
15.
is false?
(A) CHAR is a fixed-length datatype, and it pads extra spaces to match the specified
length. (1)
(B) VARCHAR is a variable-length datatype and does not pad extra spaces.
(C) The maximum length of a VARCHAR column is always less than that of a CHAR
column.
(D) CHAR is generally used for storing data of a known, fixed length.
16. Which of the following aggregate functions can be employed to determine the
number of unique entries in a specific column, effectively ignoring duplicates?
(A) SUM() (1)
(B) COUNT()
(C) AVG()
(D) COUNT(DISTINCT column_name)
17. Which protocol is used to send e-mail over internet?
(A) FTP
(B) TCP
(C) SMTP
(D) SNMP
(1)
18. Which device is primarily used to amplify and regenerate signals in a network,
allowing data to travel longer distances?
(A) Switch
(B) Router (1)
(C) Repeater
(D) Bridge

19. Which communication technique establishes a dedicated communication path


between two devices for the entire duration of a transmission, ensuring a (1)
continuous and consistent connection?

Page: 4/11
Q20 and Q21 are Assertion(A) and Reason(R) 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): Python functions can accept positional, keyword, and default
20.
parameters.

Reasoning (R): Default parameters allow function arguments to be assigned a (1)


default value if no argument is provided during the function call.
Assertion (A): A GROUP BY clause in SQL can be used without any aggregate
21.
functions.
Reasoning (R): The GROUP BY clause is used to group rows that have the same (1)
values in specified columns and must always be paired with
aggregate functions.
Q No Section-B ( 7 x 2=14 Marks) Marks
Consider the following Python code snippet:
22.
a = [1, 2, 3]
b=a (2)
a.append(4)
c = (5, 6, 7)
d = c + (8,)
a. Explain the mutability of a and c in the context of this code.
b. What will be the values of b and d after the code is executed?
Give examples for each of the following types of operators in Python:
23.
(I) Assignment Operators (2)
(II) Identity Operators
If L1 = [10, 20, 30, 40, 20, 10, ...] and L2 = [5, 15, 25, ...], then:
24.
(Answer using builtin functions only)

(I) A) Write a statement to count the occurrences of 20 in L1. (2)


OR
B) Write a statement to find the minimum value in L1.

(II) A) Write a statement to extend L1 with all elements from L2.


OR
B) Write a statement to get a new list that contains the unique elements
from L1.

Page: 5/11
25. Identify the correct output(s) of the following code. Also write the minimum and
the maximum possible values of the variable b.
import random
text = "Adventure"
b = random.randint(1, 5)
for i in range(0, b):
print(text[i], end='*') (2)

(A) A* (B) A*D*

(C) A*d*v* (D) A*d*v*e*n*t*u*

26. The code provided below is intended to reverse the order of elements in a given
list. However, there are syntax and logical errors in the code. Rewrite it after
removing all errors. Underline all the corrections made.

def reverse_list(lst)
if not lst:
return lst (2)
reversed_lst = lst[::-1]
return reversed_lst
print("Reversed list: " reverse_list[1,2,3,4] )

27. (I)
A) What constraint should be applied to a table column to ensure that all values in
that column must be unique and not NULL?
OR
B) What constraint should be applied to a table column to ensure that it can have
multiple NULL values but cannot have any duplicate non-NULL values? (2)
(II)
A) Write an SQL command to drop the unique constraint named unique_email
from a column named email in a table called Users.
OR
B) Write an SQL command to add a unique constraint to the email column of an
existing table named Users, ensuring that all email addresses are unique.

28. A) Explain one advantage and one disadvantage of mesh topology in computer
networks.
OR (2)
B) Expand the term DNS. What role does DNS play in the functioning of the
Internet?

Page: 6/11
Q No. Section-C ( 3 x 3 = 9 Marks) Marks

29. A) Write a Python function that extracts and displays all the words present in a
text file “Vocab.txt” that begins with a vowel.
OR (3)
B) Write a Python function that extracts and displays all the words containing a
hyphen ("-") from a text file "HyphenatedWords.txt", which has a three letter
word before hypen and four letter word after hypen. For example : “for-
them” is such a word.
(A) You have a stack named MovieStack that contains records of movies. Each
30.
movie record is represented as a list containing movie_title, director_name, and
release_year. Write the following user-defined functions in Python to perform the
specified operations on the stack MovieStack:

(I) push_movie(MovieStack, new_movie): This function takes the stack MovieStack


and a new movie record new_movie as arguments and pushes the new movie
record onto the stack.

(II) pop_movie(MovieStack): This function pops the topmost movie record from the
stack and returns it. If the stack is empty, the function should display "Stack is
empty".

(III) peek_movie(MovieStack): This function displays the topmost movie record (3)
from the stack without deleting it. If the stack is empty, the function should display
"None".

OR

(B) Write the definition of a user-defined function push_odd(M) which accepts a list
of integers in a parameter M and pushes all those integers which are odd from the
list M into a Stack named OddNumbers.

Write the function pop_odd() to pop the topmost number from the stack and
return it. If the stack is empty, the function should display "Stack is empty".

Write the function disp_odd() to display all elements of the stack without deleting
them. If the stack is empty, the function should display "None".

For example:

If the integers input into the list NUMBERS are: [7, 12, 9, 4, 15]

Then the stack OddNumbers should store: [7, 9, 15]

Page: 7/11
31. Predict the output of the following code:
data = [3, 5, 7, 2]
result = ""
for num in data:
for i in range(num):
result += str(i) + "*"
result = result[:-1]
print(result)
OR

Predict the output of the following code: (3)


numbers = [10, 15, 20]
for num in numbers:
for j in range(num // 5):
print(j, "+", end="")
print()

Q No. Section-D ( 4 x 4 = 16 Marks) Marks

32. Consider the table ORDERS as given below

O_Id C_Name Product Quantity Price


1001 Jitendra Laptop 1 12000
1002 Mustafa Smartphone 2 10000
1003 Dhwani Headphone 1 1500
1004 Alice Smartphone 1 9000
1005 David Tablet NULL 7000

Note: The table contains many more records than shown here.
(4)
A) Write the following queries:
(I) To display the total Quantity for each Product, excluding Products with total
Quantity less than 5.
(II) To display the ORDERS table sorted by total price in descending order.
(III) To display the distinct customer names from the ORDERS table.
(IV) To display the sum of the Price of all the orders for which the quantity is
NULL.
OR
B) Write the output:
(I) SELECT C_Name, SUM(Quantity) AS Total_Quantity FROM ORDERS GROUP BY
C_Name;
(II) SELECT * FROM ORDERS WHERE Product LIKE '%phone%';
(III) SELECT O_Id, C_Name, Product, Quantity, Price FROM ORDERS WHERE Price
BETWEEN 1500 AND 12000;
(IV) SELECT MAX(Price) FROM ORDERS;

Page: 8/11
A CSV file "HealthData.csv" contains the data of a health survey. Each record of the
33.
file contains the following data:

 Name of a country
 Life Expectancy (average number of years a person is expected to live)
 GDP per capita (Gross Domestic Product per person)
 Percentage of population with access to healthcare

For example, a sample record of the file may be: ['Wonderland', 82.5, 40000, 95].
(4)
Write the following Python functions to perform the specified operations on this
file:

(I) Read all the data from the file in the form of a list and display all those records
for which the life expectancy is greater than 75.

(II) Count the number of records in the file.

Alex has been tasked with managing the Student Database for a High School. He
34.
needs to access some information from the STUDENTS and SUBJECTS tables for a
performance evaluation. Help him extract the following information by writing the
desired SQL queries as mentioned below.
Table: STUDENTS
S_I FNa LNam Enrollment_Dat Mar
D me e e ks
201 John Doe 15-09-2020 85
202 Jane Smith 10-05-2019 90
203 Alex Johns 22-11-2021 75
(4)
on
204 Emily Davis 30-01-2022 60
205 Mich Brown 17-08-2018 95
ael

Table: SUBJECTS

Sub_ID S_ID SubName Credits


301 201 Mathematics 3
302 202 Science 4
303 203 History 2
304 204 Literature 3
305 205 Physics 4
306 201 Computer 3
Science
Write the following SQL queries:
(I) To display complete details (from both the tables) of those students whose
marks are greater than 70.
(II) To display the details of subjects whose credits are in the range of 2 to 4 (both
values included).
(III) To increase the credits of all subjects by 1 which have "Science" in their subject
names.
(IV) (A) To display names (FName and LName) of students enrolled in the
Page: 9/11
"Mathematics" subject.
(OR)
(B) To display the Cartesian Product of these two tables.

A table, named ELECTRONICS, in the PRODUCTDB database, has the following


35.
structure:

Field Type
productID int(11)
productName varchar(20)
price float
stockQty int(11)

Write the following Python function to perform the specified operation: (4)

AddAndDisplay(): To input details of a product and store it in the table


ELECTRONICS. The function should then retrieve and display all records from the
ELECTRONICS table where the price is greater than 150.
Assume the following for Python-Database connectivity:
Host: localhost
User: root
Password: Electro123

Q.No. SECTION E (2 X 5 = 10 Marks) Marks


Raj is a supervisor at a software development company. He needs to manage the
36.
records of various employees. For this, he wants the following information of each
employee to be stored:
Employee_ID – integer
Employee_Name – string
Position – string
Salary – float (5)
You, as a programmer of the company, have been assigned to do this job for Raj.
(I) Write a function to input the data of an employee and append it to a binary file.
(II) Write a function to update the data of employees whose salary is greater than
50000 and change their position to "Team Lead".
(III) Write a function to read the data from the binary file and display the data of all
those employees who are not "Team Lead".
Interstellar Logistics Ltd. is an international shipping company. They are planning to
37
establish a new logistics hub in Chennai, with the head office in Bangalore. The
Chennai hub will have four buildings - OPERATIONS, WAREHOUSE,
CUSTOMER_SUPPORT, and MAINTENANCE. As a network specialist, your task is to
propose the best networking solutions to address the challenges mentioned in
points (I) to (V), considering the distances between the various buildings and the
given requirements.

Building-to-Building Distances (in meters):

Page: 10/11
From To Distance
OPERATIONS WAREHOUSE 40 m
OPERATIONS CUSTOMER_SUPPORT 90 m
OPERATIONS MAINTENANCE 50 m
WAREHOUSE CUSTOMER_SUPPORT 60 m
WAREHOUSE MAINTENANCE 45 m
CUSTOMER_SUPPORT MAINTENANCE 55 m

Distance of Bangalore Head Office from Chennai Hub: 1300 km

Number of Computers in Each Building/Office:

Location Computers
OPERATIONS 40
WAREHOUSE 20
CUSTOMER_SUPPORT 25
MAINTENANCE 22
BANGALORE HEAD OFFICE 15
(I) Suggest the most suitable location for the server within the Chennai hub. Justify
your decision.
(II) Recommend the hardware device to connect all computers within each building (5)
efficiently.
(III) Draw a cable layout to interconnect the buildings at the Chennai hub efficiently.
Which type of cable would you recommend for the fastest and most reliable data
transfer?
(IV) Is there a need for a repeater in the proposed cable layout? Justify your
answer.
(V) A) Recommend the best option for live video communication between the
Operations Office in the Chennai hub and the Bangalore Head Office from the
following choices:
• a) Video Conferencing
• b) Email
• c) Telephony
• d) Instant Messaging
OR
(V) B) What type of network (PAN, LAN, MAN, or WAN) would be set up among the
computers within the Chennai hub?

Page: 11/11
MARKING SCHEME OF 1st PREBOARD ( KVS RO KOLKATA )
2024-25 ( COMPUTER SCIENCE)
Time allowed: 3 Hours Maximum Marks: 70

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 ( No marks should be
provided if student does not write the correct choice )

Q No. Section-A (21 x 1 = 21 Marks) Marks

1. State True or False:


(1)
The Python statement print(‘Alpha’+1) is example of TypeError Error

Ans : True
2. What id the output of following code snippet?

country = "GlobalNetwork" (1)


result = "-".join(country.split("o")).upper()
print(result)
(A) GL-BALNETW-RK
(B) GL-BA-LNET-W-RK
(C) GL-BA-LNET-W-RK
(D) GL-BA-LNETWORK

Ans : A ) GL-BALNETW-RK
3. Identify the output of the following code snippet:

text = "The_quick_brown_fox"
index = text.find("quick")
(1)
result = text[:index].replace("_", "") + text[index:].upper()
print(result)

(A) Thequick_brown_fox
(B) TheQUICK_BROWN_FOX
(C) TheQUICKBROWNFOX
(D) TheQUICKBROWN_FOX

Page: 1/21
Ans : (B) TheQUICK_BROWN_FOX

What will be the output of the following Python expression?


4.
x=5
y = 10
(1)
result = (x ** 2 + y) // x * y - x
print(result)

(A) 0
(B) -5
(C) 65
(D) 265

Ans : ( C ) 65
What will be the output of the following code snippet?
5.
(1)
text = "Python Programming"
print(text[1 : :3])

(A) Ph oai
(B) yoPgmn
(C) yhnPormig
(D) Pto rgamn
Ans : (B)

6. What will be the output of the following code?


tuple1 = (1, 2, 3)
tuple2 = tuple1 + (4,)
tuple1 += (5,)
print(tuple1, tuple2) (1)

(A) (1, 2, 3) (1, 2, 3, 4)


(B) (1, 2, 3, 5) (1, 2, 3)
(C) (1, 2, 3, 5) (1, 2, 3, 4)
(D) Error

Ans : C )
7. Dictionary my_dict as defined below, identify type of error raised by statement
my_dict['grape']?
my_dict = {'apple': 10, 'banana': 20, 'orange': 30}
ValueError (1)
(B) TypeError
(C) KeyError
(D) ValueError
Ans : (C) KeyError

Page: 2/21
What does the list.pop(x) method do in Python?
8.

A. Removes the first element from the list. (1)


B. Removes the element at index x from the list and returns it.
C. Adds a new element at index x in the list.
D. Replaces the element at index x with None.

Ans : B. Removes the element at index x from the list and returns it.

In a relational database table with one primary key and three unique
9. constraints defined on different columns (not primary), how many candidate
keys can be derived from this configuration?
(1)
(A) 1
(B) 3
(C) 4
(D) 2

Ans : C) 4
10. Fill in the blanks to complete the following code snippet choosing the
correct option:

with open("sample.txt", "w+") as file:


(1)
file.write("Hello, World!") # Write a string to the file
position_after_write = file.______ # Get the position after writing
file.seek(0) # Move the pointer to the beginning
content = file.read(5) # Read the first 5 characters
print(content)

(A) tell
(B) seek
(C) read
(D) write

Ans : (A) tell

11. State whether the following statement is True or False:


In Python, if an exception is raised inside a try block and not handled,
the program will terminate without executing any remaining code in the (1)
finally block.

Ans : False

Page: 3/21
12. What will be the output of the following code?
x=4
def reset():
global x
x=2
print(x, end='&')
def update(): (1)
x += 3
print(x, end='@')

update()
x=6
reset()
print(x, end='$')

(A) 7@2&6$
(B) 7@6&6$
(C) 7@2&2$
(D) Error
Ans : (D) Error : Unbound local variable x in function update()
Which SQL command can modify the structure of an existing table, such as
13. adding or removing columns? (1)

(A) ALTER TABLE


(B) UPDATE TABLE
(C) MODIFY TABLE
(D) CHANGE TABLE

Ans. (A) ALTER TABLE


14. What will be the output of the query?
SELECT * FROM orders WHERE order_date LIKE '2024-
10-%';
(A) Details of all orders placed in October 2024 (1)
(B) Details of all orders placed on October 10th, 2024
(C) Details of all orders placed in the year 2024
(D) Details of all orders placed on any day in 2024

Ans : (A) Details of all orders placed in October 2024


Which of the following statements about the CHAR and VARCHAR
15.
datatypes in SQL is false?
(A) CHAR is a fixed-length datatype, and it pads extra spaces to match the
specified length. (1)
(B) VARCHAR is a variable-length datatype and does not pad extra spaces.
(C) The maximum length of a VARCHAR column is always less than that of
a CHAR column.
(D) CHAR is generally used for storing data of a known, fixed length.
Ans : ( C )

Page: 4/21
16. Which of the following aggregate functions can be employed to determine
the number of unique entries in a specific column, effectively ignoring
duplicates?
(1)
(A) SUM()
(B) COUNT()
(C) AVG()
(D) COUNT(DISTINCT column_name)
Ans : (D) COUNT(DISTINCT column_name)

17. Which protocol is used to send e-mail over internet?


(A) FTP
(B) TCP
(C) SMTP
(D) SNMP (1)
Ans. (C) SMTP
18. Which device is primarily used to amplify and regenerate signals in a
network, allowing data to travel longer distances?
(A) Switch
(B) Router (1)
(C) Repeater
(D) Bridge
Ans : ( C) Repeater
19. Which communication technique establishes a dedicated communication
path between two devices for the entire duration of a transmission, (1)
ensuring a continuous and consistent connection?

Ans : Circuit Switching


Q20 and Q21 are Assertion(A) and Reason(R) 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): Python functions can accept positional, keyword, and default
20. parameters.

Reasoning (R): Default parameters allow function arguments to be assigned (1)


a default value if no argument is provided during the function call.

Ans : (B) Both A and R are true and R is not the correct explanantion
for A
Assertion (A): A GROUP BY clause in SQL can be used without any
21.
aggregate functions.
Reasoning (R): The GROUP BY clause is used to group rows that have the (1)
same values in specified columns and must always be paired
with aggregate functions.
Page: 5/21
Ans : ( C ) A is True , but R is False

Q No Section-B ( 7 x 2=14 Marks) Marks


Consider the following Python code snippet:
22.
a = [1, 2, 3]
b=a (2)
a.append(4)
c = (5, 6, 7)
d = c + (8,)
a. Explain the mutability of a and c in the context of this code.
b. What will be the values of b and d after the code is executed?

Ans : a) a is a mutable object (a list), meaning its contents can be


changed after it is created. This is demonstrated by the append()
method that adds an element to the list.
c is an immutable object (a tuple). Once created, its contents cannot
be changed. The operation c + (8,) does not modify c but creates a new
tuple.

b)The value of b will be [1, 2, 3, 4], as b references the same list as a,


which was modified by appending 4.
The value of d will be (5, 6, 7, 8), as the expression c + (8,) creates a
new tuple combining c and (8,).

( 1 marks + 1 Marks )

Give examples for each of the following types of operators in Python:


23.
(2)
(I) Assignment Operators

(II) Identity Operators

Ans :

(I) Assignment Operators: ( 1 Marks for Any one of them)

1. Example 1: = (Simple Assignment) Usage: x = 5 (assigns the


value 5 to x)
2. Example 2: += (Add and Assign) : Usage: x += 3 (equivalent to x
= x + 3)

(II) Identity Operators: ( 1 Marks for any one of them )

1. Example 1: is , Usage: x is y (checks if x and y refer to the


same object)
2. Example 2: is not : Usage: x is not y (checks if x and y do
not refer to the same object)

Page: 6/21
If L1 = [10, 20, 30, 40, 20, 10, ...] and L2 = [5, 15, 25, ...], then:
24.
(Answer using builtin functions only)

(I) A) Write a statement to count the occurrences of 20 in L1. (2)


OR
B) Write a statement to find the minimum value in L1.

(II) A) Write a statement to extend L1 with all elements from L2.


OR
B) Write a statement to get a new list that contains the unique elements
from L1.

Ans : I ( A) : count_20 = L1.count(20)


(B) : min_value = min(L1)

II (A) : L1.extend(L2)
(B) : unique_elements = list(set(L1))

( 1 marks for each correct answer , no marks if did not used


any built in function )
25. Identify the correct output(s) of the following code. Also write the minimum
and the maximum possible values of the variable b.
import random
text = "Adventure"
b = random.randint(1, 5)
for i in range(0, b):
print(text[i], end='*') (2)

(A) A* (B) A*D*

(C) A*d*v* (D) A*d*v*e*n*t*u*


Ans :  Minimum possible value of b: 1 ( 1/2 + 1/2 marks)
 Maximum possible value of b: 5

Possible Outputs : (A) and ( C ) ( 1/2 + 1/2 marks )

Page: 7/21
26. The code provided below is intended to reverse the order of elements in a
given list. However, there are syntax and logical errors in the code. Rewrite
it after removing all errors. Underline all the corrections made.

def reverse_list(lst)
if not lst:
return lst (2)
reversed_lst = lst[::-1]
return reversed_lst
print("Reversed list: " reverse_list[1,2,3,4] )

Ans : Corrections : ( 1/2 x 4 = 2)


iAdded a colon (:) after the function definition.
ii. Indented the if statement and the return statement for proper
structure.
iii. Put ( ) while calling the function reverse_list( )
iv. Added a comma (,) in the print statement for correct syntax.

27. (I)
A) What constraint should be applied to a table column to ensure that all
values in that column must be unique and not NULL?
OR
B) What constraint should be applied to a table column to ensure that it can
have multiple NULL values but cannot have any duplicate non-NULL (2)
values?
(II)
A) Write an SQL command to drop the unique constraint named
unique_email from a column named email in a table called Users.
OR
B) Write an SQL command to add a unique constraint to the email column
of an existing table named Users, ensuring that all email addresses are
unique.

Ans : (I)(A): Use the UNIQUE constraint along with the NOT NULL OR
PRIMARY KEY constraint.
OR
(B): Use the UNIQUE constraint alone, allowing for multiple NULL
values.
Example: column_name INT UNIQUE NULL

(II)(A):ALTER TABLE Users DROP CONSTRAINT unique_email;


OR
(B):ALTER TABLE Users ADD CONSTRAINT unique_email UNIQUE
(email);

( 1 mark each for correct part for each questions any correct example
as an answer is acceptable )

Page: 8/21
28. A) Explain one advantage and one disadvantage of mesh topology in
computer networks.
OR (2)
B) Expand the term DNS. What role does DNS play in the functioning of the
Internet?

Ans :
(A): Advantage of Mesh Topology: High redundancy; if one connection
fails, data can still be transmitted through other nodes.
Disadvantage of Mesh Topology: Complexity and high cost; requires
more cabling and configuration compared to simpler topologies.
OR

(B): · DNS stands for Domain Name System. It translates human-


readable domain names (like www.example.com) into IP addresses that
computers use to identify each other on the network.

( for part A 1/2 + 1/2 )


(for part B 1/2 for correct abbreviation and 1/2 for correct use)

Q No. Section-C ( 3 x 3 = 9 Marks) Marks

29. A) Write a Python function that extracts and displays all the words present in a
text file “Vocab.txt” that begins with a vowel..
OR (3)
B) Write a Python function that extracts and displays all the words
containing a hyphen ("-") from a text file "HyphenatedWords.txt", which
has a three letter word before hypen and four letter word after hypen.
For example : “for-them” is such a word.
Ans : A)
def display_words_starting_with_vowel():
vowels = 'AEIOUaeiou'
with open('Vocab.txt', 'r') as file:
words = file.read().split()
# Loop through the words and check if the first letter is a vowel
for word in words:
if word[0] in vowels:
print(word)

B)
def display_specific_hyphenated_words():
with open('HyphenatedWords.txt', 'r') as file:
words = file.read().split()
# Loop through the words and check if they match the pattern
for word in words:
parts = word.split('-')
# Check if the word is hyphenated and matches the format "XXX-
XXXX"
if len(parts) == 2 and len(parts[0]) == 3 and len(parts[1]) == 4:
print(word)
Page: 9/21
1/2 mark for file opening + 1/2 mark for correct loop +1/2 mark for
correct use of split( ) + 1 mark for correct condition + 1/2 mark for
output

(A) You have a stack named MovieStack that contains records of movies.
30. Each movie record is represented as a list containing movie_title,
director_name, and release_year. Write the following user-defined functions
in Python to perform the specified operations on the stack MovieStack:

(I) push_movie(MovieStack, new_movie): This function takes the stack


MovieStack and a new movie record new_movie as arguments and pushes
the new movie record onto the stack.

(II) pop_movie(MovieStack): This function pops the topmost movie record


from the stack and returns it. If the stack is empty, the function should
display "Stack is empty".

(III) peek_movie(MovieStack): This function displays the topmost movie (3)


record from the stack without deleting it. If the stack is empty, the function
should display "None".

OR

(B) Write the definition of a user-defined function push_odd(M) which


accepts a list of integers in a parameter M and pushes all those integers
which are odd from the list M into a Stack named OddNumbers.

Write the function pop_odd() to pop the topmost number from the stack and
return it. If the stack is empty, the function should display "Stack is empty".

Write the function disp_odd() to display all elements of the stack without
deleting them. If the stack is empty, the function should display "None".

For example:

If the integers input into the list NUMBERS are: [7, 12, 9, 4, 15]

Then the stack OddNumbers should store: [7, 9, 15]

Ans : (A )
def push_movie(movie_stack, new_movie): # 1 mark

movie_stack.append(new_movie)

def pop_movie(movie_stack):

if not movie_stack: # 1 mark

return "Stack is empty"

Page: 10/21
return movie_stack.pop()

def peek_movie(movie_stack):

if not movie_stack: # 1 mark

return "None"

return movie_stack[-1]
OR

(B) def push_odd(M, odd_numbers):

for number in M: # 1mark

if number % 2 != 0:

odd_numbers.append(number)

def pop_odd(odd_numbers):

if not odd_numbers: # 1mark

return "Stack is empty"

return odd_numbers.pop()

def disp_odd(odd_numbers):

if not odd_numbers: # 1mark

return "None"

return odd_numbers

Page: 11/21
31. Predict the output of the following code:
data = [3, 5, 7, 2]
result = ""
for num in data:
for i in range(num):
result += str(i) + "*"
result = result[:-1]
print(result)
OR

Predict the output of the following code: (3)


numbers = [10, 15, 20]
for num in numbers:
for j in range(num // 5):
print(j, "+", end="")
print()

Ans : 0*1*2*0*1*2*3*4*0*1*2*3*4*5*6*0*1
( 1 mark for predicting correct output sequence of
numbers + 1 mark for predicting correct placement
of * + 1 mark for removing last * )

OR
0 +1 +
0 +1 +2 +
0 +1 +2 +3 +
( 1 MARK For putting output in three lines + 1 mark for
predicting correct sequence of numbers in each line (
1/2 for incorrect partially correct) + 1 mark for
correct placement of + )
Q No. Section-D ( 4 x 4 = 16 Marks) Marks

32. Consider the table ORDERS as given below

O_Id C_Name Product Quantity Price


1001 Jitendra Laptop 1 12000
1002 Mustafa Smartphone 2 10000
1003 Dhwani Headphone 1 1500
1004 Alice Smartphone 1 9000
1005 David Tablet NULL 7000

Note: The table contains many more records than shown here. (4)
A) Write the following queries:
(I) To display the total Quantity for each Product, excluding Products with
total Quantity less than 5.
(II) To display the ORDERS table sorted by total price in descending order.
(III) To display the distinct customer names from the ORDERS table.
Page: 12/21
(IV) To display the sum of the Price of all the orders for which the quantity
is NULL.
OR
B) Write the output:
(I) SELECT C_Name, SUM(Quantity) AS Total_Quantity FROM ORDERS
GROUP BY C_Name;
(II) SELECT * FROM ORDERS WHERE Product LIKE '%phone%';
(III) SELECT O_Id, C_Name, Product, Quantity, Price FROM ORDERS
WHERE Price BETWEEN 1500 AND 12000;
(IV) SELECT MAX(Price) FROM ORDERS;

Ans : (A) ( 1 MARK EACH)


(I) SELECT Product, SUM(Quantity) AS Total_Quantity
FROM ORDERS
GROUP BY Product
HAVING SUM(Quantity) >= 5;

(II)SELECT O_Id, C_Name, Product, Quantity, Price


FROM ORDERS
ORDER BY Price DESC;

(III)SELECT DISTINCT C_Name


FROM ORDERS;

(IV)SELECT SUM(Price) AS Total_Price_Null_Quantity


FROM ORDERS
WHERE Quantity IS NULL;

OR
(B) ( 1 MARK EACH )
(I)
C_Name Total_Quantity
Jitendra 1
Mustafa 2
Dhwani 1
Alice 1
David NULL

(II)
O_Id C_Name Product Quantity Price
1002 Mustafa Smartphone 2 10000
1004 Alice Smartphone 1 9000

Page: 13/21
(III)

O_Id C_Name Product Quantity Price


1001 Jitendra Laptop 1 12000
1002 Mustafa Smartphone 2 10000
1003 Dhwani Headphone 1 1500
1004 Alice Smartphone 1 9000
(IV)
MAX(Price)
12000

A CSV file "HealthData.csv" contains the data of a health survey. Each


33. record of the file contains the following data:

 Name of a country
 Life Expectancy (average number of years a person is expected to
live)
 GDP per capita (Gross Domestic Product per person)
 Percentage of population with access to healthcare
(4)
For example, a sample record of the file may be: ['Wonderland', 82.5, 40000,
95].

Write the following Python functions to perform the specified


operations on this file:

(I) Read all the data from the file in the form of a list and display all those
records for which the life expectancy is greater than 75.

(II) Count the number of records in the file.

Ans : (I)
import csv
def read_health_data(filename):
records = []
with open(filename, mode='r') as file:
reader = csv.reader(file)
next(reader) # Skip the header row if present
for row in reader:
country = row[0]
life_expectancy = float(row[1])
gdp_per_capita = float(row[2])
access_to_healthcare = float(row[3])
if life_expectancy > 75 :
records.append([country, life_expectancy, gdp_per_capita,
access_to_healthcare])
return records

Page: 14/21
(II)
def count_records( ):
records = read_health_data(“HealthData.csv”)
return len(records)
Alex has been tasked with managing the Student Database for a High
34. School. He needs to access some information from the STUDENTS and
SUBJECTS tables for a performance evaluation. Help him extract the
following information by writing the desired SQL queries as mentioned
below.
Table: STUDENTS
FNam Mark
S_ID LName Enrollment_Date
e s
201 John Doe 15-09-2020 85
202 Jane Smith 10-05-2019 90 (4)
Johnso
203 Alex 22-11-2021 75
n
204 Emily Davis 30-01-2022 60
Micha
205 Brown 17-08-2018 95
el

Table: SUBJECTS

Sub_ID S_ID SubName Credits


301 201 Mathematics 3
302 202 Science 4
303 203 History 2
304 204 Literature 3
305 205 Physics 4
Computer
306 201 3
Science
Write the following SQL queries:
(I) To display complete details (from both the tables) of those students
whose marks are greater than 70.
(II) To display the details of subjects whose credits are in the range of 2 to 4
(both values included).
(III) To increase the credits of all subjects by 1 which have "Science" in their
subject names.
(IV) (A) To display names (FName and LName) of students enrolled in the
"Mathematics" subject.
(OR)
(B) To display the Cartesian Product of these two tables.

Ans : ( I )
SELECT * FROM STUDENTS S
JOIN SUBJECTS Sub ON S.S_ID = Sub.S_ID
WHERE S.Marks > 70;

Page: 15/21
(II)
SELECT *
FROM SUBJECTS
WHERE Credits BETWEEN 2 AND 4;
(III)
UPDATE SUBJECTS
SET Credits = Credits + 1
WHERE SubName LIKE '%Science%';
(IV) A:
SELECT FName, LName
FROM STUDENTS S
JOIN SUBJECTS Sub ON S.S_ID = Sub.S_ID
WHERE Sub.SubName = 'Mathematics';
OR
B:
SELECT *
FROM STUDENTS, SUBJECTS;

A table, named ELECTRONICS, in the PRODUCTDB database, has the


35. following structure:

Field Type
productID int(11)
productName varchar(20)
price float
stockQty int(11)
(4)
Write the following Python function to perform the specified operation:

AddAndDisplay(): To input details of a product and store it in the table


ELECTRONICS. The function should then retrieve and display all records
from the ELECTRONICS table where the price is greater than 150.
Assume the following for Python-Database connectivity:
Host: localhost
User: root
Password: Electro123

Ans :
import mysql.connector
def AddAndDisplay():
# Connect to the database
conn = mysql.connector.connect(
host='localhost',
user='root',
password='Electro123',
database='PRODUCTDB'
)
cursor = conn.cursor()
productID = int(input("Enter Product ID: "))
Page: 16/21
productName = input("Enter Product Name: ")
price = float(input("Enter Price: "))
stockQty = int(input("Enter Stock Quantity: "))
cursor.execute("INSERT INTO ELECTRONICS
(productID, productName,
price, stockQty) VALUES (%s,
%s, %s, %s)", (productID,
productName, price, stockQty))
conn.commit()
cursor.execute("SELECT * FROM ELECTRONICS
WHERE price > 150")
records = cursor.fetchall()
print("\nRecords with price greater than 150:")
for record in records:
print(record)
cursor.close()
conn.close()|
(1 Mark for Declaration of correct Connection Object
+ 1 Mark for correct input + 1 marks for correctly
using execute( ) method + 1 marks for showing
output using loop )

Q.No. SECTION E (2 X 5 = 10 Marks) Marks


Raj is a supervisor at a software development company. He needs to
36. manage the records of various employees. For this, he wants the following
information of each employee to be stored:
Employee_ID – integer
Employee_Name – string
Position – string
Salary – float (5)
You, as a programmer of the company, have been assigned to do this job for
Raj.
(I) Write a function to input the data of an employee and append it to a binary
file.
(II) Write a function to update the data of employees whose salary is greater
than 50000 and change their position to "Team Lead".
(III) Write a function to read the data from the binary file and display the data
of all those employees who are not "Team Lead".

Ans : (I)
import pickle
def add_employee(filename):
employee_id = int(input("Enter Employee ID: "))
employee_name = input("Enter Employee Name: ")
position = input("Enter Position: ")
salary = float(input("Enter Salary: "))
new_employee = (employee_id, employee_name, position, salary)
with open(filename, 'ab') as file:
pickle.dump(new_employee, file)

(1/2 mark for input + 1 mark for correct use of dump( ) to add new emp
Page: 17/21
data)
(II)
def update_employee(filename):
employees = []
with open(filename, 'rb') as file:
try:
while True:
employees.append(pickle.load(file))
except EOFError:
pass
for i in range(len(employees)):
if employees[i][3] > 50000:
employees[i] = (employees[i][0], employees[i][1], "Team Lead",
employees[i][3])
with open(filename, 'wb') as file:
for employee in employees:
pickle.dump(employee, file)
(1 mark for correct use of load( ) method to retrieve data + 1/2 mark for
correct loop + 1/2 mark for correct condition within loop )

(III)
def display_non_team_leads(filename):
print("\nEmployees who are not Team Leads:")
with open(filename, 'rb') as file:
try:
while True:
employee = pickle.load(file)
if employee[2] != "Team Lead":
print(f"ID: {employee[0]}, Name: {employee[1]}, Position:
{employee[2]}, Salary: {employee[3]}")
except EOFError:
pass
( 1 mark for correct use of Try except block and 1/2 mark for correct
use of while loop )

Page: 18/21
Interstellar Logistics Ltd. is an international shipping company. They are
37. planning to establish a new logistics hub in Chennai, with the head office in
Bangalore. The Chennai hub will have four buildings - OPERATIONS,
WAREHOUSE, CUSTOMER_SUPPORT, and MAINTENANCE. As a
network specialist, your task is to propose the best networking solutions to
address the challenges mentioned in points (I) to (V), considering the
distances between the various buildings and the given requirements.

(5)
Building-to-Building Distances (in meters):

From To Distance
OPERATIONS WAREHOUSE 40 m
OPERATIONS CUSTOMER_SUPPORT 90 m
OPERATIONS MAINTENANCE 50 m
WAREHOUSE CUSTOMER_SUPPORT 60 m
WAREHOUSE MAINTENANCE 45 m
CUSTOMER_SUPPORT MAINTENANCE 55 m

Distance of Bangalore Head Office from Chennai Hub: 1300 km

Number of Computers in Each Building/Office:

Location Computers
OPERATIONS 40
WAREHOUSE 20
CUSTOMER_SUPPORT 25
MAINTENANCE 22
BANGALORE HEAD OFFICE 15

Page: 19/21
(I) Suggest the most suitable location for the server within the Chennai hub.
Justify your decision.

(II) Recommend the hardware device to connect all computers within each
building efficiently.

(III) Draw a cable layout to interconnect the buildings at the Chennai hub
efficiently. Which type of cable would you recommend for the fastest and
most reliable data transfer?

(IV) Is there a need for a repeater in the proposed cable layout? Justify your
answer.

(V) A) Recommend the best option for live video communication between the
Operations Office in the Chennai hub and the Bangalore Head Office from
the following choices:

 a) Video Conferencing
 b) Email
 c) Telephony
 d) Instant Messaging
OR

(V) B) What type of network (PAN, LAN, MAN, or WAN) would be set up
among the computers within the Chennai hub?

Ans :
(I) The server should be placed in the OPERATIONS building.
Justification:

 It has the largest number of computers (40), making it the most


central location in terms of the network load.
 The distances to other buildings are relatively short, ensuring
efficient data transfer. (1 Mark)

(II) A switch should be used within each building to connect all


computers. A switch is ideal for creating a local area network (LAN)
and ensures efficient communication between devices in a single
building. ( 1 Mark)

(III) The most efficient cable layout would involve connecting the
buildings as follows:

 OPERATIONS to WAREHOUSE (40 m)


 OPERATIONS to MAINTENANCE (50 m)
 OPERATIONS to CUSTOMER_SUPPORT (90 m)
 WAREHOUSE to MAINTENANCE (45 m)
 WAREHOUSE to CUSTOMER_SUPPORT (60 m)

Page: 20/21
CUSTOMER_SUPPORT

(90 m)

OPERATIONS

/ | \

(40 m) (50 m) (60 m)

/ | \

WAREHOUSE MAINTENANCE

Cable Recommendation: Fiber optic cable is recommended for high-


speed data transfer and reliable communication over distances. It
offers better bandwidth and lower signal degradation over long
distances than copper cables. ( 1/2 + 1/2 mark)

(III) There is no need for a repeater in this layout. The maximum distance
between any two buildings is 90 meters, which is well within the 100-meter
limit for Ethernet cable or fiber optics before requiring a repeater.

( 1 mark )

(IV) A) The best option for live communication between the Chennai
Operations Office and the Bangalore Head Office would be Video
Conferencing. This allows real-time face-to-face meetings and visual
communication across long distances, which is ideal for inter-office
collaboration.

OR

(V) B) The network type in the Chennai hub would be a LAN (Local Area
Network), as all computers are located within a confined geographical
area (the logistics hub) and are connected to each other for data
communication within the same campus.

(1 mark for any correct part solution )

Page: 21/21
अनक्र
ु म ांक/ROLL NO सेट/SET : 01

केंद्रीय विद्य लय सांगठन ,जयपुर सांभ ग


KENDRIYA VIDYALAYA SANGATHAN, JAIPUR REGION
प्रथम प्री बोर्ड परीक्ष / 1ST PRE BOARD EXAMINATION :2024-25
कक्ष / CLASS :XII
विषय /SUB : कांप्यूटर विज्ञ नां (83) /COMPUTER SCIENCE (83)
अधिकतम अिधि / Time Allowed :03 Hours अधिकतम अांक Maximum Marks : 70
स म न्य ननर्दे श / 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 the case of MCQ, the text of the correct answer should also be written.

Q. Section-A (21 x 1 = 21 Marks) Mark


1 State True or False: 1
The keys of a dictionary must be of immutable types.
2 Identify the output of the following code snippet: 1
str = "KENDRIYA VIDYALAYA"
str=str.replace('YA','*')
print(str)
(a) KENDRIYA VIDYALAYA (b) KENDRI*A VID*ALAYA
(c) KENDRI* VID*LA* (d) * KENDRI* VID*LA*
3 What will be the output of following expression? 1
(5<10 ) and (10< 5) or (3<18) and not 8<18
(a) True (b) False (c) Error (d) No output
4 What is the output of the expression? 1
St1=”abc@pink@city”
print(St1.split("@"))
(a) (“abc”, “@”, “pink”, “@”, “city”) (b) [“abc”, “@”, “pink”,”@’,”city”]
(c) [“abc”, “pink”, “city”] (d) Error
5 What will be the output of the following code snippet? 1
message= "Satyamev Jayate"
print(message[-2::-2])
6 Which of the following options will not result in an error when performed on types in 1
python where tp = (5,2,7,0,3) ?
(a) Tp[1] = 2 (b) tp.append(2)
(c) tp1 = tp+tp (d) tp.sum( )

Page 1 of 7
7 If my_dict is a dictionary as defined below, then which of the following statements will 1
raise an exception?
my_dict = {'aman': 10, 'sumit': 20, 'suresh': 30}
(a) my_dict.get('suresh') (b) print(my_dict['aman', 'sumit'])
(c) my_dict['aman']=20 (d) print(str(my_dict))
8 Which of the following can delete an element from a list if the index of the element is 1
given?
(a) pop( ) (b) remove( )
(c) clear( ) (d) all of these
9 Which of the following attributes can be considered as a choice for primary key? 1
(a) Name (b) Street
(c) Roll No (d) Subject
10 Write the missing statement to complete the following code: 1
file = open("abc.txt", "r")
d = file.read(50)
____________________ #Move the file pointer to the beginning of the file
next_data = file.read(75)
file.close()
11 State whether the following statement is True or False: 1
An exception may be raised even if the program is syntactically correct.
12 What will be the output of the following Python code ? 1
v = 50
def Change(n):
global v
v, n = n, v
print(v, n, sep = “#”, end = “@”)
Change(20)
print(v)
(a) 20#50@20 (b) 50@20#50
(c) 50#50#50 (d) 20@50#20
13 Which statement is used to modify data in a table? 1
(a) CHANGE (b) MODIFY (c) UPDATE (d) ALTER

14 How would you return all the rows from a table named "Item" sorted in descending 1
order on the column "IName"?
(a) SELECT * FROM Item SORT 'IName' DESC;
(b) SELECT * FROM Item ORDER BY IName DESC ;
(c) SELECT * FROM Item ORDER IName DESC ;
(d) SELECT * FROM Item SORT BY 'IName' DESC;
15 LIKE clause is used for. 1
(a) For pattern matching (b) For table matching
(c) For inserting similar data in a table (d) For deleting data from a table
16 Count(*) method count 1
(a) NULL values only (b)Empty Values
(c) ALL the values (d) None of these
17 The term HTTP stands for? 1
(a) Hyper terminal tracing program (b) Hypertext tracing protocol
(c) Hypertext transfer protocol (d) Hypertext transfer program

18 A device that connects networks with different protocols – 1


(a) Switch (b) Hub (c) Gateway (d) Proxy Server
19 Which switching technique follows the store and forward mechanism? 1

Page 2 of 7
Q20 and Q21 are Assertion(A) and Reason(R) 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
20 Assertion :- A parameter having a default value in the function header is known as a 1
default parameter.
Reason:- The default values for parameters are considered only if no value is
provided for that parameter in the function call statement.
21 Assertion :- Both WHERE and HAVING clauses are used to specify conditions.
Reason :- The WHERE and HAVING clauses are interchangeable.

Q Section-B ( 7 x 2=14 Marks) Mark


22 What are immutable and mutable types? List immutable and mutable types of 2
python.
23 If given A=2,B=1,C=3, What will be the output of following expressions: 2
(i) print((A>B) and (B>C) or(C>A))
(ii) print(A**B**C)
24 Write the most appropriate list method to perform the following tasks. 2
(I) A) To delete a given element from the list L1.
OR
B) To sort the elements of list L1 in ascending order.
(II) A) To add an element in the beginning of the list L1.
OR
B) To add elements of a list L2 in the end of a list L1.
25 What possible outputs(s) are expected to be displayed on screen at the time of 2
execution of the program from the following code? Also specify the maximum
values that can be assigned to each of the variables FROM and TO.
import random
AR=[20,30,40,50,60,70]
FROM=random.randint(1,3)
TO=random.randint(2,4)
for K in range(FROM,TO):
print (AR[K],end=”#“)
(i)10#40#70# (ii)30#40#50# (iii)50#60#70# (iv)40#50#70#
26 Rewrite the following code in Python after removing all syntax error(s). Underline 2
each correction done in the code.
p=30
for c in range(0,p)
If c%4==0:
print (c*4)
Elseif c%5==0:
print (c+3)
else
print(c+10)
27 (i) (A) What constraint should be applied on a table column so that duplicate 2
values are not allowed in that column, but NULL is allowed.
OR
Page 3 of 7
(B) What constraint should be applied on a table column so that NULL is not
allowed in that column, but duplicate values are allowed.
(ii)
(A) Write an SQL command to remove the Primary Key constraint from a table,
named MOBILE. M_ID is the primary key of the table.
OR
B) Write an SQL command to make the column M_ID the Primary Key of an
already existing table, named MOBILE.
28 (A) How is it easier to diagnose fault in Star topology than in Bus topology ? 2
OR
(B) Nirmala is a bit confused between the terms Web server and Web browsers.
Help her in understanding both the terms with the help of suitable example.

Q Section-C ( 3 x 3 = 9 Marks) Mark


29 (A) Write a Python function that count the lines start with the word “the” in a file 3
“xyz.txt” and display it at the end.
OR
B) Write a Python function that Count total number of vowels in a file “abc.txt”.
30 (A) Madhuri has a list containing 10 integers. You need to help him create a 3
program
with separate user defined functions to perform the following operations based on
this list.
● Traverse the content of the list and push the ODD numbers into a stack.
● Pop and display the content of the stack.
For Example:
If the sample Content of the list is as follows:
N=[12, 13, 34, 56, 21, 79, 98, 22, 35, 38]
Sample Output of the code should be:
13,21,89,35
OR
(B) Saroj have a list of 10 numbers . You need to help him create a program with
separate user defined functions to perform the following operations based on this
list.
● Traverse the content of the list and push the numbers into a stack which are
divisible by 5.
● Pop and display the content of the stack.
For Example:
If the sample Content of the list is as follows:
N=[2,5,10,13,20,23,45,56,60,78]
Sample Output of the code should be:
5,10,20,45,60
31 (A) Predict the output of the Python code given below: 3
def func(n1 = 1, n2= 2):
n1= n1 * n2
n2= n2 + 2
print(n1, n2)
func( )
func(2,3)

Page 4 of 7
OR
(B) Predict the output of the Python code given below:
T= [“20”, “50”, “30”, “40”]
Counter=3
Total= 0
for I in [7,5,4,6]:
newT=T[Counter]
Total= float (newT) + I
print(Total)
Counter=Counter-1

Q Section-D ( 4 x 4 = 16 Marks) Mark


32 Write SQL queries for (i)to(iv),which are based on the table: ACTIVITY given 4
below:
Table:ACTIVITY
ACode ActivityName ParticipantsNum PrizeMoney ScheduleDate
1001 Relay100x4 16 10000 23-Jan-2004
1002 Highjump 10 12000 12-Dec-2003
1003 ShotPut 12 8000 14-Feb-2004
1005 LongJump 12 9000 01-Jan-2004
1008 DiscussThrow 10 15000 19-Mar-2004
(i) To display the name of all activities with their Acodes in descending order.
(ii) To display sum of PrizeMoney for each of the Number of participants
groupings (as shown in column ParticipantsNum(10,12,16).
(iii) To display the Schedule Date and Participants Number for the activity
Relay100x4.
(iv) To increase PrizeMoney by 500 for High jump activity
OR
Write output for SQL queries(i) to(iii) and query for (iv),which are based on the
table: ACTIVITY:
(i) select count(distinct ParticipantsNum) from ACTIVITY;
(ii) select max(ScheduleDate),min(ScheduleDate) from ACTIVITY;
(iii) select sum(PrizeMoney) from ACTIVITY;
(iv) Write a query to delete the record of Acode 1003.
33 Abhishek is making a software on “Countries & their Capitals” in which various 4
records are to be stored/retrieved in CAPITAL.CSV data file. It consists of some
records. As a programmer, you have to help him to successfully execute the
program.

(A) Write a function in Python named AddNewRec(Country,Capital) to append


following records in the file “CAPITAL.CSV”.
[“FRANCE”,”PARIS”]
[“SRILANKA”,”COLOMBO”]
(B) Write a function in Python named ShowRec( ) that will show all the contents of
CAPITAL.CSV
34 Write SQL commands for the queries (i) to (iii) and output for (iv) & (v) based 4
on a table COMPANY and CUSTOMER .

Page 5 of 7
COMPANY
CID CNAME CITY PRODUCTNAME
111 SONY DELHI TV
222 NOKIA MUMBAI MOBILE
333 ONIDA DELHI TV
444 SONY MUMBAI MOBILE
555 BLACKBERRY MADRAS MOBILE
666 DELL DELHI LAPTOP

CUSTOMER
CUSTID NAME PRICE QTY CID
101 Rohan Sharma 70000 20 222
102 Deepak Kumar 50000 10 666
103 Mohan Kumar 30000 5 111
104 Sahil Bansal 35000 3 333
105 Neha Soni 25000 7 444
106 Sonal Aggarwal 20000 5 333
107 Arjun Singh 50000 15 666
(i) To display those company name along with price which are having price less
than 30000.
(ii) To display the name and price of the companies whose price is between 20000
to 35000.
(iii) To increase the price by 1000 for those customer whose name starts with ‘S’
(iv) To display those product name, city and price which are having product name
as MOBILE.
35 Kabir wants to write a program in Python to insert the following record in the table 4
named Student in MYSQL database, SCHOOL:
- rno(Roll number) – integer
- name(Name) – string
- DOB(Date of Birth) – Date
- Fee – float
Note the following to establish connectivity between Pythonand MySQL:
- Username – root
- Password – tiger
- Host – localhost
The values of fieldsrno, name, DOB and fee has to be accepted from the user.
Help Kabir to write the program in Python.

Q Section-E ( 2 x 5 = 10 Marks) Mark


36 Amit is a manager working in a recruitment agency. He needs to manage the 5
records of various candidates. For this, he wants the following information of each
candidate to be stored: -
Candidate_ID – integer
Candidate_Name – string
Designation – string
Experience – float

Page 6 of 7
You, as a programmer of the company, have been assigned to do this job for Amit.
(i) Write a function to input the data of a candidate and append it in a binary file.
(ii) Write a function to update the data of candidates whose experience is more
than 12 years and change their designation to "Sr. Manager".
(iii) Write a function to read the data from the binary file and display the data of all
those candidates who are not "Sr. Manager".
37 PVS Computers decided to open a new office at Ernakulum, the office consist of 5
Five Buildings and each contains number of computers. The details are shown
below.

Distance between the buildings

Building 1 and 2 20 Meters Building No of computers


1 40
Building 2 and 3 50 Meters
2 45
Building 3 and 4 120 Meters 3 110
4 70
Building 3 and 5 70 Meters
5 60
Building 1 and 5 65 Meters
Building 2 and 5 50 Meters

The Company has now decided to connect network in buildings.


(i)Suggest the most suitable place (i.e. building) to house the server of this
organization. Also give a reason to justify your suggested location.
(ii) Where would you place Hub/Switch? Answer with justification.
(iii) Suggest a cable layout of connection between the buildings (Topology).
(iv) Do you think anywhere Repeaters required in the campus? Why
(v) Suggest a protocol that shall be needed to provide Video Conferencing solution
between Ernakulum Campus and Ranchi Campus.
OR
What type of network (PAN, LAN, MAN, or WAN) will be set up among the
computers connected in the Ernakulum campus?

Page 7 of 7
Kendriya Vidyalaya Sangathan, Jaipur Region
Pre-Board Examination: 2024-25
Marking scheme Set No: 1
Class: XII Subject: Computer Science (083)
Maximum Marks: 70 Period: 3 Hours
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 the case of MCQ, the text of the correct answer should also be written.

Q. Section-A (21 x 1 = 21 Marks) Mark


Ans 1 True 1
(1 mark for correct answer)
Ans 2 (c) KENDRI* VID*LA* 1
(1 mark for correct answer)
Ans 3 (b) False 1
(1 mark for correct answer)
Ans 4 (c) [“abc”, “pink”, “city”] 1
(1 mark for correct answer)
Ans 5 tyJvmya 1
(1 mark for correct answer)
Ans 6 (c) tp1 = tp+tp 1
(1 mark for correct answer)
Ans 7 (b) print(my_dict['aman', 'sumit']) 1
(1 mark for correct answer)
Ans 8 (a) pop( ) 1
(1 mark for correct answer)
Ans 9 (c) Roll No 1
(1 mark for correct answer)
Ans10 file.seek(0) ( OR file.seek(0,0) ) 1
(1 mark for correct answer)
Ans11 True 1
(1 mark for correct answer)
Ans12 (a) 20#50@20 1
(1 mark for correct answer)
Ans13 (c) UPDATE 1
(1 mark for correct answer)
Ans14 (b) SELECT * FROM Item ORDER BY IName DESC ; 1
(1 mark for correct answer)
Ans15 (a) For pattern matching 1
(1 mark for correct answer)
Ans16 (c) ALL the values 1
(1 mark for correct answer)
Ans17 (c) Hypertext transfer protocol 1
(1 mark for correct answer)
Ans18 (c) Gateway 1
(1 mark for correct answer)
Ans19 Message Switching technique 1
(1 mark for correct answer)
Q20 and Q21 are Assertion(A) and Reason(R) 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
Ans20 (b) Both A and R are true and R is not the correct explanation for A 1
(1 mark for correct answer)
Ans21 (c) A is True but R is False
(1 mark for correct answer)

Q Section-B ( 7 x 2=14 Marks) Mark


Ans Immutable types are those that can never change their value in place. These are : 2
22 integers, float, string, tuple
Mutable types are those whose values can be changed in place. These are : lists,
dictionaries
(1 mark for each correct definition and example)
Ans (i) True 2
23 (ii) 2
(1 mark for each correct answer.)
Ans 2
24 (I) A) L1.remove(4)
OR
B) L1.sort( )
(II) A) L1.insert( )
OR
B) L1.extend(L2)
(1 mark for each correct answer)
Ans (ii)30#40#50# 2
25 Maximum value assigned to FROM is 3
Maximum value assigned to TO is 4
(1 mark for each correct answer)
(½ x 2 = 1 Mark for correct Maximum values)
Ans p=30 2
26 for c in range(0,p):
if c%4==0:
print (c*4)
elif c%5==0:
print (c+3)
else:
print(c+10)
(½ mark each for correcting 4 mistakes)
Ans (I) A) UNIQUE 2
27 OR
B) NOT NULL
(1 mark for correct answer)

(II) A) ALTER TABLE MOBILE DROP PRIMARY KEY;


OR
B) ALTER TABLE MOBILE ADD PRIMARY KEY (M_ID);
(1 mark for correct answer)
28 Ans: Fault diagnosis is easier in Star topology as if there is any problem in a node 2
will affect the particular node only. While in bus topology, if problem exists in
common medium it will affect the entire nodes.
OR
Web Server Web browser
A web server is a computer or a group A web browser is an application used
of computers that hosts or stores to access and view websites.
content of website. Common web browsers include
It processes and delivers web pages Microsoft Internet Explores, Google
of the websites to the users. Chrome etc.
The main job of a web server is to
display the website content
(2 mark for correct answer)

Q Section-C ( 3 x 3 = 9 Marks) Mark


29 (A) 3
Logic:- We need to split all the words of a every line and then check first word of
each line.
def count_the():
F=open(“abc.txt”,”r”)
L=F.readlines()
count=0
for x in L: # read all the lines one by one
L1=x.split() # It will split all the lines into words
if L1[0].lower() == “the” :
count=count+1
print(“total lines are :- “,count)
F.close()
(½ mark for correct function header)
(½ mark for correctly opening the file)
(½ mark for correctly reading from the file)
(½ mark for splitting the text into words/character)
(1 mark for correctly displaying the desired counts)
OR
(B)
Read the file character by character
def count_vowels():
F=open(“abc.txt”, “r”)
S=f.read()
Count=0
for x in S:
if x.lower() in “aeiou”:
count=count+1
print(“total number of vowels are :- “, count)
F.close()

(½ mark for correct function header)


(½ mark for correctly opening the file)
(½ mark for correctly reading from the file)
(½ mark for checking vowels)
(1 mark for correctly displaying the desired counts)
30 N=[12, 13, 34, 56, 21, 79, 98, 22,35, 38] 3
def PUSH(S,N):
S.append(N)
def POP(S):
if S!=[ ]:
return S.pop()
else:
return None
ST=[ ]
for k in N:
if k%2!=0:
PUSH(ST,k)
while True:
if ST!=[ ]:
print(POP(ST),end=" ")
else:
break
(2x1 mark for correct function body; 1 mark for function calling)
OR
(B) N= [2,5,10,13,20,23,45,56,60,78]
def PUSH(S,N):
S.append(N)
def POP(S):
if S!=[]:
return S.pop()
else:
return None
ST=[]
for k in N:
if k%5==0:
PUSH(ST,k)
while True:
if ST!=[]:
print(POP(ST),end=" ")
else:
break
(2x1 mark for correct function body; 1 mark for function calling)

31 2 4 3
65
OR
47.0
35.0
54.0
26.0
( 3 Mark for correct output, 1 mark for partial correct)

Q Section-D ( 4 x 4 = 16 Marks) Mark


32 i) Select ActivityName, Acode from ACTIVITY order by Acode desc; 4
ii) Select sum(PrizeMoney) from ACTIVITY group by ParticipantsNum;
iii) Select ScheduleDate, ParticipantsNum from ACTIVITY where
ActivityName = ‘Relay 100 x4’;
iv) Update ACTIVITY set PrizeMoney = PrizeMoney + 500 where
ActivityName = “High jump”;

(1 mark for each correct Query.)


OR
(i)
Count(distinct ParticipantsNum)

3
(ii)
Max(ScheduleDate) Min(ScheduleDate)

2004-03-19 2003-12-12
(iii)
Sum(PrizeMoney)

54000
(iv) delete from ACTIVITY where Acode = 1003;
(1 mark for each correct answer.)
Ans Ans: (a) 4
33 import csv
def AddNewRec(Country,Capital):
f=open("CAPITAL.CSV",'a')
fwriter=csv.writer(f,lineterminator="\n")
fwriter.writerow([Country,Capital])
f.close()
(b)
def ShowRec():
with open("CAPITAL.CSV","r") as NF:
NewReader=csv.reader(NF)
for rec in NewReader:
print(rec[0],rec[1])

AddNewRec(“FRANCE”,”PARIS”)
AddNewRec(“SRILANKA”,”COLOMBO”)
ShowRec()

Ans SQL Two table based question 4


34 (i) SELECT CNAME, PRICE FROM COMPANY, CUSTOMER WHERE
COMPANY.CID = CUSTOMER.CID AND PRICE < 30000;
(ii) SELECT CNAME, PRICE FROM COMPANY, CUSTOMER WHERE
COMPANY.CID = CUSTOMER.CID AND PRICE BETWEEN 20000 AND 35000;
(iii) UPDATE CUSTOMER SET PRICE = PRICE+1000 WHERE NAME LIKE “S%”;
(iv) SELECT PRODUCTNAME,CITY, PRICE FROM COMPANY,CUSTOMER
WHERE COMPANY.CID=CUSTOMER.CID AND PRODUCTNAME=”MOBILE”;
(1 mark for each correct query.)
Ans import mysql.connector as mysql 4
35 con1 = mysql.connect(host = “localhost”, user = “root”, password = “tiger”,
database = “sample”)
mycursor = con1.cursor( )
rno = int(input(“Enter Roll Number : “))
name = input(“Enter the name : “)
DOB = input(“Enter date of Birth : “)
fee = float(input(“Enter Fee : “
query = “INSERT into student values({ }, ‘{ }’, ‘{ }’ , { })”.format(rno,name,DOB,fee)
mycursor.execute(query)
con1.commit( )
print(“Data added successfully”)
con1.close( )
(½ mark for correctly importing the connector object)
(½ mark for correctly creating the connection object)
(½ mark for correctly creating the cursor object)
(½ mark for correctly inputting the data)
(1 mark for correct creation of query)
(½ mark for correctly executing the first query with commit
(½ mark for correctly displaying the data)

Q Section-E ( 2 x 5 = 10 Marks) Mark


Ans (I) import pickle 5
36 def input_candidates():
candidates = [ ]
n = int(input("Enter the number of candidates you want to add: "))
for i in range(n):
candidate_id = int(input("Enter Candidate ID: "))
candidate_name = input("Enter Candidate Name: ")
designation = input("Enter Designation: ")
experience = float(input("Enter Experience (in years): "))
candidates.append([candidate_id, candidate_name, designation,
experience])
return candidates
candidates_list = input_candidates()

def append_candidate_data(candidates):
with open('candidates.bin', 'ab') as file:
for candidate in candidates:
pickle.dump(candidate, file)
print("Candidate data appended successfully.")
append_candidate_data(candidates_list)

(II) import pickle


def update_senior_manager():
updated_candidates = [ ]
try:
with open('candidates.bin', 'rb') as file:
while True:
try:
candidate = pickle.load(file)
if candidate[3] > 10: # If experience > 10 years
candidate[2] = 'Senior Manager'
updated_candidates.append(candidate)
except EOFError:
break # End of file reached
except FileNotFoundError:
print("No candidate data found. Please add candidates first.")
return
with open('candidates.bin', 'wb') as file:
for candidate in updated_candidates:
pickle.dump(candidate, file)
print("Candidates updated to Senior Manager where applicable.")
update_senior_manager()

(III)
import pickle
def display_non_senior_managers():
try:
with open('candidates.bin', 'rb') as file:
while True:
try:
candidate = pickle.load(file)
if candidate[2] != 'Senior Manager': # Check if not Senior Manager
print(f"Candidate ID: {candidate[0]}")
print(f"Candidate Name: {candidate[1]}")
print(f"Designation: {candidate[2]}")
print(f"Experience: {candidate[3]}")
print("--------------------")
except EOFError:
break # End of file reached
except FileNotFoundError:
print("No candidate data found. Please add candidates first.")
display_non_senior_managers()

(1/2 mark of import pickle)


(1/2 mark for input)
(1/2 mark for opening file in append mode and 1/2 mark for using dump)
(1/2 mark for opening file in read mode and 1/2 mark for using load)
(1 mark for checking the condition and updating the value)
(1 mark for checking the condition and displaying data correctly)
(1 mark for try and except block)
37 Networking based question 5
(i) Server should be installed in Building 3 , As maximum computer is there
(ii) Hub/Switch installed in each and every building to connect computers in each
building.
(iii) Bus/ Star topology
(iv) No repeater is required as distance between building is less than 100 meter.
(v) Voip
OR
LAN (Local Area Network)

(1x5=5 mark for each correct answer)


केȾी य िीवOी लय सं गठन

Ůथम /िीȪत य Ůी बोड´ पर Ɨी -2024-25

KENDRIYA VIDYALAYA SANGATHAN, AGRA REGION

First /Second - Pre Board Examination-2024-25

कƗी XII (COMPUTER SCIENCE)

MARKING SCHEME

Max. Time – 3 hours Max. Marks – 70

ििधकतम समय - 3 घं टे ििधकतम िंक – 70

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.

Q. No. Section-A (21 x 1 = 21 Marks) Marks

1. False (1)

(1 mark for correct answer)

2. (C) ['L', '-', 'Structured', 'Q'] (1)


(1 mark for correct answer)

3. (D)True (1)

PAGE NO. 1 OF 11
(1 mark for correct answer)

4. (B) trip@spli (1)


(1 mark for correct answer)

5. (A) () (1)
(1 mark for correct answer)

6. (C) [ [“2”,”3”] ] (1)


(1 mark for correct answer)

7. (B) print(dict['Rose', 'Lily']) (1)


(1 mark for correct answer)

8. (D) None of the above (1)


(1 mark for correct answer)

9. (A) Cannot have NULL as well as UNIQUE values. (1)


(1 mark for correct answer)

10. (B) F.write(“PASS”) (1)


(1 mark for correct answer)

11. False (1)


(1 mark for correct answer)

12. 150 # 50 (1)


150 # 0
(1/2 mark for each correct line/answer)

13. DELETE (1)


(1 mark for correct answer)

14. (C) Display name of students whose name has ‘ar’ anywhere in name. (1)
(1 mark for correct answer)
15. (C) VARCHAR (1)
(1 mark for correct answer)

16. (B) ORDER BY (1)


(1 mark for correct answer)

17. (C) FTP (1)


(1 mark for correct answer)

PAGE NO. 2 OF 11
18. (D) REPEATER (1)
(1 mark for correct answer)

19. Topology (1)


(1 mark for correct answer)

20. (A) Both A and R are true and R is the correct explanation for A. (1)
(1 mark for correct answer)

21. (C) A is True but R is False. (1)


(1 mark for correct answer)
Q. No. Section-B ( 7 x 2=14 Marks) Marks

22. “in” operator results in True/False after checking a value in a range of (2)
values. (1 mark for correct answer)
“ONE” & [1,2,3] (1/2 mark for each correct answer)

23. 1. 6789 (2)


2. 6
(1 mark for each correct answer)

24. 1. (a) L2.pop() or any correct python function. (2)


OR
(b) L1.count(20)
2. (a) L2.extend([1, 0, 2])
OR
(b) L1.sort()
(1 mark for each correct answer)

25. (a) & (b) (2)


Maximum value of BEG: 2
Maximum value of END: 4
(1/2 mark for each correct answer)
(1/2 mark for each correct max. value of BEG & END)

26. Y=int(input(“Enter 1 or 10”)) (2)


if Y==10:
for Y in range(1,11):
print(Y)

PAGE NO. 3 OF 11
elif Y<10:
for m in range(5,0,-1):
print(“thank you”)
(1/2 mark for each correct answer)

27. 1. (a) CHECK constraint OR (b) PRIMARY KEY (2)


2. (a) SHOW TABLES;
OR
(b) DESCRIBE PLAYER; / DESC PLAYER;
(1 mark for each correct answer)

28. (A) MODEM stands Modulation-Demodulation. MODEM is used to connect (2)


to Internet through the conversion of digital signals into analog signals and
vice-versa.
(1 mark for each correct full form)
(1 mark for each correct use of MODEM)
OR
(B) XML stands for Extensible Markup Language. XML allows the
development more new markups/elements while HTML works only on the
already defined markups.
(1 mark for each correct full form)
(1 mark for each correct benefit of XML over HTML)
Q. No. Section-C ( 3 x 3 = 9 Marks) Marks

29. (3)

(1/2 mark for correct function header)

PAGE NO. 4 OF 11
(1/2 mark for correct opening of file)
(1/2 mark for correctly reading from the file)
(1 mark for any correct logic & it’s code)
(1/2 mark for printing correct output)
OR

(1/2 mark for correct function header)


(1/2 mark for correct opening of file)
(1/2 mark for correctly reading from the file)
(1 mark for any correct logic & it’s code)
(1/2 mark for printing correct output)

30. (I) (3)


def Push_Emp(Emp_Stack, New_Emp):
Emp_Stack.append(New_Emp)

(II)
def Pop_Emp(Emp_Stack):
if not Emp_Stack:
print("Underflow")
else:
return(Emp_Stack.pop())

(III)
def Peep(Emp_Stack):
if not Emp_Stack:
print("None")
else:

PAGE NO. 5 OF 11
print(Emp_Stack[-1])

(3x1 mark for correct function body; No marks for any function header as it
was a part of the question)

OR
(B)
(I)
def Push_State(D_STATE):
for I in D_STATE:
if len(D_STATE[I])<10:
STATE.append(D_STATE[I])

(II)
def Pop_State():
if not STATE:
print("Empty")
else:
return(STATE.pop())

(III)
def Disp_State():
if not STATE:
print("None")
else:
print(STATE [-1:-len(STATE)-1:-1])

(3x1 mark for correct function body; No marks for any function header as it
was a part of the question)

31. OUTPUT : cO*P*t*R (3)


(3 marks for correct line of output)
(deduct ½ mark for not printing **/*)
OR

PAGE NO. 6 OF 11
OUTPUT : (22,44,66)
(3 marks for correct line of output)
(deduct ½ mark for not printing parentheses/comma)
Q. No. Section-D ( 4 x 4 = 16 Marks) Marks

32. (A) Write SQL queries for the following: (4)


I. SELECT * FROM SURGERY ORDER BY STARTDATE DESC;
II. SELECT SUM(FEES) FROM SURGERY WHERE OTNO IS NULL;
III. SELECT SID, FEES FROM SURGERY WHERE SNAME LIKE
“D%”;
IV. SELECT COUNT(*) FROM SURGERY WHERE FEES<12000 AND
OTNO != 301;
(4 x 1 mark for each correct query)
OR
(B) Write the output of the given below SQL queries:-
I. DISTINCT(OTNO)
302
NULL
301
II. OTNO COUNT(*) MIN(FEES)
302 2 15000
III. SNAME
HEART
STOMOCH
IV. AVG(FEES)
16500
(4X1 mark each for correct output)

33. (I) (4)


import csv
def SHOW():
f=open("Population.csv",'r')
records=csv.reader(f)
next(records, None) #To skip the Header row

PAGE NO. 7 OF 11
for i in records:
if int(i[2])>200000:
print(i)
f.close()
(½ mark for opening in the file in right mode)
(½ mark for correctly creating the reader object)
(½ mark for correctly checking the condition)
(½ mark for correctly displaying the records)

(II)
import csv
def Count_City():
f=open("Population.csv",'r')
records=csv.reader(f)
next(records, None) #To skip the Header row
count=0
for i in records:
count+=1
print(count)
f.close()

(½ mark for opening in the file in right mode)


(½ mark for correctly creating the reader object)
(½ mark for correct use of counter)
(½ mark for correctly displaying the counter)

Note (for both parts (I) and (II)):


(i) Ignore import csv as it may be considered the part of the complete
program, and there is no need to import it in individual functions.
(ii) Ignore next(records, None) as the file may or may not have the Header
Row.

34. Write SQL commands for the following queries (i) to (iv) based on the (4)
relations TRAINER & COURSE given below:

PAGE NO. 8 OF 11
I. SELECT * FROM TRAINER WHERE CITY IS ”CHENNAI”;
II. SELECT CITY, COUNT(*) FROM TRAINER GROUP BY CITY;
III. SELECT * FROM COURSE WHERE FEES > 12000 AND
CNAME LIKE “%A”;
IV. (A) SELECT T.TNAME, C.CNAME FROM TRAINER T,
COURSE T WHERE T.TID=C.TID AND C.FEES<10000;
OR
(B) SELECT * FROM TRAINER, COURSE;
(4X1 mark each for correct QUERY)

35. def AddNewProduct(): (4)


import mysql.connector as mycon
mydb=mycon.connect(host="localhost",user="root",
passwd="Time",database="PRO_DB")
mycur=mydb.cursor()
pid=int(input("Enter Product ID: "))
pname=input("Enter Product Name: ")
company=input("Enter Company Name: ")
price=float(input("Enter price: "))
query="INSERT INTO PRODUCT VALUES ({}, '{}', '{}', {})"
query=query.format(pid, pname, company, price)
mycur.execute(query)
mydb.commit()
mycur.execute("select * from product where price<250")
for rec in mycur:
print(rec)

(½ mark for correctly importing the connector object)


(½ mark for correctly creating the connection object)
(½ mark for correctly creating the cursor object)
(½ mark for correctly inputting the data)
(½ mark for correct creation of first query)
(½ mark for correctly executing the first query with commit)
(½ mark for correctly executing the second query)

PAGE NO. 9 OF 11
(½ mark for correctly displaying the data)
Q. No. SECTION E (2 X 5 = 10 Marks) Marks

36. (I) (5)


import pickle
def NewTest():
Tid = int(input("Enter Test ID: "))
Sub= input("Enter Subject Name of Test: ")
MM = int(input("Enter Max. Marks of Test: ") )
SM = float(input("Enter Marks Scored in the Test: "))
REC = [Tid, Sub, MM, SM]

F=open(“TEST.DAT”,”ab”)
pickle.dump(REC, F)
F.close()

(II)
import pickle
def UpdateMM(Sub):
file=open(“TEST.DAT”,”rb”)
while True:
try:
rec = pickle.load(file)
if rec[1] == Sub:
rec[2]+=10
file.seek(-len(rec))
pickle.dump(rec, file)
print(“Max. Marks updated”)
except EOFError:
break # End of file reached

(III)
import pickle
def DisplayAvgMarks(Sub):

PAGE NO. 10 OF 11
sum=count=0
try:
with open('TEST.DAT', 'rb') as file:
while True:
try:
rec = pickle.load(file)
if rec[1] == Sub: # Check the subject
sum+=rec[3]
count+=1
except EOFError:
print(“Average marks of “, Sub, “ are : “, sum/count)
break # End of file reached
except FileNotFoundError:
print("No Test data found. Please add Test data first.")

(1/2 mark of import pickle)


(1/2 mark for input)
(1/2 mark for opening file in append mode and 1/2 mark for using dump)
(1/2 mark for opening file in read mode and 1/2 mark for using load)
(1 mark for checking the condition and updating the value)
(1 mark for checking the condition and displaying data correctly)

37. I. Bus/Star topology (5)


(½ mark for correct layout + ½ mark for correct topology name)
II. ADMIN
(1 mark for correct answer)
III. Hub/Switch
(1 mark for correct answer)
IV. ADMIN & RESOURCE
ADMIN & FINANCE
(½ mark each for correct name)
V. (A) (c) Optical Fiber
OR
(B) LAN
(1 mark for correct answer)

***************

PAGE NO. 11 OF 11
KENDRIYA VIDYALAYA SANGATHAN, CHENNAI REGION
CLASS: XII SESSION: 2024-25
PREBOARD
COMPUTER SCIENCE (083)
Time allowed: 3 Hours Maximum Marks: 70
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.

Q No. Section-A (21 x 1 = 21 Marks) Marks


1 State True or False 1
In Python, a dictionary is an ordered collection of items(key:value pairs).
2 State the output of the following 1
L1=[1,2,3] i) [1,3,7]
L2=L1
ii) [2,3,7]
L1.append(7)
L2.insert(2,14) iii) [1,14,3,7]
L1.remove(1) iv) [2,14,3,7]
print(L1)
3 The following expression will evaluate to 1
print(2+(3%5)**1**2/5+2)
i) 5 ii) 4.6 iii) 5.8 iv) 4

4 What is the output of the expression? 1


food=’Chinese Continental’
print(food.split(‘C’))
i) ('', 'hinese ', 'ontinental')
ii) ['', 'hinese ', 'ontinental']
iii) ('hinese ', 'ontinental')
iv) ['hinese ', 'ontinental']
5 What will be output of the following code snippet? 1
Msg=’Wings of Fire!’
print (Msg[-9: :2])
6 What will be the output of the following: 1
T1=(10)
print(T1*10)
i) 10 ii) 100 iii)(10,10) iv(10,)
7 If farm is a t as defined below, then which of the following will cause an exception? 1
farm={‘goat’:5,’sheep’:35,’hen’:10,’pig’:7}
i) print(str(farm))
ii) print(farm[‘sheep’,’hen’])
iii) print(farm.get(‘goat))
iv) farm[‘pig’]=17
8 What does the replace(‘e’,’h’) method of string does? 1
i) Replaces the first occurrence of ‘e’ to ‘h’
ii) Replaces the first occurrence of ‘h’ to ‘e’
iii) Replace all occurrences of ‘e’ to ‘h’
iv) Replaces all occurrences of ‘h’ to ‘e’
9 If a table has 1 primary key and 3 candidate key, how many alternate keys will be in 1
the table.
i) 4 ii) 3 iii)2 iv)1
10 Write the missing statement to complete the following code 1
file = open("story.txt")
t1 = file.read(10)
_________________________#Move the file pointer to the beginning of the file
t2= file.read(50)
print(t1+t2)
file.close()
11 Which of the following keyword is used to pass the control to the except block in 1
Exceptional handling?
i) pass ii) finally iii) raise iv)throw
12 What will be the output of the following code: 1
sal = 5000
def inc_sal(per):
global sal i) 5000%6000$
inc = sal * (per / 100) ii) 5500.0%6000$
sal += inc iii) 5000.0$6000%
inc_sal(10) iv) 5500%5500$
print(sal,end='%')
sal=6000
print(sal,end='$')

13 State the sql command used to add a column to an existing table? 1


14 What will be the output of the following query? 1
Mysql> SELECT * FROM CUSTOMER WHERE CODE LIKE ‘_A%’
A) Customer details whose code’s middle letter is A
B) Customers name whose code’s middle letter is A
C) Customers details whose code’s second letter is A
D) Customers name whose code’s second letter is A
15 Sushma created a table named Person with name as char(20) and address as 1
varchar(40). She inserted a record with “Adithya Varman” and address as “Vaanam
Illam, Anna Nagar IV Street”. State how much bytes would have been saved for this
record.
i)(20,34) ii)(30,40) iii)(14,40) iv)14,34)
16 _____ gives the number of values present in an attribute of a relation. 1
a)count(distinct col) b)sum(col) c)count(col) d)sum(distinct col)
17 The protocol used identify the corresponding url from ip address is _____ 1
a)IP b)HTTP c)TCP d)FTP
18 The device used to convert analog signal to digital signal and vice versa is .. 1
a)Amplifier b)Router c)Modem d)Switch
19 In ___________ switching technique, data is divided into chunks of packets and 1
travels through different paths and finally reach the destination.
Q20 and Q21 are Assertion(A) and Reason(R) 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
20 Assertion (A) : A function can have multiple return statements 1
Reason (R) : Only one return gets executed Values are returned as a tuple.
21 Assertion (A) : DROP is a DDL command 1
Reason(R ) : It is used to remove all the content of a database object

Q No. Section-B ( 7 x 2=14 Marks) Marks


22 Differentiate list and tuple with respect to mutability. Give suitable example to 2
illustrate the same .
23 Give two examples of each of the following 2
a) Assignment operators b) Logical operators
24 If L1 = [13,25,41,25,63,25,18,78] and L2= [58,56,25,74,56] 2
(i) A) Write a statement to remove fourth element from L1
Or
B) Write the statement to find maximum element in L2

(ii) (A) write a statement to insert L2 as the last element of L1


OR
(B) Write a statement to insert 15 as second element in L2
25 Identify the correct output(s) of the following code. Also write the minimum and the 2
maximum possible values of the variable Lot

import random
word='Inspiration'
Lot=2*random.randint(2,4)
for i in range(Lot,len(word),3):
print(word[i],end='$')

i) i$a$i$n$ ii) i$n$


iii) i$t$n$ iv) a$i$n$

26 Identify Primary Key and Candidate Key present if any in the below table name 2
Colleges. Justify
Streng
Cid Name Location Year AffiUniv PhoneNumber
th
University
St. Xavier's
1 Mumbai 1869 10000 of 022-12345678
College
Mumbai
Loyola University
2 Chennai 1925 5000 044-87654321
College of Madras
Hansraj Delhi
3 New Delhi 1948 4000 011-23456789
College University
Christ Christ
4 Bengaluru 1969 8000 080-98765432
University University
Lady Shri
Delhi
5 Ram New Delhi 1956 2500 011-34567890
University
College
27 (I) 2
(A) What constraint/s should be applied to the column in a table to make it as
alternate key?
OR
(B) What constraint should be applied on a column of a table so that it becomes
compulsory to insert the value
(II)
(A) Write an SQL command to assign F_id as primary key in the table named flight
OR
(B)Write an SQL command to remove the column remarks from the table name
customer.
28 List one advantage and disadvantage of star and bus topology 2
OR
Define DNS and state the use of Internet Protocol.

Q No. Section-C ( 3 x 3 = 9 Marks) Marks


29 (A) Write a function that counts no of words beginning with a capital letter from 3
the text file RatanJi.txt
Example:
If you want to Walk Fast,
Walk Alone.
But - if u want to Walk Far,
Walk Together
Output:
No of words starting with capital letter : 10

OR
(B) Write a function that displays the line number along with no of words in it
from the file Quotes.txt
Example :
None can destroy iron, but its own rust can!
Likewise, none can destroy a person, but their own mindset can
The only way to win is not be afraid of losing.
Output:
Line Number No of words
Line 1: 9
Line 2: 11
Line 3: 11
30 (A) There is a stack named Uniform that contains records of uniforms Each record 3
is represented as a list containing uid, uame, ucolour, usize, uprice.
Write the following user-defined functions in python to perform the specified
operations on the stack Uniform :
(I) Push_Uniform(new_uniform):adds the new uniform record onto the stack
(II) Pop_Uniform(): pops the topmost record from the stack and returns it. If
the stack is already empty, the function should display “underflow”.
(III) Peep(): This function diplay the topmost element of the stack without
deleting it.if the stack is empty,the function should display ‘None’.
OR
(a) Write the definition of a user defined function push_words(N) which accept
list of words as parameter and pushes words starting with A into the stack
named InspireA
(b) Write the function pop_words(N) to pop topmost word from the stack and
return it. if the stack is empty, the function should display “Empty”.

31 Predict the output of the Python code given below: 3


Con1="SILENCE-HOPE-SUCCEss@25"
Con2=""
i=0
while i<len(Con1):
if Con1[i]>='0' and Con1[i]<='9':
Num=int(Con1[i])
Num-=1
Con2=Con2+str(Num)
elif Con1[i]>='A' and Con1[i]<='Z':
Con2=Con2+Con1[i+1]
else:
Con2=Con2+'^'
i+=1
print(Con2)

Q Section-D ( 4 x 4 = 16 Marks) Mar


No. ks
32 Consider the following table named Vehicle and state the query or state the output 4
Table:- Vehicle
VID LicensePlate VType Owner Contact State
Cost
1 MH12AB1234 Car Raj Kumar 65 9876543210 Maharastra
2 DL3CDE5678 Truck Arjith Singh 125 8765432109 New Delhi
3 KA04FG9012 Motor cycle Prem Sharma 9123456789 Karnataka
4 TN07GH3456 SUV Shyad Usman 65 9987654321 Tamil Nadu
5 KA01AB1234 Car Devid jhon 65 9876543210 Karnataka
6 TN02CD5678 Truck Anjali Iyer 125 8765432109 Tamil Nadu
7 AP03EF9012 Motor cycle Priya Reddy 9123456789 Andhra Pradesh
(A)
(i) To display number of different vehicle type from the table vehicle
(ii) To display number of records entered vehicle type wise whose minimum cost is above 80
(iii)To set the cost as 45 for those vehicles whose cost is not mentioned
(iv) To remove all motor cycle from vehicle
OR
(B)
(i) SELECT VTYPE,AVG(COST) FROM VEHICLE GROUP BY VTYPE;
(ii) SELECT OWNER ,VTYPE,CONTACT FROM VEHICLE WHERE OWNER LIKE
“P%”;
(iii)SELECT COUNT(*) FROM VEHICLE WHERE COST IS NULL;
(iv) SELECT MAX(COST) FROM VEHICLE;
33 A CSV file “Movie.csv” contains data of movie details. Each record of the file contains the 4
following data:
1.Movie id
2.Movie name
3.Genere
4.Language
5.Released date
For example, a sample record of the file may be:
["tt0050083",’ ‘12 Angry Men is’,’Thriller’.’Hindi’,’12/04/1957’]
Write the following functions to perform the specified operations on this file
(i) Read all the data from the file in the form of the list and display all those records for
which language is in Hindi.
(ii) Count the number of records in the file.
34 Salman has been entrusted with the management of Airlines Database. He needs to access some 4
information from Airports and Flights tables for a survey. Help him extract the following
information by writing the desired SQL queries as mentioned below.
Table - Airports
A_ID A_Name City IATACode
1 Indira Gandhi Intl Delhi DEL
2 Chhatrapati Shivaji Intl Mumbai BOM
3 Rajiv Gandhi Intl Hyderabad HYD
4 Kempegowda Intl Bengaluru BLR
5 Chennai Intl Chennai MAA
6 Netaji Subhas Chandra Bose Intl Kolkata CCU
Table - Flights
F_ID A_ID F_No Departure Arrival
1 1 6E 1234 DEL BOM
2 2 AI 5678 BOM DEL
3 3 SG 9101 BLR MAA
4 4 UK 1122 DEL CCU
5 1 AI 101 DEL BOM
6 2 6E 204 BOM HYD
7 1 AI 303 HYD DEL
8 3 SG 404 BLR MAA
i) To display airport name, city, flight id, flight number corresponding flights whose
departure is from delhi
ii) Display the flight details of those flights whose arrival is BOM, MAA or CCU
iii) To delete all flights whose flight number starts with 6E.
iv) (A) To display Cartesian Product of two tables
OR
(B) To display airport name,city and corresponding flight number
35 A table named Event in VRMALL database has the following structure: 4

Field Type
EventID int(9)
EventName varchar(25)
EventDate date
Description varchar(30)
Write the following Python function to perform the specified operations:
Input_Disp(): to input details of an event from the user and store into the table Event. The
function should then display all the records organised in the year 2024.

Assume the following values for Python Database Connectivity


Host-localhost, user-root, password-tiger

Q No. Section-E ( 2 x 5 = 10 Marks) Marks


36 Ms Joshika is the Lab Attendant of the school. She is asked to maintain the project 5
details of the project synopsis submitted by students for upcoming Board Exams.
The information required are:
-prj_id - integer
-prj_name-string
-members-integer
-duration-integer (no of months)
As a programmer of the school u have been asked to do this job for Joshika and define
the following functions.
i) Prj_input() - to input data of a project of student and append to the binary
file named Projects
ii) Prj_update() - to update the project details whose member are more than 3
duration as 3 months.
iii) Prj_solo() - to read the data from the binary file and display the data of all
project synopsis whose member is one.
37 P&O Nedllyod Container Line Limited has its headquarters at London and regional 5
office at Mumbai. At Mumbai office campus they planned to have four blocks for HR,
Accts, Logistics and Admin related work. Each block has number of computers
connected to a network for communication, data and resource sharing
As a network consultant, you have to suggest best network related solutions for the
issues/problems raised in (i) to (v), keeping in mind the given parameters

REGIONAL OFFICE MUMBAI

HR ADMIN
London Head
Head Head
Office
Accts Logistics

Distances between various blocks/locations:


Admin to HR 500m
Accts to Admin 100m
Accts to HR 300m
Logistics to Admin 200m
HR to logistics 450m
Accts to logistics 600m
Number of computers installed at various blocks are as follows:
Block No of computers
ADMIN 95
HR 70
Accts 45
Logistics 28
i) Suggest the most appropriate block to place the sever in Mumbai office.
Justify your answer.
ii) State the best wired medium to efficiently connect various blocks within
the Mumbai Office.
iii) Draw the ideal cable layout (block to block) for connecting these blocks
for wired connectivity.
iv) The company wants to conduct an online meeting with heads of regional
office and headquarter. Which protocol will be used for the effective voice
communication?
v) Suggest the best place to house the following
a) Repeater b) Switch
KENDRIYA VIDYALAYA SANGATHAN, CHENNAI REGION
CLASS: XII SESSION: 2024-25
PREBOARD I MARKING SCHEME
COMPUTER SCIENCE (083)
Time allowed: 3 Hours Maximum Marks: 70

Q No. Section-A (21 x 1 = 21 Marks) Marks


1 False 1
(1 mark for correct answer)
2 iv) [2,14,3,7] 1
(1 mark for correct answer)
3 ii) 4.6 1
(1 mark for correct answer)
4 ii) ['', 'hinese ', 'ontinental'] 1
(1 mark for correct answer)
5 so ie 1
(1 mark for correct answer)
6 ii) 100 1
(1 mark for correct answer)
7 ii) print(farm[‘sheep’,’hen’]) 1
(1 mark for correct answer)
8 iii) Replace all occurrences of ‘e’ to ‘h’ 1
(1 mark for correct answer)
9 iii)2 1
(1 mark for correct answer)
10 file.seek(0) 1
(1 mark for correct answer)
11 iii) raise 1
(1 mark for correct answer)
12 ii) 5500.0%6000$ 1
(1 mark for correct answer)
13 ALTER (or ALTER TABLE) 1
(1 mark for correct answer)
14 iii) Customers details whose code’s second letter is A 1
(1 mark for correct answer)
15 i) (20,34) 1
(1 mark for correct answer)
16 c)count(col) 1
(1 mark for correct answer)
17 a)IP 1
(1 mark for correct answer)
18 c)Modem 1
(1 mark for correct answer)
19 Packet Switching 1
(1 mark for correct answer)
Q20 and Q21 are Assertion(A) and Reason(R) 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
20 A) Both A and B are true and R is the correct explanation for A 1
(1 mark for correct answer)
21 D) A is False B is True 1
Q No. Section-B ( 7 x 2=14 Marks) Marks
22 Difference 1 mark 2
Example ½ mark each
23 a) Assignment Operators = += -= *= **= /= //= %= 2
b) Logical Operators not and or (any two from each)
(1/2 mark for each correct operator)
24 2
(i) A) L1.pop(4)
Or
B) a=max(L2) or print(max(L2)

(ii) (A) L1.append(L2)


OR
(B) L2.insert(1,15)
25 Identify the correct output(s) of the following code. Also write the minimum and the 2
maximum possible values of the variable Lot
Minimum value possible for Lot: 4
Maximum value possible for Lot: 8
Possible outputs are : i) and ii)
26 Identify Primary Key and Candidate Key present if any in the below table name 2
Colleges. Justify
Primary Key: Cid its unique
Candidate Key: Cid, Name, PhoneNumber as they are have unique values

27 (I) 2
(A) UNIQUE ,NOT NULL
OR
(B) NOT NULL (PRIMARY KEY CAN BE GIVEN MARK)
(II)
(A) ALTER TABLE flight ADD PRIMARY KEY(F_id);
OR
(B) ALTER TABLE CUSTOMER DROP REMARKS;
28 STAR Adv DisAdv ½ mark each 2
BUS Adv DisAdv ½ mark each
OR
DNS definition 1 mark, IP purpose 1 mark

Q No. Section-C ( 3 x 3 = 9 Marks) Marks


29 a) Opening and closing file ½ mark 3
Read() ½ mark split() ½ mark
Loop ½ mark upper case checking ½ mark
Output display ½ mark
OR
b)
Opening and closing file ½ mark
Readlines() ½ mark
Loop ½ mark counting no of words ½ mark
Output display ½ mark
30 (1/2 for identifying even numbers) 3
(1/2 mark for correctly adding data to stack)
(1/2 mark for correctly poping data on the stack and 1/2 mark for checking
condition)
(1/2 mark for correctly displaying the data with none)
(1/2 mark for function call statements)
OR
(1 ½ mark for correct function body; No marks for any function header as it
was a part of the question)
31 ILENCE-^OPE-^UCCEs^^^14 correct o/p 3 mark 3

Q Section-D ( 4 x 4 = 16 Marks) Mar


No. ks
32 i) SELECT COUNT(DISTINCT VTYPE) FROM VEHICLE; 4
ii) SELECT VTYPE,COUNT(*) FROM VEHICLE GROUP BY VTYPE HAVING
MIN(COST)>80;
iii) UPDATE VEHICLE SET COST=45 WHERE COST IS NULL
iv) SELECT OWNER ,VTYPE,CONTACT FROM VEHICLE WHERE OWNER LIKE
“P%”;
OR
i)
+---------------------+-----------------+
| VTYPE | AVG(COST) |
+----------------------+-----------------+
| CAR | 65.0000 |
| truck | 125.0000 |
| Moter Cycle | NULL |
| SUV | 65.0000 |
| MOTOR CYCLE | NULL |
+----------------------+-----------------+
ii)
+--------------------+----------------------+------------------+
| OWNER | VTYPE | CONTACT |
+---------------------+----------------------+-----------------+
| Prem Sharma | Moter Cycle | 9987654321 |
| PRIYA REDDY | MOTOR CYCLE | 9123456789 |
+---------------------+----------------------+-----------------+
iii)
+---------------+
| COUNT(*) |
+--------------+
| 2|
+--------------+
iv)
+-----------------+
| MAX(COST) |
+-----------------+
| 125 |
+-----------------+

33 (½ mark for opening in the file in right mode) 4


(½ mark for correctly creating the reader object)
(½ mark for correctly checking the condition)
(½ mark for correctly displaying the records)
OR
(½ mark for opening in the file in right mode)
(½ mark for correctly creating the reader object)
(½ mark for correct use of counter)
(½ mark for correctly displaying the counter)
34 i) select airports.a_id,city,f_id,F_no from flights,airports where flights.f_id=airports.a_id 4
and departure="DEL";
ii) select * from flights where arrival="bom" or arrival="Maa" or arrival="ccu";
iii) delete from flights where F_no like "6E%";
iv) (A) select * from flights,airports;
OR
(b) select airports.a_id,city,flights.f_id from flights,airports where airports.a_id=flights.a_id;
35 4
#interface code
import mysql.connector as mn
def Input_Disp():
con=mc.connect(host="localhost",user="root",password="tiger",database="VRMALL")
cur=con.cursor()
print("Enter Event Details:")
eid=input("ID:")
ename=input("NAME:")
edate=input("DATE:")
des=input("Description:")
query="insert into Event values("+eid+",'"+ename+"','"+edate+"','"+des+"')"
cur.execute(query)
con.commit()
print("Record Inserted")

print("Details of Event organised in year 2024")


query="select * from Event where eventdate like '2024'"
cur.execute(query)
data=cur.fetchall()
print("ID NAME DATE DESCRIPTION")
for rec in data:
print(rec[0],rec[1],rec[2],rec[3],sep= " ")
con.close()
or any other relavant code
import ½ mark
Connectivity stmt ½ mark
Cursor creation query creation ,execute(), commit ½ mark each
Query creation, cursor execution ½ mark each
Fetching data and display loop ½ mark each
Q No Section-E ( 2 x 5 = 10 Marks) Mark
s
36 #binary file
def Prj_input():
file=open("Projects.dat","ab")
print("Enter Project Details:")
pid=int(input("ID:"))
pname=input("NAME:")
mem=int(input("MEMBERS:"))
dur=int(input("DURATION IN MONTHS:"))
rec=[pid,pname,mem,dur]
pickle.dump(rec,file)
file.close()
print("data inserted")
def Prj_update():
file=open("Projects.dat","rb+")
try:
while True:
pos=file.tell()
rec=pickle.load(file)
5
if rec[2]>3:
rec[3]=3
file.seek(pos)
pickle.dump(rec,file)
except EOFError:
pass
finally:
file.close()
print("Record modified")
def Prj_solo():
file=open("Projects.dat","rb")
try:
print("PROJECT DETAILS")
print("ID NAME MEMBERS DURATION")
while True:
import pickle ½ mark
rec=pickle.load(file)
input and ifclose ½ mark ,insert 1 mark
rec[2]==1:
try except block ½ mark loop ½ mark
print(rec[0],recc[1],rec[2],rec[3],sep=" ")
reading records , updation
file.seek(pos) ½ mark each
try catch block ½ mark
pickle.dump(rec,file)
loop except
½ markEOFError:
fetching and display ½ mark each
37 passi) Server to be placed in ADMIN block as it has maximum number of 5
file.close() computers(70 30 traffic rule)
ii) Coaxial cable/fiber optics
iii) Star topology or any other layout

LOGISTICS
ACCTS

ADMIN

HR

iv) VoIP Voice over internet Protocol


v)
a) Repeater –distance more then 90 m –all
..if fiber optical cable then no repeater
b) Switch- in each block as to connect computers
कें द्रीय विद्यालय संगठन, अहमदाबाद संभाग SET-1/A
KENDRIYA VIDYALAYA SANGATHAN, AHMEDABAD REGION
प्री-बोर्ड परीक्षा:2024-25
PRE-BOARD EXAMINATION: 2024-25

SUBJECT : COMPUTER SCIENCE(083) TIME : 3 HOURS


CLASS : XII MM : 70
----------------------------------------------------------------------------------------------------
सामान्यवनदेश/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.

Q.NO SECTION-A(21x1=21 Marks) MARKS

1 State True or False: (1)


“In a Python program, if a break statement is given in a nested loop, it
terminates the execution of all loops in one go.”

2 Identify the output of the following code snippet: (1)


T=(100)
print(T*2)
(A) Syntax error
(B) (200,)
(C) 200
(D) (100,100)
3 Given s1=“Hello”. Which of the following statements will give an error? (1)
(A) print(s1[4])
(B) s2=s1
(C) s1=s1[4]
(D) s1[4]= “Y”
4 Write the output of following expression: (1)
5>10 and not(10<15)
5 What is the output of the expression? (1)

Page 1 of 10
s='All the Best'
p=s.split("t")
print(p)
(A) ['All ', 'he Bes', '']
(B) (‘All ', 'he Bes', '')
(C) ['All ', 't', 'he', 'Bes', 't']
(D) Error
6 Given a Tuple tup1= (10, 20, 30, 40, 50, 60, 70, 80, 90). (1)
What will be the output of print (tup1 [-2: -5])?
(A) (80,70,60)
(B) ( )
(C) (60,70,80)
(D) Error
7 What will be the output of the following python dictionary operation? (1)
data = {'A':2000, 'B':2500, 'C':3000, 'A':4000}
print(data)
(A) {'A':2000, 'B':2500, 'C':3000, 'A':4000}
(B) {'A':2000, 'B':2500, 'C':3000}
(C) {'A':4000, 'B':2500, 'C':3000}
(D) It will generate an error.
8 _______ method is used to delete a given element from the list. (1)
9 Which of the following mode in file opening statement results or generates an (1)
error if the file does not exist?
(A) a+
(B) r+
(C) w+
(D) None of the above
10 Which of the following python statement will bring the read pointer to 10th (1)
character from the end of a file containing 100 characters, opened for reading
in binary mode.
(A) File.seek(10,0)
(B) File.seek(-10,2)
(C) File.seek(-10,1)
(D) File.seek(10,2)
11 State whether the following statement is True or False: (1)
An exception may be raised even if the program is syntactically correct.
12 What will be the output of the following code? (1)
V = 50
def Change(N):
Page 2 of 10
global V
V,N = N,V
print(V,N,sep=''#'', end=''@'')
Change(20)
print(V)
(A) 20@50#20
(B) 50@20#50
(C) 20#50@20
(D) 50#50#50
13 In SQL, which operator is used to check if the column has null value/no (1)
value?
14 Consider the following statement: (1)
SELECT emp_no, name FROM emp ________ designation;
Which of the following option will be used to display the employee number
and names of similar designations together?
(A) FIELD()
(B) GROUP BY
(C) ORDER BY
(D) Both (B) and (C)
15 In which datatype the data will consume the same number of bytes as (1)
declared and is right padded?
(A) DATE
(B) VARCHAR
(C) CHAR
(D) None of these
16 Which of the following aggregate functions ignore NULL values? (1)
(A) max()
(B) count()
(C) avg()
(D) All of these
17 Which of the following is used to view emails when internet is not available? (1)
(A) SMTP
(B) POP3
(C) PPP
(D) VoIP
18 Fill in the blank: (1)
The modem at the sender’s computer end acts as a ____________.
(A) Model
(B) Modulator
Page 3 of 10
(C) Demodulator
(D) Convertor
19 Which of the following transmission media has the highest bandwidth? (1)
(A) Co axial cable
(B) Fiber optic cable
(C) Twisted pair cable
(D) None of these
Q20 and Q21 are Assertion(A) and Reason(R) 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
20 Assertion (A): To use a function from a particular module, we need to import (1)
the module.
Reasoning (R): import statement can be written anywhere in the program,
before using a function from that module.
21 Assertion (A): COUNT function ignores DISTINCT (1)
Reasoning (R): DISTINCT ignores the duplicate values.
Q.NO SECTION-B(7x2=14 Marks) MARKS
22 Predict the output of the Python code given below: (2)
List1 = list("Examination")
List2 =List1[1:-1]
new_list = []
for i in List2:
j=List2.index(i)
if j%2==0:
List1.remove(i)
print(List1)
23 Difference between compile time and run time error. (2)
24 (A)Given is a Python string declaration: (2)
myexam="@@PRE BOARD EXAMINATION 2024@@"
Write the output of: print(myexam[::-2])
OR
(B)Write the output of the code given below:
my_dict = {"name": "Aman", "age": 26}
my_dict['age'] = 27
my_dict['address'] = "Delhi"
print(my_dict.items())
25 Find the correct output(s) of the following code. Also write the maximum and (2)

Page 4 of 10
minimum values that can be assigned to variable Y.
import random
X=random.random()
Y=random.randint(0,4)
print (int(X),":",Y+int(X))
(A) 0:0
(B) 1:6
(C) 2:4
(D) 0:3
26 A programmer has written a code to input a number and check whether it is (2)
prime or not. However the code is having errors. Rewrite the correct code and
underline the corrections made.
def prime():
n=int(input("Enter number to check :: ")
for i in range (2, n//2):
if n%i=0:
print("Number is not prime \n")
break
else:
print("Number is prime \n’)
27 (I) A) Write the SQL command to see the list of tables in a database. (2)
OR
B) Write the SQL command to insert a new record in the table.

(II) A) What constraint should be applied on a table column so that NULL is


not allowed in that column, but duplicate values are allowed.
OR
B) What constraint should be applied on a table column so that duplicate
values are not allowed in that column, but NULL is allowed.
28 (a) Write the full forms of the following: (i) POP (ii) HTTPS (2)
OR
(b) Name the protocol used for : (i)remote login (ii) file transferring
Q.NO SECTION-C(3x3=9 Marks) MARKS
29 Write a method SHOWLINES() in Python to read lines from text file (3)
‘EXAMCS.txt’ and display the lines which do not contain 'ke'.
Example: If the file content is as follows:
An apple a day keeps the doctor away.
We all pray for everyone’s safety.
A marked difference will come in our country.
Page 5 of 10
The SHOWLINES() function should display the output as:
We all pray for everyone’s safety.
OR
Write a function RainCount() in Python, which should read the content of a
text file “RAIN.txt” and then count and display the count of occurrence of
word rain (case-insensitive) in the file.
Example: If the file content is as follows:
It rained yesterday
It might rain today
I wish it rains tomorrow too
I love Rain
The RainCount() function should display the output as: Rain – 2
30 A list contains following record of a customer: (3)
[Customer_name, Phone_number, City]
Write the following user defined functions to perform given operations on the
stack named status:
(i) Push_element() - To Push an object containing name and Phone number of
customers who live in Goa 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.
OR
Write a function in Python, Push(SItem) where , SItem is a dictionary
containing the details of stationary items– {Sname:price}.
The function should push the names of those items in the stack who have
price greater than 75. Also display the count of elements pushed into the
stack.
For example:
If the dictionary contains the following data:
Ditem={"Pen":106,"Pencil":59,"Notebook":80,"Eraser":25}
The stack should contain:
Notebook
Pen
The output should be:
The count of elements in the stack is 2
31 Predict the output of the following code: (3)
s="All The Best"
n = len(s)
m=""
for i in range(0, n):

Page 6 of 10
if (s[i] >= 'a' and s[i] <= 'm'):
m = m +s[i].upper()
elif (s[i] >= 'n' and s[i] <= 'z'):
m = m +s[i-1]
elif (s[i].isupper()):
m = m + s[i].lower()
else:
m = m +'#'
print(m)
OR
Predict the output of the following code:
F1="WoNdERFUL"
F2="StuDenTS"
F3=""
for I in range(0,len(F2)+1):
if F1[I]>='A' and F1<='F':
F3=F3+F1[I]
elif F1[I]>='N' and F1[I]<='Z':
F3=F3+F2[I]
else:
F3=F3+"*"
print(F3)
Q.NO SECTION-D(4x4=16 Marks) MARKS
32 Write the output of the queries (i) to (iv) based on the table, TECH_COURSE (4)
given below:

A) Write the following queries:


(i) To display the details of the courses with names starting with ‘D’.
(ii) To display the fees of courses in descending order.
(iii) Display the sum of fees of all the courses for which TID is not null.
(iv) To display the course name with fees less than 15000.
OR
B) Write the output of following queries:
(i) SELECT DISTINCT TID FROM TECH_COURSE;

Page 7 of 10
(ii) SELECT TID, COUNT(*), MIN(FEES) FROM TECH_COURSE GROUP BY TID
HAVING COUNT(TID)>1;
(iii) SELECT CNAME FROM TECH_COURSE WHERE FEES>15000 ORDER BY
CNAME;
(iv) SELECT AVG(FEES) FROM TECH_COURSE WHERE FEES BETWEEN 15000
AND 17000;
33 Write a program in Python that defines and calls the following user defined (4)
functions:
a) ADD() – To accept and add data of an employee to a CSV file ‘record.csv’.
Each record consists of a list with field elements as empid, name and mobile
to store employee id, employee name and employee salary respectively.
b) COUNTR() – To count the number of records present in the CSV file named
‘record.csv’.
34 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
 Fees – Numeric
 Qtr – Numeric

Answer the following questions:


(i) Identify the attribute best suitable to be declared as a primary key.
(ii) Write the degree of the above table if table contains 4 rows.
(iii) Insert the following data into the attributes Rollno, Name, Class, Fees and
Qtr in fees table.
(iv) (A) Aman want to remove the table Fees table from the database School.
Which command will he use from the following:
a) DELETE FROM Fees;
b) DROP TABLE Fees;
c) DROP DATABASE Fees;
d) DELETE Fees FROM Fees;
OR
(iv) (B) Now Aman wants to display the structure of the table Fees, i.e, name
of the attributes and their respective data types that he has used in the table.
Write the query to display the same.

Page 8 of 10
35 A table named student, in school database, has the following structure: (4)
RollNo – integer
Name – string
Class – integer
Marks – integer
Write the following Python function to perform the specified operation:
DataDisplay(): To input details of student and store it in the table. The
function should then retrieve and displays only those records who have marks
greater than 75.
Note the following to establish connectivity between Python and MYSQL:
Username is root , Password is tiger.
Q.NO SECTION-E(2x5=10 Marks) MARKS
36 A binary file “Book.dat” has structure [BookNo, Book_Name, Author, Price] (5)
i. Write a user defined function CreateFile() to input data for a record and add
to Book.dat .
ii. Write a function CountRec(Author) in Python which accepts the Author
name as parameter and count and return number of books by the given
Author are stored in the binary file “Book.dat”
37 Reha Medicos Center has set up its new center in Dubai. It has four buildings (5)
as shown in the diagram given below:

Distance between various building are as follows:

Page 9 of 10
As a network expert, provide the best possible answer for the following
queries:
i) Draw the cable layout to efficiently connect various buildings.
ii) Suggest the most appropriate location of the server. Justify your choice.
iii) Suggest the placement of the following device with justification:
a) Repeater b) Hub/Switch
iv) Suggest a system (hardware/software) to prevent unauthorized access to
or from the network.
v) A) Which cable is best suited for above layout.
OR
B) What type of network (PAN, LAN, MAN, or WAN) will be set up
among the computers connected with each other?

************

Page 10 of 10
कें द्रीय विद्यालय संगठन, अहमदाबाद संभाग SET-1/A
KENDRIYA VIDYALAYA SANGATHAN, AHMEDABAD REGION
प्री-बोर्ड परीक्षा:2024-25
PRE-BOARD EXAMINATION: 2024-25
MARKING SCHEME

SUBJECT : COMPUTER SCIENCE(083) TIME : 3 HOURS


CLASS :XII MM : 70
----------------------------------------------------------------------------------------------------
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.

Q.NO SECTION-A(21x1=21 Marks) MARKS

1 False (1)

2 (C) 200 (1)

3 (D) s1[4]= “Y” (1)

4 False (1)

5 (A) ['All ', 'he Bes', ''] (1)

6 (B) ( ) (1)

7 (C) {'A':4000, 'B':2500, 'C':3000} (1)

8 remove() (1)

9 (B) r+ (1)

10 (B) File.seek(-10,2) (1)

11 True (1)

12 (C) 20#50@20 (1)

13 IS NULL (1)

Page 1 of 7
14 (B) GROUP BY (1)

15 (C) CHAR (1)

16 (D) All of these (1)

17 (B) POP3 (1)

18 (B) Modulator (1)

19 (B) Fiber optic cable (1)

20 (A)Both A and R are true and R is the correct explanation for A (1)

21 (D)A is False but R is True (1)

Q.NO SECTION-B(7x2=14 Marks) MARKS

22 ['E', 'a', 'i', 'a', 'i', 'n'] (2)

23 Any two correct differences between compile time and run time error (2)

24 (A) @40 OTNMX RO R@ (2)


OR
(B) dict_items([('name', 'SAM'), ('age', 27), ('address', 'MUMBAI')])
25 (A) and(D) are possible outputs (2)
Maximum:0
Minimum:3
26 def prime(): (2)
n=int(input("Enter number to check :: ")) #bracket missing
for i in range (2, n//2):
if n%i==0: # = missing
print("Number is not prime \n")
break #wrong indent
else:
print("Number is prime \n”) # quote mismatch
(½ mark for each correct correction made and underlined)
27 (I) A) SHOW TABLES (2)
OR
B) INSERT INTO
(II)A) ALTER TABLE <table name> DROP PRIMARY KEY;
OR
B) ALTER TABLE <table name> ADD PRIMARY KEY ( <primary key>);

(1 mark each for correct answer)


28 (i) POP – Post Office Protocol (2)

Page 2 of 7
(ii) HTTPS: Hyper Text Transfer Protocol Secure
OR
(i) Telnet
(ii) FTP
Q.NO SECTION-C(3x3=9 Marks) MARKS

29 def SHOWLINES(): (3)


f=open("EXAMCS.txt")
for line in f:
if 'ke' not in line:
print(line.strip())
f.close()
OR
def RainCount():
f=open('rain.txt')
data=f.read()
data=data.upper()
data=data.split()
c=data.count('RAIN')
print('Rain -',c)
f.close()
Any other correct code
(½ mark for correct function header)
(½ mark for correctly opening the file)
(½ mark for correctly reading from the file)
( ½ mark for splitting the text into words)
(1 mark for correctly displaying the desired output)
30 status=[] (3)
def Push_element(cust):
if cust[2]=="Goa":
L1=[cust[0],cust[1]]
status.append(L1)
def Pop_element ():
num=len(status)
while len(status)!=0:
dele=status.pop()
print(dele)
num=num-1
else:

Page 3 of 7
print("Stack Empty")

(1.5 marks for correct push_element() and 1.5 marks for correct
pop_element())
OR
stackItem=[]
def Push(SItem):
count=0
for k in SItem:
if (SItem[k]>=75):
stackItem.append(k)
count=count+1
print("The count of elements in the stack is : ", count)
(1 mark for correct function header
1 mark for correct loop
½ mark for correct If statement
½ mark for correct display of count)
31 aLL#tHE#bEes (3)
OR
S*u**n*S*
(deduct ½ mark for not printing * #)
Q.NO SECTION-D(4x4=16 Marks) MARKS

32 A) (4)
(i) SELECT * FROM TECH_COURSE WHERE CNAME LIKE ‘D%’;
(ii) SELECT FEES FROM TECH_COURSE ORDER BY FEES DESC;
(iii) SELECT SUM(FEES) AS TOTAL_FEES FROM TECH_COURSE WHERE TID IS
NOT NULL;
(iv) SELECT CNAME FROM TECH_COURSE WHERE FEES <15000;
OR
B) Write the output of following queries:
(i)

(ii)

Page 4 of 7
(iii)

(iv) 15500.00
(4 x 1 mark for each correct output)
33 import csv (4)
def ADD():
fout=open("record.csv","a",newline="\n")
wr=csv.writer(fout)
empid=int(input("Enter Employee id :: "))
name=input("Enter name :: ")
mobile=int(input("Enter mobile number :: "))
lst=[empid,name,mobile] ---------1/2 mark
wr.writerow(lst) ---------1/2 mark
fout.close()
def COUNTR():
fin=open("record.csv","r",newline="\n")
data=csv.reader(fin)
d=list(data)
print(len(d))
fin.close()
ADD()
COUNTR()
(½ mark for importing csv module
1½ marks each for correct definition of ADD() and COUNTR()
½ mark for function call statements)
34 i)Primary Key – Rollno (4)
ii)Degree of table= 5
iii)Insert into fees values(101,’Aman’,’XII’,5000);
iv)(A) DELETE FROM Fees;
OR
iv)(B) Desc Fees;
(4x1 mark for each correct query)
35 import mysql.connector as mysql (4)
def DataDisplay():
con1=mysql.connect(host="localhost",user="root",password="tiger",
database="school")
mycur= con1.cursor()
no=int(input("Enter Roll Number: "))
Page 5 of 7
nm=input("Enter Student Name: ")
class=int(input("Enter class: "))
marks=float(input("Enter marks: "))
query="INSERT INTO student VALUES ({},'{}',{},{})"
query=query.format(no,nm,class,marks)
mycur.execute(query)
con1.commit()
print("Students with marks greater than 75 are : ")
mycursor.execute("select * from student where Marks>75")
data= mycursor.fetchall()
for i in data:
print(i)
print()
(½ mark for correctly importing the connector object)
(½ mark for correctly creating the connection object)
(½ mark for correctly creating the cursor object)
(½ mark for correctly inputting the data)
(½ mark for correct creation of first query)
(½ mark for correctly executing the first query with commit)
(½ mark for correctly executing the second query)
(½ mark for correctly displaying the data)
Q.NO SECTION-E(2x5=10 Marks) MARKS

36 import pickle (5)


defcreateFile():
fobj=open("Book.dat","ab")
BookNo=int(input("Book Number : "))
Book_name=input("Name :")
Author = input("Author:" )
Price = int(input("Price : "))
rec=[BookNo,Book_Name,Author,Price]
pickle.dump(rec,fobj)
fobj.close()
defCountRec(Author):
fobj=open("Book.dat","rb")
num = 0
try:
while True:
rec=pickle.load(fobj)

Page 6 of 7
if Author==rec[2]:
num = num + 1
except:
fobj.close()
return num
Any other correct code
(1 mark of import pickle and function def)
(1 mark for input)
(1/2 mark for opening file in append mode and 1/2 mark for using dump)
(1/2 mark for opening file in read mode and 1/2 mark for using load)
(1 mark for checking the condition and updating the value)
(1 mark for checking the condition and displaying data correctly)
37 i) Layout- (5)

ii)The most appropriate location of the server would be Research Lab, as this
building contains the maximum number of computers.
(iii)
a) For layout1, since the cabling distance between Accounts to Store is quite
large, so a repeater would ideally be needed along their path to avoid loss of
signals during the course of data flow in this route. For layout2, since the
cabling distance between Store to Research Lab is quite large, so a repeater
would ideally be placed.
b) In both the layouts, a Hub/Switch each would be needed in all the
buildings to interconnect the group of cables from the different computers in
each building.
(iv) Firewall
(v) A) Twisted Pair cable / Ethernet cable
OR
B) LAN
(1 mark for correct answer)
************

Page 7 of 7
कें द्रीय विद्यालय संगठन, अहमदाबाद संभाग SET-1/B
KENDRIYA VIDYALAYA SANGATHAN, AHMEDABAD REGION
प्री-बोर्ड परीक्षा:2024-25
PRE-BOARD EXAMINATION: 2024-25

SUBJECT : COMPUTER SCIENCE(083) TIME : 3 HOURS


CLASS : XII MM : 70
----------------------------------------------------------------------------------------------------
सामान्यवनदेश/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.

Q.NO SECTION-A(21x1=21 Marks) MARKS

1 Write the output of following expression: (1)


5>10 and not(10<15)
2 Identify the output of the following code snippet: (1)
T=(100)
print(T*2)
(A) Syntax error
(B) (200,)
(C) 200
(D) (100,100)
3 Given s1=“Hello”. Which of the following statements will give an error? (1)
(A) print(s1[4])
(B) s2=s1
(C) s1=s1[4]
(D) s1[4]= “Y”
4 What is the output of the expression? (1)
s='All the Best'
p=s.split("t")
print(p)

Page 1 of 10
(A) ['All ', 'he Bes', '']
(B) (‘All ', 'he Bes', '')
(C) ['All ', 't', 'he', 'Bes', 't']
(D) Error
5 State True or False: (1)
“In a Python program, if a break statement is given in a nested loop, it
terminates the execution of all loops in one go.”

6 Given a Tuple tup1= (10, 20, 30, 40, 50, 60, 70, 80, 90). (1)
What will be the output of print (tup1 [-2: -5])?
(A) (80,70,60)
(B) ( )
(C) (60,70,80)
(D) Error
7 _______ method is used to delete a given element from the list. (1)
8 Which of the following mode in file opening statement results or generates an (1)
error if the file does not exist?
(A) a+
(B) r+
(C) w+
(D) None of the above
9 What will be the output of the following python dictionary operation? (1)
data = {'A':2000, 'B':2500, 'C':3000, 'A':4000}
print(data)
(A) {'A':2000, 'B':2500, 'C':3000, 'A':4000}
(B) {'A':2000, 'B':2500, 'C':3000}
(C) {'A':4000, 'B':2500, 'C':3000}
(D) It will generate an error.
10 Which of the following python statement will bring the read pointer to 10th (1)
character from the end of a file containing 100 characters, opened for reading
in binary mode.
(A) File.seek(10,0)
(B) File.seek(-10,2)
(C) File.seek(-10,1)
(D) File.seek(10,2)
11 In which datatype the data will consume the same number of bytes as (1)
declared and is right padded?
(A) DATE
(B) VARCHAR
(C) CHAR

Page 2 of 10
(D) None of these

12 Consider the following statement: (1)


SELECT emp_no, name FROM emp ________ designation;
Which of the following option will be used to display the employee number
and names of similar designations together?
(A) FIELD()
(B) GROUP BY
(C) ORDER BY
(D) Both (B) and (C)
13 In SQL, which operator is used to check if the column has null value/no (1)
value?
14 What will be the output of the following code? (1)
V = 50
def Change(N):
global V
V,N = N,V
print(V,N,sep=''#'', end=''@'')
Change(20)
print(V)
(A) 20@50#20
(B) 50@20#50
(C) 20#50@20
(D) 50#50#50
15 State whether the following statement is True or False: (1)
An exception may be raised even if the program is syntactically correct.
16 Fill in the blank: (1)
The modem at the sender’s computer end acts as a ____________.
(A) Model
(B) Modulator
(C) Demodulator
(D) Convertor
17 Which of the following transmission media has the highest bandwidth? (1)
(A) Co axial cable
(B) Fiber optic cable
(C) Twisted pair cable
(D) None of these
18 Which of the following aggregate functions ignore NULL values? (1)
(A) max()
Page 3 of 10
(B) count()
(C) avg()
(D) All of these
19 Which of the following is used to view emails when internet is not available? (1)
(A) SMTP
(B) POP3
(C) PPP
(D) VoIP
Q20 and Q21 are Assertion(A) and Reason(R) 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
20 Assertion (A): To use a function from a particular module, we need to import (1)
the module.
Reasoning (R): import statement can be written anywhere in the program,
before using a function from that module.
21 Assertion (A): COUNT function ignores DISTINCT (1)
Reasoning (R): DISTINCT ignores the duplicate values.
Q.NO SECTION-B(7x2=14 Marks) MARKS
22 Predict the output of the Python code given below: (2)
List1 = list("Examination")
List2 =List1[1:-1]
new_list = []
for i in List2:
j=List2.index(i)
if j%2==0:
List1.remove(i)
print(List1)
23 Difference between compile time and run time error. (2)
24 (A)Given is a Python string declaration: (2)
myexam="@@PRE BOARD EXAMINATION 2024@@"
Write the output of: print(myexam[::-2])
OR
(B)Write the output of the code given below:
my_dict = {"name": "Aman", "age": 26}
my_dict['age'] = 27
my_dict['address'] = "Delhi"
print(my_dict.items())

Page 4 of 10
25 Find the correct output(s) of the following code. Also write the maximum and (2)
minimum values that can be assigned to variable Y.
import random
X=random.random()
Y=random.randint(0,4)
print (int(X),":",Y+int(X))
(A) 0:0
(B) 1:6
(C) 2:4
(D) 0:3
26 A programmer has written a code to input a number and check whether it is (2)
prime or not. However the code is having errors. Rewrite the correct code and
underline the corrections made.
def prime():
n=int(input("Enter number to check :: ")
for i in range (2, n//2):
if n%i=0:
print("Number is not prime \n")
break
else:
print("Number is prime \n’)
27 (I) A) Write the SQL command to see the list of tables in a database. (2)
OR
B) Write the SQL command to insert a new record in the table.

(II) A) What constraint should be applied on a table column so that NULL is


not allowed in that column, but duplicate values are allowed.
OR
B) What constraint should be applied on a table column so that duplicate
values are not allowed in that column, but NULL is allowed.
28 (a) Write the full forms of the following: (i) POP (ii) HTTPS (2)
OR
(b) Name the protocol used for : (i)remote login (ii) file transferring
Q.NO SECTION-C(3x3=9 Marks) MARKS
29 Write a method SHOWLINES() in Python to read lines from text file (3)
‘EXAMCS.txt’ and display the lines which do not contain 'ke'.
Example: If the file content is as follows:
An apple a day keeps the doctor away.
We all pray for everyone’s safety.
Page 5 of 10
A marked difference will come in our country.
The SHOWLINES() function should display the output as:
We all pray for everyone’s safety.
OR
Write a function RainCount() in Python, which should read the content of a
text file “RAIN.txt” and then count and display the count of occurrence of
word rain (case-insensitive) in the file.
Example: If the file content is as follows:
It rained yesterday
It might rain today
I wish it rains tomorrow too
I love Rain
The RainCount() function should display the output as: Rain – 2
30 A list contains following record of a customer: (3)
[Customer_name, Phone_number, City]
Write the following user defined functions to perform given operations on the
stack named status:
(i) Push_element() - To Push an object containing name and Phone number of
customers who live in Goa 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.
OR
Write a function in Python, Push(SItem) where , SItem is a dictionary
containing the details of stationary items– {Sname:price}.
The function should push the names of those items in the stack who have
price greater than 75. Also display the count of elements pushed into the
stack.
For example:
If the dictionary contains the following data:
Ditem={"Pen":106,"Pencil":59,"Notebook":80,"Eraser":25}
The stack should contain:
Notebook
Pen
The output should be:
The count of elements in the stack is 2
31 Predict the output of the following code: (3)
s="All The Best"
n = len(s)
m=""

Page 6 of 10
for i in range(0, n):
if (s[i] >= 'a' and s[i] <= 'm'):
m = m +s[i].upper()
elif (s[i] >= 'n' and s[i] <= 'z'):
m = m +s[i-1]
elif (s[i].isupper()):
m = m + s[i].lower()
else:
m = m +'#'
print(m)
OR
Predict the output of the following code:
F1="WoNdERFUL"
F2="StuDenTS"
F3=""
for I in range(0,len(F2)+1):
if F1[I]>='A' and F1<='F':
F3=F3+F1[I]
elif F1[I]>='N' and F1[I]<='Z':
F3=F3+F2[I]
else:
F3=F3+"*"
print(F3)
Q.NO SECTION-D(4x4=16 Marks) MARKS
32 Write the output of the queries (i) to (iv) based on the table, TECH_COURSE (4)
given below:

A) Write the following queries:


(i) To display the details of the courses with names starting with ‘D’.
(ii) To display the fees of courses in descending order.
(iii) Display the sum of fees of all the courses for which TID is not null.
(iv) To display the course name with fees less than 15000.
OR
B) Write the output of following queries:

Page 7 of 10
(i) SELECT DISTINCT TID FROM TECH_COURSE;
(ii) SELECT TID, COUNT(*), MIN(FEES) FROM TECH_COURSE GROUP BY TID
HAVING COUNT(TID)>1;
(iii) SELECT CNAME FROM TECH_COURSE WHERE FEES>15000 ORDER BY
CNAME;
(iv) SELECT AVG(FEES) FROM TECH_COURSE WHERE FEES BETWEEN 15000
AND 17000;
33 Write a program in Python that defines and calls the following user defined (4)
functions:
a) ADD() – To accept and add data of an employee to a CSV file ‘record.csv’.
Each record consists of a list with field elements as empid, name and mobile
to store employee id, employee name and employee salary respectively.
b) COUNTR() – To count the number of records present in the CSV file named
‘record.csv’.
34 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
 Fees – Numeric
 Qtr – Numeric

Answer the following questions:


(i) Identify the attribute best suitable to be declared as a primary key.
(ii) Write the degree of the above table if table contains 4 rows.
(iii) Insert the following data into the attributes Rollno, Name, Class, Fees and
Qtr in fees table.
(iv) (A) Aman want to remove the table Fees table from the database School.
Which command will he use from the following:
a) DELETE FROM Fees;
b) DROP TABLE Fees;
c) DROP DATABASE Fees;
d) DELETE Fees FROM Fees;
OR
(iv) (B) Now Aman wants to display the structure of the table Fees, i.e, name
of the attributes and their respective data types that he has used in the table.

Page 8 of 10
Write the query to display the same.
35 A table named student, in school database, has the following structure: (4)
RollNo – integer
Name – string
Class – integer
Marks – integer
Write the following Python function to perform the specified operation:
DataDisplay(): To input details of student and store it in the table. The
function should then retrieve and displays only those records who have marks
greater than 75.
Note the following to establish connectivity between Python and MYSQL:
Username is root , Password is tiger.
Q.NO SECTION-E(2x5=10 Marks) MARKS
36 A binary file “Book.dat” has structure [BookNo, Book_Name, Author, Price] (5)
i. Write a user defined function CreateFile() to input data for a record and add
to Book.dat .
ii. Write a function CountRec(Author) in Python which accepts the Author
name as parameter and count and return number of books by the given
Author are stored in the binary file “Book.dat”
37 Reha Medicos Center has set up its new center in Dubai. It has four buildings (5)
as shown in the diagram given below:

Distance between various building are as follows:

Page 9 of 10
As a network expert, provide the best possible answer for the following
queries:
i) Draw the cable layout to efficiently connect various buildings.
ii) Suggest the most appropriate location of the server. Justify your choice.
iii) Suggest the placement of the following device with justification:
a) Repeater b) Hub/Switch
iv) Suggest a system (hardware/software) to prevent unauthorized access to
or from the network.
v) A) Which cable is best suited for above layout.
OR
B) What type of network (PAN, LAN, MAN, or WAN) will be set up
among the computers connected with each other?

************

Page 10 of 10
कें द्रीय विद्यालय संगठन, अहमदाबाद संभाग SET-1/B
KENDRIYA VIDYALAYA SANGATHAN, AHMEDABAD REGION
प्री-बोर्ड परीक्षा:2024-25
PRE-BOARD EXAMINATION: 2024-25
MARKING SCHEME

SUBJECT : COMPUTER SCIENCE(083) TIME : 3 HOURS


CLASS :XII MM : 70
----------------------------------------------------------------------------------------------------
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.

Q.NO SECTION-A(21x1=21 Marks) MARKS

1 False (1)

2 (C) 200 (1)

3 (D) s1[4]= “Y” (1)

4 (A) ['All ', 'he Bes', ''] (1)

5 False (1)

6 (B) ( ) (1)

7 remove() (1)

8 (B) r+ (1)

9 (C) {'A':4000, 'B':2500, 'C':3000} (1)

10 (B) File.seek(-10,2) (1)

11 (C) CHAR (1)

12 (B) GROUP BY (1)

13 IS NULL (1)

Page 1 of 7
14 (C) 20#50@20 (1)

15 True (1)

16 (B) Modulator (1)

17 (B) Fiber optic cable (1)

18 (D) All of these (1)

19 (B) POP3 (1)

20 (A)Both A and R are true and R is the correct explanation for A (1)

21 (D)A is False but R is True (1)

Q.NO SECTION-B(7x2=14 Marks) MARKS

22 ['E', 'a', 'i', 'a', 'i', 'n'] (2)

23 Any two correct differences between compile time and run time error (2)

24 (A) @40 OTNMX RO R@ (2)


OR
(B) dict_items([('name', 'SAM'), ('age', 27), ('address', 'MUMBAI')])
25 (A) and(D) are possible outputs (2)
Maximum:0
Minimum:3
26 def prime(): (2)
n=int(input("Enter number to check :: ")) #bracket missing
for i in range (2, n//2):
if n%i==0: # = missing
print("Number is not prime \n")
break #wrong indent
else:
print("Number is prime \n”) # quote mismatch
(½ mark for each correct correction made and underlined)
27 (I) A) SHOW TABLES (2)
OR
B) INSERT INTO
(II)A) ALTER TABLE <table name> DROP PRIMARY KEY;
OR
B) ALTER TABLE <table name> ADD PRIMARY KEY ( <primary key>);

(1 mark each for correct answer)


28 (i) POP – Post Office Protocol (2)

Page 2 of 7
(ii) HTTPS: Hyper Text Transfer Protocol Secure
OR
(i) Telnet
(ii) FTP
Q.NO SECTION-C(3x3=9 Marks) MARKS

29 def SHOWLINES(): (3)


f=open("EXAMCS.txt")
for line in f:
if 'ke' not in line:
print(line.strip())
f.close()
OR
def RainCount():
f=open('rain.txt')
data=f.read()
data=data.upper()
data=data.split()
c=data.count('RAIN')
print('Rain -',c)
f.close()
Any other correct code
(½ mark for correct function header)
(½ mark for correctly opening the file)
(½ mark for correctly reading from the file)
( ½ mark for splitting the text into words)
(1 mark for correctly displaying the desired output)
30 status=[] (3)
def Push_element(cust):
if cust[2]=="Goa":
L1=[cust[0],cust[1]]
status.append(L1)
def Pop_element ():
num=len(status)
while len(status)!=0:
dele=status.pop()
print(dele)
num=num-1
else:

Page 3 of 7
print("Stack Empty")

(1.5 marks for correct push_element() and 1.5 marks for correct
pop_element())
OR
stackItem=[]
def Push(SItem):
count=0
for k in SItem:
if (SItem[k]>=75):
stackItem.append(k)
count=count+1
print("The count of elements in the stack is : ", count)
(1 mark for correct function header
1 mark for correct loop
½ mark for correct If statement
½ mark for correct display of count)
31 aLL#tHE#bEes (3)
OR
S*u**n*S*
(deduct ½ mark for not printing * #)
Q.NO SECTION-D(4x4=16 Marks) MARKS

32 A) (4)
(i) SELECT * FROM TECH_COURSE WHERE CNAME LIKE ‘D%’;
(ii) SELECT FEES FROM TECH_COURSE ORDER BY FEES DESC;
(iii) SELECT SUM(FEES) AS TOTAL_FEES FROM TECH_COURSE WHERE TID IS
NOT NULL;
(iv) SELECT CNAME FROM TECH_COURSE WHERE FEES <15000;
OR
B) Write the output of following queries:
(i)

(ii)

Page 4 of 7
(iii)

(iv) 15500.00
(4 x 1 mark for each correct output)
33 import csv (4)
def ADD():
fout=open("record.csv","a",newline="\n")
wr=csv.writer(fout)
empid=int(input("Enter Employee id :: "))
name=input("Enter name :: ")
mobile=int(input("Enter mobile number :: "))
lst=[empid,name,mobile] ---------1/2 mark
wr.writerow(lst) ---------1/2 mark
fout.close()
def COUNTR():
fin=open("record.csv","r",newline="\n")
data=csv.reader(fin)
d=list(data)
print(len(d))
fin.close()
ADD()
COUNTR()
(½ mark for importing csv module
1½ marks each for correct definition of ADD() and COUNTR()
½ mark for function call statements)
34 i)Primary Key – Rollno (4)
ii)Degree of table= 5
iii)Insert into fees values(101,’Aman’,’XII’,5000);
iv)(A) DELETE FROM Fees;
OR
iv)(B) Desc Fees;
(4x1 mark for each correct query)
35 import mysql.connector as mysql (4)
def DataDisplay():
con1=mysql.connect(host="localhost",user="root",password="tiger",
database="school")
mycur= con1.cursor()
no=int(input("Enter Roll Number: "))
Page 5 of 7
nm=input("Enter Student Name: ")
class=int(input("Enter class: "))
marks=float(input("Enter marks: "))
query="INSERT INTO student VALUES ({},'{}',{},{})"
query=query.format(no,nm,class,marks)
mycur.execute(query)
con1.commit()
print("Students with marks greater than 75 are : ")
mycursor.execute("select * from student where Marks>75")
data= mycursor.fetchall()
for i in data:
print(i)
print()
(½ mark for correctly importing the connector object)
(½ mark for correctly creating the connection object)
(½ mark for correctly creating the cursor object)
(½ mark for correctly inputting the data)
(½ mark for correct creation of first query)
(½ mark for correctly executing the first query with commit)
(½ mark for correctly executing the second query)
(½ mark for correctly displaying the data)
Q.NO SECTION-E(2x5=10 Marks) MARKS

36 import pickle (5)


defcreateFile():
fobj=open("Book.dat","ab")
BookNo=int(input("Book Number : "))
Book_name=input("Name :")
Author = input("Author:" )
Price = int(input("Price : "))
rec=[BookNo,Book_Name,Author,Price]
pickle.dump(rec,fobj)
fobj.close()
defCountRec(Author):
fobj=open("Book.dat","rb")
num = 0
try:
while True:
rec=pickle.load(fobj)

Page 6 of 7
if Author==rec[2]:
num = num + 1
except:
fobj.close()
return num
Any other correct code
(1 mark of import pickle and function def)
(1 mark for input)
(1/2 mark for opening file in append mode and 1/2 mark for using dump)
(1/2 mark for opening file in read mode and 1/2 mark for using load)
(1 mark for checking the condition and updating the value)
(1 mark for checking the condition and displaying data correctly)
37 i) Layout- (5)

ii)The most appropriate location of the server would be Research Lab, as this
building contains the maximum number of computers.
(iii)
a) For layout1, since the cabling distance between Accounts to Store is quite
large, so a repeater would ideally be needed along their path to avoid loss of
signals during the course of data flow in this route. For layout2, since the
cabling distance between Store to Research Lab is quite large, so a repeater
would ideally be placed.
b) In both the layouts, a Hub/Switch each would be needed in all the
buildings to interconnect the group of cables from the different computers in
each building.
(iv) Firewall
(v) A) Twisted Pair cable / Ethernet cable
OR
B) LAN
(1 mark for correct answer)
************

Page 7 of 7

You might also like