ALL-In-OnE XII CS PB QP MS 2024-25 From Know Python Bytes
ALL-In-OnE XII CS PB QP MS 2024-25 From Know Python Bytes
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
(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
()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
OR
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="#")
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
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
(ü) 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:
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)
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
Password: airplane
" Host: localhost
BUSINESS 25
BLOCK
TECHNOLOGY 40
BLOCK
LAW BLOCK 15
HRCENTRE 115
OR
SSS-1207 16
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
(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
()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
OR
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="#")
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
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
(ü) 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:
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)
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
Password: airplane
" Host: localhost
BUSINESS 25
BLOCK
TECHNOLOGY 40
BLOCK
LAW BLOCK 15
HRCENTRE 115
OR
SSS-1207 16
OR
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
OR
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:
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
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
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
(22,44,66)
OR
DDL- ALTER,
DROP DML –
INSERT, UPDATE
(½ mark for each correct categorization)
SECTION C
29. (a) output 1+2
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()
[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]
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
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()
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()
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;
Page 4 of 8
(iii) Select o_id, c_name, product, quantity, price from orders where the price between
1500 and 12000;
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")
Page 6 of 8
for row in resultset:
print(row)
cursor.close()
mycon.close()
else:
print("Unable to Fetch Attendance!")
Medicine
Admin
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.
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?
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)
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.
HR
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.
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)
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)
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.
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.
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).
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
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.
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
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)]
(ii) Display all data separated by Department and in decreasing order of Salary:
SELECT * FROM Faculty ORDER BY Department, Salary DESC;
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%';
(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()
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: "))
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.
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)
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:
(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.
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?
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.
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)
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:
(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]
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
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.
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
Field Type
productID int(11)
productName varchar(20)
price float
stockQty int(11)
Write the following Python function to perform the specified operation: (4)
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
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 )
Ans : True
2. What id the output of following code snippet?
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
(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)
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.
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:
(A) tell
(B) seek
(C) read
(D) write
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)
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)
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
( 1 marks + 1 Marks )
Ans :
Page: 6/21
If L1 = [10, 20, 30, 40, 20, 10, ...] and L2 = [5, 15, 25, ...], then:
24.
(Answer using builtin functions only)
II (A) : L1.extend(L2)
(B) : unique_elements = list(set(L1))
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] )
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
( 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
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:
OR
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]
Ans : (A )
def push_movie(movie_stack, new_movie): # 1 mark
movie_stack.append(new_movie)
def pop_movie(movie_stack):
Page: 10/21
return movie_stack.pop()
def peek_movie(movie_stack):
return "None"
return movie_stack[-1]
OR
if number % 2 != 0:
odd_numbers.append(number)
def pop_odd(odd_numbers):
return odd_numbers.pop()
def disp_odd(odd_numbers):
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
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
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;
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)
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].
(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.
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
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;
Field Type
productID int(11)
productName varchar(20)
price float
stockQty int(11)
(4)
Write the following Python function to perform the specified operation:
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 )
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
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:
(III) The most efficient cable layout would involve connecting the
buildings as follows:
Page: 20/21
CUSTOMER_SUPPORT
(90 m)
OPERATIONS
/ | \
/ | \
WAREHOUSE MAINTENANCE
(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.
Page: 21/21
अनक्र
ु म ांक/ROLL NO सेट/SET : 01
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
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.
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
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.
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.
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.
31 2 4 3
65
OR
47.0
35.0
54.0
26.0
( 3 Mark for correct output, 1 mark for partial correct)
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()
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)
(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()
OR
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
OR
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:
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
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
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
(22,44,66)
OR
DDL- ALTER,
DROP DML –
INSERT, UPDATE
(½ mark for each correct categorization)
SECTION C
29. (a) output 1+2
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()
[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]
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
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()
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()
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;
Page 4 of 8
(iii) Select o_id, c_name, product, quantity, price from orders where the price between
1500 and 12000;
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")
Page 6 of 8
for row in resultset:
print(row)
cursor.close()
mycon.close()
else:
print("Unable to Fetch Attendance!")
Medicine
Admin
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.
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?
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)
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.
HR
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.
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)
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)
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.
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.
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).
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
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.
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
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)]
(ii) Display all data separated by Department and in decreasing order of Salary:
SELECT * FROM Faculty ORDER BY Department, Salary DESC;
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%';
(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()
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: "))
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.
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)
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:
(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.
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?
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.
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)
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:
(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]
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
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.
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
Field Type
productID int(11)
productName varchar(20)
price float
stockQty int(11)
Write the following Python function to perform the specified operation: (4)
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
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 )
Ans : True
2. What id the output of following code snippet?
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
(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)
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.
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:
(A) tell
(B) seek
(C) read
(D) write
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)
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)
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
( 1 marks + 1 Marks )
Ans :
Page: 6/21
If L1 = [10, 20, 30, 40, 20, 10, ...] and L2 = [5, 15, 25, ...], then:
24.
(Answer using builtin functions only)
II (A) : L1.extend(L2)
(B) : unique_elements = list(set(L1))
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] )
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
( 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
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:
OR
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]
Ans : (A )
def push_movie(movie_stack, new_movie): # 1 mark
movie_stack.append(new_movie)
def pop_movie(movie_stack):
Page: 10/21
return movie_stack.pop()
def peek_movie(movie_stack):
return "None"
return movie_stack[-1]
OR
if number % 2 != 0:
odd_numbers.append(number)
def pop_odd(odd_numbers):
return odd_numbers.pop()
def disp_odd(odd_numbers):
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
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
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;
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)
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].
(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.
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
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;
Field Type
productID int(11)
productName varchar(20)
price float
stockQty int(11)
(4)
Write the following Python function to perform the specified operation:
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 )
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
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:
(III) The most efficient cable layout would involve connecting the
buildings as follows:
Page: 20/21
CUSTOMER_SUPPORT
(90 m)
OPERATIONS
/ | \
/ | \
WAREHOUSE MAINTENANCE
(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.
Page: 21/21
अनक्र
ु म ांक/ROLL NO सेट/SET : 01
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
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.
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
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.
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.
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.
31 2 4 3
65
OR
47.0
35.0
54.0
26.0
( 3 Mark for correct output, 1 mark for partial correct)
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()
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)
(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()
MARKING SCHEME
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.
1. False (1)
3. (D)True (1)
PAGE NO. 1 OF 11
(1 mark for correct answer)
5. (A) () (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)
PAGE NO. 2 OF 11
18. (D) REPEATER (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)
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)
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)
29. (3)
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
(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)
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
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()
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)
PAGE NO. 9 OF 11
(½ mark for correctly displaying the data)
Q. No. SECTION E (2 X 5 = 10 Marks) Marks
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.")
***************
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.
import random
word='Inspiration'
Lot=2*random.randint(2,4)
for i in range(Lot,len(word),3):
print(word[i],end='$')
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.
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”.
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.
HR ADMIN
London Head
Head Head
Office
Accts Logistics
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
LOGISTICS
ACCTS
ADMIN
HR
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.
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:
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
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:
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
1 False (1)
4 False (1)
6 (B) ( ) (1)
8 remove() (1)
9 (B) r+ (1)
11 True (1)
13 IS NULL (1)
Page 1 of 7
14 (B) GROUP BY (1)
20 (A)Both A and R are true and R is the correct explanation for A (1)
23 Any two correct differences between compile time and run time error (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
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
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
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
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.
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:
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
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:
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
1 False (1)
5 False (1)
6 (B) ( ) (1)
7 remove() (1)
8 (B) r+ (1)
13 IS NULL (1)
Page 1 of 7
14 (C) 20#50@20 (1)
15 True (1)
20 (A)Both A and R are true and R is the correct explanation for A (1)
23 Any two correct differences between compile time and run time error (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
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
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