100% found this document useful (1 vote)
538 views

PDF&Rendition 1 1

Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
100% found this document useful (1 vote)
538 views

PDF&Rendition 1 1

Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 180

KENDRIYA VIDYALAYA SANGATHAN

GUWAHATI REGION
PRE BOARD – II (Session 2023-24)
Class : XII Subject: (083) Computer Science
Maximum Marks : 70 Time Allowed: 03:00 Hours
General Instructions:
• Please check this question paper contains 35 questions.
• The paper is divided into 4 Sections- A, B, C, D and E.
• Section A, consists of 18 questions (1 to 18). Each question carries 1 Mark.
• Section B, consists of 7 questions (19 to 25). Each question carries 2 Marks.
• Section C, consists of 5 questions (26 to 30). Each question carries 3 Marks.
• Section D, consists of 2 questions (31 to 32). Each question carries 4 Marks.
• Section E, consists of 3 questions (33 to 35). Each question carries 5 Marks.
• All programming questions are to be answered using Python Language only.

SECTION – A
Q1. State True or False (1)
"In Python, data type of a variable depends on its value"
Q2. The correct definition of column ‘alias’ is (1)
a. A permanent new name of column
b. A new column of a table
c. A view of existing column with different name
d. A column which is recently deleted
Q3 What will be the output of the following python expression? print(2**3**2) (1)
a. 64 b. 256 c. 512 d. 32
Q4. 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.
Q5. In MYSQL database, if a table, Alpha has degree 5 and cardinality 3, and another table, Beta has (1)
degree 3 and cardinality 5, what will be the degree and cardinality of the Cartesian product of
Alpha and Beta?
a. 5,3 b. 8,15 c. 3,5 d. 15,8
Q6. Identify the device on the network which is responsible for forwarding data from one (1)
device to another
a. NIC b. Router c. RJ45 d. Repeater
Q7. Choose the most correct statement among the following – (1)

Page 1 of 10
a. a dictionary is a sequential set of elements
b. a dictionary is a set of key-value pairs
c. a dictionary is a sequential collection of elements key-value pairs
d. a dictionary is a non-sequential collection of elements
Q8. Select the correct output of the code: (1)
a = "Year 2024 at all the best"
a = a.split('a')
b = a[0] + "-" + a[1] + "-" + a[3]
print (b)

a. Year – 0- at All the best


b. Ye-r 2024 -ll the best
c. Year – 024- at All the best
d. Year – 0- at all the best
Q9. Which of the following statement(s) would give an error during execution? (1)
S=["CBSE"] # Statement 1
S+="Delhi" # Statement 2
S[0]= '@' # Statement 3 S=S+"Thank
you" # Statement 4
a) Statement 1 b) Statement 2 c) Statement 3 d) Statement 4
Q10. Give the output: (1)
dic1={‘r’:’red’,’g’:’green’,’b’:’blue’}
for i in dic1:
print (i,end=’’)
a. rgb
b. RGB
c. RBG
d. rbg
Q11. Which function is used to display the unique values of a column of a table? (1)
a. sum()
b. unique()
c. distinct()
d. return()
Q12. Select the correct output of the code: (1)
for i in "QUITE":
print([i.lower()], end= "#")
a. q#u#i#t#e#
b. [‘quite#’]
c. ['q']#['u']#['i']#['t']#['e']#
d. [‘quite’] #

Q13. The statement which is used to get the number of rows fetched by execute() method of (1)
cursor:

Page 2 of 10
a. cursor.rowcount b. cursor.rowscount()
c. cursor.allrows() d. cursor.countrows()
Q14. Select the correct statement, with reference to SQL: (1)
a. Aggregate functions ignore NULL
b. Aggregate functions consider NULL as zero or False
c. Aggregate functions treat NULL as a blank string
d.NULL can be written as 'NULL' also.
Q15. is a communication protocol responsible to control the transmission of data over a (1)
network.
a. TCP (b) SMTP (c) PPP (d)HTTP
Q16. Which method is used to move the file pointer to a specified position. (1)
a. tell()
b. seek()
c. seekg()
d. tellg()

Q17 and 18 are ASSERTION AND REASONING based questions. Mark the correct choice as (1)
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
C. A is True but R is False
d. A is false but R is True
Q17. Assertion (A):- The number of actual parameters in a function call may not be equal to the (1)
number of formal parameters of the function.
Reasoning (R):- During a function call, it is optional to pass the values to default
parameters.

Q18. Assertion (A): A tuple can be concatenated to a list, but a list cannot be concatenated to a (1)
tuple.
Reason (R): Lists are mutable and tuples are immutable in Python.

SECTION B
Q19. 1+1
(i) Expand the following terms: =2
SMTP , FTP

(ii) Give one difference between XML and HTML.


OR
(i) Write short note on TELNET

(ii) Name the following


Two commonly used web browsers

Page 3 of 10
Q20. a) Rishaan has written a code to input a number and check whether it is even or odd number. (2)
His code is having errors. Observe the following code carefully and rewrite it after removing
all syntax and logical errors. Underline all the corrections made.
Def checkNumber(N):
status = N%2
return
#main-code
num=int( input(“ Enter a number to check :))
k=checkNumber(num)
if k = 0:
print(“This is EVEN number”)
else:
print(“This is ODD number”)
Q21. a) Write a function countNow(CITY) in Python, that takes the dictionary, CITY as an argument (2)
and displays the names (in uppercase) of the CITY whose names are longer than 5
characters.
For example, Consider the following dictionary
CITY={1:"Delhi",2:"Guwahati",3:"Ajmer",4:"Jaipur",5:"Udaipur”}
The output should be:
GUWAHATI
JAIPUR
UDAIPUR
OR
a) Write a Python code to accept a word /String a mixed case and pass it to a function the
function should count the number of vowels present in the given string and return the
number of vowels to the main program.
Sample Input : computer science
Sample output : No of vowels = 6
Q22. Predict the output of the Python code given below: (2)
def Swap (a,b ) :
if a>b:
print(“changed ”,end=“”)
return b,a
else:
print(“unchanged ”,end=“”)
return a,b
data=[11,22,16,50,30]
for i in range (4,0,-1):

Page 4 of 10
print(Swap(data[i],data[i-1]))
Q23. Choose the best option for the possible output of the following code (2)
import random
L1=[random.randint(0,10) for x in range(3)]
print(L1)
(a) [0,0,7] (b) [9,1,7] (c) [10,10,10] (d) All are possible

OR
import random
num1=int(random.random()+0.5)
What will be the minimum and maximum possible values of variable num1
Q24. Ms. Tejasvi has just created a table named “Student” containing columns sname, Class and Mark. (2)
After creating the table, she realized that she has forgotten to add a primary key column in the
table. Help her in writing an SQL command to add a primary key column StuId of integer type to
the table Student.
Thereafter, write the command to insert the following record in the table:
StuId- 1299
Sname- Shweta
Class: XII
Mark: 98
Q25. Predict the output of the following code: (2)
value = 50
def display(N):
global value
value = 25
if N%7==0:
value = value + N
else:
value = value - N
print(value, end="#")
display(20)
print(value)
OR
Predict the output of the Python code given below:
a=20
def call():
global a
b=20
a=a+b
return a
print(a)
call()
print(a)

Page 5 of 10
SECTION – C
Q26. Predict the output of the Python code given below: (3)

Q27. a) Consider the table CLUB given below and write the output of the SQL queries that follow. (3)

CCODE CNAME MAKE COLOUR CAPACITY CHARGES


105 Fortuner Toyota White 7 1500
245 Nexon Tata Black 5 1000
130 Duster Renault Green 6 2000
225 Kwid Renault Grey 5 2500
120 Baleno Suzuki Red 5 4000
207 Nano Tata Blue 4 3500

(i) SELECT DISTINCT MAKE FROM CAR;


(ii) SELECT MAKE, COUNT(*) FROM CAR GROUP BY MAKE;
(iii) SELECT CNAME FROM CAR WHERE CAPACITY>5 ORDER BY CNAME;
Q28. Write a function in Phyton to read lines from a text file visiors.txt, and display only those lines, (3)
which are starting with an alphabet 'P'.
If the contents of file is :
Visitors from various cities are coming here. Particularly, they
want to visit the museum.
Looking to learn more history about countries with their cultures. The output should be:
Particularly, they want to visit the museum.
OR
Write a method in Python to read lines from a text file book.txt, to find and display the
occurrence of the word 'are'. For example, if the content of the file is:
Books are referred to as a man’s best friend. They are very beneficial for mankind and have
helped it evolve. Books leave a deep impact on us and are responsible for uplifting our mood.

The output should be 3.

Page 6 of 10
Q29. A relation Toys is given below : (3)
T_no Name Company Price Qty
T001 Doll Barbie 1200 10
T002 Car Seedo_wheels 550 12
T003 Mini House Barbie 1800 15
T004 tiles Seedo_wheels 450 20
T005 Ludo Seedo_wheels 200 24

Write SQL commands to:


a. Display the average price of each type of company having quantity more than 15.
b. Count the type of toys manufactured by each company.
c. Display the total price of all toys.

Q30. A list, NList contains following record as list elements: (3)


[City, Country, distance from Delhi]
Each of these records are nested together to form a nested list. Write the following user defined
functions in Python to perform the specified operations on the stack named travel.

(i) Push_element(NList): It takes the nested list as an argument and pushes a list object
containing name of the city and country, which are not in India and distance is less than 3500 km
from Delhi.
(ii) Pop_element(): It pops the objects from the stack and displays them. Also, the function should
display “Stack Empty” when there are no elements in the stack.

For example: If the nested list contains the following data:


NList=[["New York", "U.S.A.", 11734],
["Naypyidaw", "Myanmar", 3219],
["Dubai", "UAE", 2194],
["London", "England", 6693],
["Gangtok", "India", 1580],
["Columbo", "Sri Lanka", 3405]]
The stack should contain:
['Naypyidaw', 'Myanmar'],
['Dubai', 'UAE'],
['Columbo', 'Sri Lanka']
The output should be:
['Columbo', 'Sri Lanka']
['Dubai', 'UAE']
['Naypyidaw', 'Myanmar']
Stack Empty

Page 7 of 10
SECTION – D
Q31. Consider the following tables Consumer and Stationary. (4)

Table: Stationary
StationaryNa
S_ID Company Price
me
BP01 Ball Pen Reynolds 10
PL02 Pencil Natraj 5
ER05 Eraser Natraj 3
PL01 Pencil Apsara 6
GP02 Gel Pen Reynolds 15

Table: Consumer
C_ID ConsumerName City S_ID
01 Pen House Delhi PL01
06 Write Well Mumbai GP02
12 Topper Delhi BP01
15 Good Learner Delhi PL02
16 Motivation Bangalore PL01
Write SQL statements for (i) to (iv)
(i) To display the consumer detail in descending order of their name.
(ii) To display the Name and Price of Stationaries whose Price is in the range 10 to 15.
(iii) To display the ConsumerName, City and StationaryName for stationaries of "Reynolds"
Company
iv) To increase the Price of all stationary by 2 Rupees

Q32 (a) What does CSV stand for? (4)


(b) Write a Program in Python that defines and calls the following user defined functions:
(i) InsertRow() – To accept and insert data of an student to a CSV file ‘class.csv’. Each
record consists of a list with field elements as rollno, name and marks to store roll
number, student’s name and marks respectively.
(ii) COUNTD() – To count and return the number of students who scored marks greater than
75 in the CSV file named ‘class.csv’.
Section – E
Q33. XYZ Media house campus is in Delhi and has 4 blocks named Z1, Z2, Z3 and Z4. The tables given (5)
below show the distance between different blocks and the number of computers in each block.

Page 8 of 10
The company is planning to form a network by joining these blocks.
i. Out of the four blocks on campus, suggest the location of the server that will provide the best
connectivity. Explain your response.
ii. For very fast and efficient connections between various blocks within the campus, suggest a
suitable topology and draw the same.
iii. Suggest the placement of the following devices with justification
(a) Repeater
(b) Hub/Switch
iv. VoIP technology is to be used which allows one to make voice calls using a broadband internet
connection. Expand the term VoIP.
v. The XYZ Media House intends to link its Mumbai and Delhi centers. Out of LAN, MAN, or
WAN, what kind of network will be created?
Justify your answer.
Q34. 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”

OR
A binary file “STUDENT.DAT” has structure (admission_number, Name, Percentage). Write a
function countrec() in Python that would read contents of the file “STUDENT.DAT” and display the
details of those students whose percentage is above 75. Also display number of students scoring
above 75%

Page 9 of 10
Q35 (i) Define the term Domain with respect to RDBMS. Give one example to support your answer. 5

(ii) Kabir wants to write a program in Python to insert the following record in the table 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 Python and MySQL:


Username - root
Password - tiger
Host - localhost

The values of fields rno, name, DOB and fee has to be accepted from the user. Help Kabir to write
the program in Python.
OR
(i) Give one difference between Primary key and unique key.

(ii) Sartaj has created a table 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 Python and MySQL:


Username - root
Password - tiger
Host - localhost

Page 10 of 10
KENDRIYA VIDYALAYA SANGATHAN
GUWAHATI REGION
PRE BOARD – II EXAMINATION (Session 2023-24)
Class : XII Time Allowed : 03:00 Hours
Subject: (083) Computer Science Maximum Marks : 70

General Instructions:
• Please check this question paper contains 35 questions.
• The paper is divided into 4 Sections- A, B, C, D and E.
• Section A, consists of 18 questions (1 to 18). Each question carries 1 Mark.
• Section B, consists of 7 questions (19 to 25). Each question carries 2 Marks.
• Section C, consists of 5 questions (26 to 30). Each question carries 3 Marks.
• Section D, consists of 2 questions (31 to 32). Each question carries 4 Marks.
• Section E, consists of 3 questions (33 to 35). Each question carries 5 Marks.
• All programming questions are to be answered using Python Language only.
SECTION – A
Q1. True (1)
Q2. C ) A view of existing column with different name (1)
Q3. c) 512 (1)
Q4. c) {'A':4000, 'B':2500, 'C':3000} (1)
Q5. b) 8,15 (1)
Q6. b) Router (1)
Q7. (b) a dictionary is a set of key-value pairs (1)
Q8. b)Ye-r 2024 -ll the best (1)
Q9. d) Statement 4 (1)
Q10. a) rgb (1)
Q11. c) distinct() (1)
Q12. c) ['q']#['u']#['i']#['t']#['e']# (1)
Q13. a)cursor.rowcount (1)
Q14. a) Aggregate functions ignore NULL (1)
Q15. a. TCP (1)
Q16. b) SEEK (1)
Q17. a) (1)
Q18. d) (1)

Page 1 of 7
SECTION – B
Q19. (i) ½ mark for each correct expansion (2)
HTML( Hypertext mark Up language)
We use pre-defined tags
Static web development language – only focuses on how data looks
It use for only displaying data, cannot transport data
Not case sensitive

XML (Extensible Markup Language)


we can define our own tags and use them
Dynamic web development language – as it is used for transporting and storing data
Case sensitive
1 mark for any one correct difference No mark to be awarded if only full form is given
OR
(I) 1 mark for correct definition
(ii) 1/2 mark for each correct name of web browser.
Q20. Def checkNumber(N): # Def should be def (2)
status = N%2
return # return what? Should be return status
#main-code
num=int( input(“ Enter a number to check :)) # Message not enclosed within quotation
mark
k=checkNumber(num)
if k = 0: # must be k = = 0
print(“This is EVEN number”)
else:
print(“This is ODD number”)

(½ mark for each correct correction made and underlined.)


Q21. ½ mark for correct function header (2)
½ mark for correct loop
½ mark for correct if statement
½ mark for displaying the output
OR
½ mark for correct function header
½ mark for correct loop
½ mark for correct if statement
½ mark for displaying the output
Q22. unchanged (30, 50) (2)
changed (16, 50)
unchanged (16, 22)
changed (11, 22)
(½ mark for each correct Output)

Page 2 of 7
Q23. d) All are possible (2)
OR
Minimum 0 and maximum 1
(1 mark for each correct Output)
Q24. 1 mark for correct ALTER TABLE command (2)
SQL Command to add primary key:
ALTER TABLE Student ADD StuId INTEGER PRIMARY KEY;
1 mark for correct INSERT command
As the primary key is added as the last field, the command for inserting data will be:
INSERT INTO Student VALUES("Shweta","XII",98,1299);
Alternative answer:
INSERT INTO Student(Stuid,Sname,class,Mark) VALUES(1299,"Shweta","XII",98);
Q25. 50#5 (2 marks for correct answer) (2)
OR
20
40
(2 marks for correct answer)
SECTION – C
Q26. ND-*34 (3)
(½ mark for each correct character )
Q27. 1 mark for each correct output (3)
(i)
MAKE
Toyota
Tata
Renault
Suzuki
(ii)
MAKE COUNT(*)
Toyota 1
Tata 2
Renault 2
Suzuki 1
(iii)
CNAME
Duster
Fortuner
Q28. def rdlines(): (3)
file = open('visitors.txt','r') for line in file:
if line[0] == 'P': print(line)
file.close()

Page 3 of 7
# Call the rdlines function. rdlines()
½ mark for function header
1 mark for opening file
1 mark for correct for loop and condition
½ mark for closing file
OR
def count_word():
file = open('india.txt','r') count = 0
for line in file:
words = line.split() for word in
words:
if word == 'India': count += 1
print(count) file.close()
# call the function count_word(). count_word()
½ mark for function header
1 mark for opening file
1 mark for correct for loop and condition
½ mark for closing file
Q29. Select company, avg(Price) from toys group by company having Qty>15; (3)
Select Company, count(distinct name) from toys group by Company;
Select name, sum(Price* Qty) from toys;
½ mark for the Select with avg(), ½ mark for the having clause
½ mark for the Select with count() , ½ mark for group by clause
½ mark for the Select with sum() , ½ mark for the group by clause
Q30. (3)

1 ½ marks for each function

Page 4 of 7
SECTION – D
Q31. i) SELECT * FROM Consumer ORDER BY ConsumerName DESC (4)
(ii) SELECT StationaryName, Price FROM Stationary WHERE Price>=10 AND Price<=15
(iii) SELECT C.ConsumerName, C.City, S.StationaryName FROM Stationary S, Consumer C
WHERE C.S_ID=S.S+ID AND S.Company="Reynolds";
iv) UPDATE Stationary SET Price=Price+2

Q32. (a) Comma separated value 1 marks (4)


(b) (i) 2 Marks
def InsertRow():
import csv
f=open("class.csv","a+",newline="")
rno=int(input("Enter roll no. :"))
name=int(input("Enter name :"))
marks=int(input("Enter marks :"))
wo=csv.writer(f)
wo.writerow([rno, name, marks])
f.close()

(b)(ii) 2 Marks
def COUNTD():
import csv
count=0
f=open("class.csv","r")
ro=csv.reader(f)
for i in ro:
if i[2]>75:
count+=1
return count
½ mark for opening and closing file
½ mark for reader object
½ mark for print heading
½ mark for printing data
SECTION – E
Q33. i. Z2 as it has maximum number of computers. (5)
ii. For very fast and efficient connections between various blocks within the campus suitable
topology: Star Topology

Page 5 of 7
iii. Repeater: To be placed between Block Z2 to Z4 as distance between them is more than 100
metres.

Hub/Switch: To be placed in each block as each block has many computers that needs to be
included to form a network.
iv. Voice Over Internet Protocol
v. WAN as distance between Delhi and Mumbai is more than 40kms.
(1 mark for each correct answer)
34. import pickle 5
def createFile():
fobj=open("Book.dat","ab")
BookNo=int(input("Book Number : "))
Book_name=input("Name :")
Author = input("Author:" )
Price = int(input("Price : "))
rec=[BookNo,Book_Name,Author,Price]
pickle.dump(rec,fobj)
fobj.close()
def CountRec(Author):
fobj=open("Book.dat","rb")
num = 0
try:
while True:
rec=pickle.load(fobj)
if Author==rec[2]:
num = num + 1
except:
fobj.close()
return num
or
import pickle
def CountRec():
fobj=open("STUDENT.DAT","rb")
num = 0
try:
while True:
rec=pickle.load(fobj)
if rec[2] > 75:
print(rec[0],rec[1],rec[2],sep="\t")
num = num + 1
except:
fobj.close()
return num

Page 6 of 7
Q35. Domain is a set of values from which an attribute can take value in each row. For example, roll no (5)
field can have only integer values and so its domain is a set of integer values
½ mark for correct definition
½ mark for correct example

½ mark for importing correct module


1 mark for correct connect()
½ mark for correctly accepting the input
1 ½ mark for correctly executing the query
½ mark for correctly using commit()
OR

(I) 1 mark for correct difference


(II)

½ mark for importing correct module


1 mark for correct connect()
1 mark for correctly executing the query
½ mark for correctly using fetchall()
1 mark for correctly

Page 7 of 7
SET-2
KENDRIYA VIDYALAYA SANGATHAN (LUCKNOW REGION)
XII- PRE-BOARD EXAMINATION 2023-24
Computer Science (083)
Time allowed: 3 hours Maximum marks: 70
General Instructions:
 Please check this question paper contains 35 questions.
 The paper is divided into five sections- A, B, C, D and E.
 Section A, consists of 18 questions (1 to 18). Each question carries 01 mark.
 Section B, consists of 07 questions (19 to 25). Each question carries 02 marks.
 Section C consists of 05 questions (26 to 30). Each question carries 03 marks.
 Section D consists of 02 questions (31 to 32). Each question carries 04 marks.
 Section E consists of 03 questions (33 to 35). Each question carries 5marks.
 All programming questions are to be answered using Python Language only.
 15 minutes time has been allotted to read this question paper.

Section – A
Q01. State True or False (1)
“Python is a platform independent, case sensitive and interpreted language”
Q02. Which of the following(s) is/are valid Identifier(s) in Python? (1)
(a) for (b) elif (c) _123 (d) None
Q03. What will be the output of the following Python code? (1)
T1=(1,2,[1,2],3)

T1[2][1]=3.5

print(T1)

(a) (1,2,[3.5,2],3) (b) (1,2,[1,3.5],3) (c) (1,2,[1,2],3.5) (d) Error Message


Q04. What will be the output of the following expression if the value of a=0, b=1 and c=2? (1)
print(a and b or not c )
(a) True (b) False (c) 1 (d) 0
Q05. What should be the output of the following code? (1)
String = “India will be a global player in the digital economy”
Str1= String.title(); Str2=Str1.split()
print(Str2[len(Str2)-1:-3:-1])
(a) [‘Digital’,’Economy’] (b) [‘The’,’Digital’,’Economy’]
(c) [‘economy’,’digital’] (d) [‘Economy’,’Digital’]
Q06. Which of the following statement is incorrect? (1)
(a) A file handle is a reference to a file on disk.
1
Page 1 of 12 | KVS –Lucknow Region | Session 2023-24
(b) File handle is used to read and write data to a file on disk.
(c) All the functions that you perform on a disk file can’t be performed through file handle.
(d) None of these
Q07. Fill in the blank: - (1)
_____________ command is used to add a new column into an existing table in SQL.
(a) UPDATE (b) INSERT (c) ALTER (d) CREATE
Q08. Which of the following command is a DDL command? (1)
(a) SELECT (b) GROUP BY (c) DROP (d) UNIQUE
Q09. Which of the following statement(s) would give an error after executing the following code? (1)
name_marks{'atul':88,'basab':45,'chetan':90} #Statement1
upgrade={} #Statement2
for key in name_marks.keys(): #Statement3
if (name_marks[key]>50): #Statement4
upgrade[key]=name_marks[key] #Statement5
print(upgrade) #Statement6
(a) Statement1 (b) Statement3 (c) Statement4 (d) Statement5
Q10. Fill in the blank: (1)
Number of records/ tuples/ rows in a relation or table of a database is referred to as ________
(a) Domain (b) Degree (c) Cardinality (d) Integrity
Q11. Which of the following statement is not true regarding opening modes of a file? (1)
(a) When you open a file for reading, if the file does not exist, an error occurs.
(b) When you open a file for writing, if the file does not exist, an error does not occur.
(c) When you open a file for appending content, if the file does not exist, an error does not occur.
(d) When you open a file for writing, if the file exists, new content added to the end of the file.
Q12. The __________________ clause is used for pattern matching in MySQL queries. (1)
(a) ALL (b) DESC (c) MATCH (d) LIKE
Q13. A __________________ specifies the distinct address for each resource on the Internet. (1)
(a) FTP (b) WWW (c) URL (d) HTTP
Q14. What will be the output of the following Python code? (1)
print(5<10 and 10<5 or 4<9 and not 3<-3)
(a) True (b) False (c) Error Message (d) None of these
Q15. Which of the following query is incorrect? Assume table EMPLOYEE with attributes (1)
EMPCODE, NAME, SALARY and CITY.
(a) SELECT COUNT(*) FROM EMPLOYEE;
(b) SELECT COUNT(NAME) FROM EMPLOYEE;
(c) SELECT AVG(SALARY) FROM EMPLOYEE;
(d) SELECT MAX(SALARY) AND MEAN(SALARY) FROM EMPLOYEE;
Q16. Which one of the following syntax is correct to establish a connection between Python and (1)
MySQL database using the function connect( ) of mysql.connector package? Assume that import
2
Page 2 of 12 | KVS –Lucknow Region | Session 2023-24
mysql.connector as mycon is imported in the program
.(a) mycon.connect(host = “hostlocal”, user = “root”, password = “MyPass”)
(b) mycon.connect(host = “localhost”, user = “root”, passwd = “MyPass”, database = “test”)

(c) mycon.connect(“host”=“localhost”, “user”= “root”, “passwd”=”MyPass”, “database”= “test”)

(d) mycon.connect(“localhost” = host, “root”=user, “MyPass”=passwd)

Q-17 and Q-18 are ASSERTION AND REASONING based questions. Mark the correct choice as
(a) Both A and R are true and R is the correct explanation for A
(b) Both A and R are true and R is not the correct explanation for A
(c) A is True but R is False &
(d) A is False but R is True
Q17. Assertion(A): Dictionary is an unordered collection of data values that stores the key: value pair. (1)
Reason(R): Immutable means they cannot be changed after creation.
Q18. Assertion(A): Access mode ‘a’ opens a file for appending content at the end of the file. (1)
Reason(R): The file pointer is at the end of the file if the file exists and opens in write mode.
Section – B
Q19. Manish has designed a Python program to calculate factorial of a number passed as argument, (2)
but he is getting errors while executing the code. Rewrite his code after removing errors and
underline each correction.
def factorial():
fact=1
while N>0:
fact=*N
N=N-1
print(“Factorial’ ,fact)
#main( )
Factorial(5)
Q20. Differentiate between Star Topology and Bus Topology. Write two points of difference. (2)
OR
Write two point of difference between Bridge and Gateway.
Q21. (a) Write the output of when Python string declaration is given as follows: - (1)
Mystr=”I love technology while growing up”
print(Mystr[1:len(Mystr):2])
(1)
(b) Write the output of the code given below:
Student_details = {"name": "aditya", "age": 16}
New=Student_details.copy()
New['address'] = "Mumbai"
print(Student_details);
print(New)

Q22. Explain the Relational Database Management System terminologies- Degree and Attribute of a (2)
relation. Give example to support your answer.
Q23. (a) Write the full forms of the following: - (i) FTP (ii) POP (2)

3
Page 3 of 12 | KVS –Lucknow Region | Session 2023-24
(b) What is MAC address?

Q24. Predict the output of the Python code given below: (2)
def modify(L):
for C in range(len(L)):
if C%2==1:
L[C]*=2
else:
L[C]//=2
#Main
N=[5,13,47,9]
modify(N)
print(N)
OR
Predict the output of the Python code given below:
T=(1,2,3,4,5,6,7,8,9)
T1=T[2:8:2]
T2=T[-2:-8:-2]
T3=T1+T2
print(T3[::-1])
Q25. Differentiate between WHERE and HAVING clause used in MySQL with appropriate example. (2)
OR
Explain the use of GROUP BY clause in MySQL with an appropriate example.
Section – C
Q26. (a) Consider the following tables – BILLED and ITEM (1+2)

Table: BILLED
BNO NAME CITY
1001 Ashok Delhi
1002 Manish Jaipur
1003 Rahul Lucknow
Table: ITEM
ITEMCODE INAME PRICE
11 HDD 2500
12 Keyboard 850
13 RAM 1100

What will be the output of the following SQL query statement?


SELECT * FROM BILLED, ITEM;
(b) Write the output of the queries (i) to (iv) based on the table EMPLOYEE given below:

4
Page 4 of 12 | KVS –Lucknow Region | Session 2023-24
Table: EMPLOYEE
EMPID NAME DESIGNATION SALARY CITY
101 Harry Manager 90000 Delhi
102 Sam Director 120000 Mumbai
103 Peter Clerk 45000 Delhi
104 Jack Manager 85000 Kolkata
105 Robert Clerk 55000 Mumbai
(i) SELECT DISTINCT DESIGNATION FROM EMPLOYEE;
(ii) SELECT CITY, SUM(Salary) FROM EMPLOYEE GROUP BY CITY HAVING
SALARY > 50000;
(iii)SELECT NAME, SALARY FROM EMPLOYEE WHERE CITY IN
(‘DELHI’,’KOLKATA’) ORDER BY NAME DESC;
(iv) SELECT NAME, SALARY, CITY FROM EMPLOYEE WHERE NAME LIKE ‘H%’
AND SALARY BETWEEN 50000 AND 90000;

Q27. (a) Write a method COUNT_W5() in Python which read all the content of a text file (3)
‘STORY.TXT’ and count &display all those words whose length is 6 character long.
For Example: - If the file content is as follows:
God made the mother earth and the man made countries;
These countries having states and states consists cities.
Then the output of the method will be
Six characters words are: - mother, These, having, states,cities,output,method
The total no of words with length of 6 characters is: 6
OR
(b) Write a function VC_COUNT() in Python, which should read each character of a text file
“THEORY.TXT” and then count and display all the vowels and consonants separately(including
upper cases and small cases).
Example:
If the file content is as follows:
A boy is playing there. There is a playground.
The VC_COUNT() function should display the output as:
Total vowels are: 14
Total consonants are: 22
Q28. (a) Write the outputs of the SQL queries (i) to (iv) based on the relations ENGINEER and (2+1)
SALARY given below:
Table: ENGINEER
5
Page 5 of 12 | KVS –Lucknow Region | Session 2023-24
EID NAME AGE DEPARTMENT DOJ GENDER
101 RAVI 34 CODING 2007-09-05 M
102 SUMAN 29 NETWORKING 2010-10-10 F
103 MONU 36 CODING 2003-10-20 M
104 RUPALI 32 ANALYSIS 2012-05-12 F
105 ROHIT 24 TESTING 2017-04-10 M

Table: SALARY
EID BASIC HRA DA
101 40000 3000 2000
102 45000 2500 2500
103 50000 5000 2800
104 35000 3000 1600
105 30000 2500 1200
(i) SELECT DEPARTMENT, COUNT(*) FROM ENGINEER GROUP BY
DEPARTMENT;
(ii) SELECT MAX(DOJ), MIN(DOJ) FROM ENGINEER;
(iii) SELECT NAME, DEPARTMENT, (BASIC+HRA+DA) AS “TOTALSALARY”
FROM ENGINEER, SALARY WHERE ENGINEER.EID =SALARY.EID;
(iv) SELECT NAME, HRA FROM ENGINEER E, SALARY S WHERE E.EID=S.EID
AND GENDER = ’F’;
(b) Write a command to view the structure of a table.
Q29. Write a function INTERCHANGE(L), where L is the list of elements passed as argument to the (3)
function. The function returns another list named ‘ChangedList’ that contain values interchanged
as the even index value with next consecutive odd index value of the L.
For example:
If L contains [25,30,35,40,45]
The ChangedList will have [30,25,40,35,45 ]
Q30. A list named as Record contains following format of for students: [student_name, class, city]. (3)
Write the following user defined functions to perform given operations on the stack named
‘Record’:
(i) Push_record(Record) – To pass the list Record = [ ['Rahul', 12,'Delhi'], [‘Kohli',11,'Mumbai'],
['Rohit',12,'Delhi'] ] and then Push an object containing Student name, Class and City of student
belongs to ‘Delhi’ to the stack Record and display and return the contents of stack
(ii) Pop_record(Record) – To pass following Record [[“Rohit”,”12”,”Delhi”] [“Rahul”,
12,”Delhi”] ] and then to Pop all the objects from the stack and at last display “Stack Empty”

6
Page 6 of 12 | KVS –Lucknow Region | Session 2023-24
when there is no student record in the stack. Thus the output should be: -
[“Rohit”,”12”,”Delhi”]
[“Rahul”, 12,”Delhi”]
Stack Empty
OR
A list of numbers is used to populate the contents of a stack using a function push(stack, data)
where stack is an empty list and data is the list of numbers. The function should push all the
numbers that are even to the stack. Also write the function pop() that removes the top element of
the stack on its each call.
Section – D
Q31. Manoj is working in a mobile shop and assigned a task to create a table MOBILES with (1+1+2)
record of mobiles as Mobile code, Model, Company, Price and Date of Launch. After
creation of the table, he has entered data of 5 mobiles in the MOBILES table.
MOBILES
MCODE MODEL COMPANY PRICE DATE_OF_LAUNCH
M01 9PRO REALME 17000 2021-01-01
M02 NOTE11 MI 21000 2021-10-12
M03 10S MI 14000 2022-02-05
M04 NARZO50 REALME 13000 2020-05-01
M05 iPHONE12 APPLE 70000 2021-07-01
Based on the data given above answer the following questions:
(i) Identify the most appropriate column, which can be considered as Primary key.
(ii) Write the degree and cardinality of the above table, after removing one column and two
more record added to the table.
(iii) Write the statements to:
(a) Add a new column GST with data type integer to the table.
(b) Insert the value of GST in the new column as 18% of PRICE.
OR (Option for part iii only)
(iii) Write the statements to:
(a) To insert a new record of mobile as MobileCode – M06, Company Apple,
Model- iPHONE13, Price-110000 and Date of launch – ‘2022-03-01’.
(b) To delete the record of mobile with model as NARZO50.
Q32. Arun, during Practical Examination of Computer Science, has been assigned an (1+1+2)
incomplete search() function to search in a pickled file student.dat. The File student.dat is
created by his Teacher and the following information is known about the file.

7
Page 7 of 12 | KVS –Lucknow Region | Session 2023-24
 File contains details of students in [Rollno, Name, Marks] format.

 File contains details of 10 students (i.e. from Rollno 1 to 10) and separate list of each

student is written in the binary file using dump().

Arun has been assigned the task to complete the code and print details of Roll Number 7.

import _________________ # Statement1


def search( ):
f=______________________ #Statement2
found=0
while True:
try:
rec=pickle._____________ #Statement3
if(_________________): #Statement4
print(rec); found=1
except: break
if (found==0):
print("Record not found")
(i) Which module should be imported in the program? (Statement 1)
(ii) Write the correct statement required to open a file student.dat. (Statement 2)
(iii) Which statement should arun fill in Statement 3 to read the data from the binary file,
student.dat and in Statement 4 to match the Rollno.
Section – E
Q33. Signature Training Institute is planning to set up its centre in Jaipur with four specialized blocks (5)
for MBBS, MBA, BTECH and ADMIN. The physical distance between these blocks and the
number of computers to be installed in each block is given below. The Head Quarter of the
Institute is in Delhi. You as a Network expert have to answer the queries raised by their board of
directors as given (i) to (v).
JAIPUR CAMPUS

MBA ADMIN

MBBS BTECH

Distance between blocks in meter:

8
Page 8 of 12 | KVS –Lucknow Region | Session 2023-24
MBBS to MBA - 60
MBBS to ADMIN - 190
MBBS to BTECH - 110
MBA to BTECH - 120
MBA to ADMIN - 50
No of computers to be installed in each Block:
ADMIN - 50
MBBS - 15
MBA - 25
BTECH - 40

(i) Suggest the most appropriate block to house the SERVER in Jaipur Campus to get the best
and effective connectivity. Justify your answer.
(ii) Suggest a device/software to be installed in Jaipur campus to take care of data security.
(iii) Suggest the best wired medium and draw the cable layout to economically connect all the
blocks with the campus.
(iv) Suggest the placement of the following devices with appropriate reasons:
(a) Switch / Hub (b) Repeater
(v) Suggest a protocol that shall be needed to provide video conferencing solution between
Jaipur campus and Delhi Head Quarter.
Please note that there is internal choice in Q34 & Q35.
Q34. (a) Write the output of the code given below: (2+3)
def Funstr(S):
T=""
for i in S:
if i.isdigit():
T=T+i
return T

A="Comp.Sc.- 083"
B=Funstr(A)
print(A,'\n',B, sep="#")
(b) The code given below inserts the following record in the table employee:
EmpNo – integer
EmpName – string
Salary – integer
City – string
Note the following to establish connectivity between Python and MYSQL:
 Username is root
 Password is tiger
 The table exists in a MYSQL database named COMPANY.
 The details (EmpNo, EmpName, Salary and City) are to be accepted from the user.

Write the following missing statements to complete the code:

9
Page 9 of 12 | KVS –Lucknow Region | Session 2023-24
Statement 1 – to form the cursor object
Statement 2 – to execute the command that inserts the record in the table Employee.
Statement 3 - to add the record permanently in the database

import mysql.connector as mysql


def sql_data():
con1=mysql.connect(host="localhost",user="root", passwd="tiger", database=
"company")
mycursor=_________________ #Statement 1
EmpNo=int(input("Enter Employee Number : "))
EmpName=input("Enter Employee Name : ")
Salary=int(input("Enter Employee Salary: "))
City=input("Enter Employee City Name: "))
query="insert into Employee values({},'{}',{},’{}’)".format(EmpNo,EmpName, Salary,City)
______________________ #Statement 2
______________________ # Statement 3
print("Data Added successfully")
OR
(a) Predict the output of the code given below:
def ListChange(L):
for i in range(len(L)):
if L[i]%2==0:
L[i]=L[i]*2
if L[i]%3==0:
L[i]=L[i]*3
if L[i]%5==0:
L[i]=L[i]*5
L=[3,4,5,9]
ListChange(L)
for i in L:
print(i, end="$")
(b) The code given below reads the following record from the table named Product and
displays only those records whosepriceis greater than 500:
PNo – integer
PName – string
Price – integer
Note the following to establish connectivity between Python and MYSQL:
 Username is root

10
Page 10 of 12 | KVS –Lucknow Region | Session 2023-24
 Password is tiger
 The table exists in a MYSQL database named school.
Write the following missing statements to complete the code:
Statement 1 – to form the cursor object
Statement 2 – to execute the query that extracts records of those products whose Priceare
greater than 500.
Statement 3- to read the complete result of the query (records whose price are greater than
500) into the object named data, from the table Product in the database.
import mysql.connector as mysql
def sql_data():
con1=mysql.connect(host="localhost",user="root",passwd="tiger", database="ABCD")
mycursor=_______________ #Statement 1
print("Product detail whose price greater than 500 are : ")
_________________________ #Statement 2
data=__________________ #Statement 3
for i in data:
print(i)
print()
Q35. How CSV files are different from normal text files? (5)
Write a program in Python that defines and calls the following user defined functions:

(i) INSERT() – To accept and add data of a Student to a CSV file ‘Sdetails.csv’. Each record
consists of a list with field elements as RollNo, Name, Class and Marks to store roll number of
students, name of student, class and marks obtained by the student.
(ii) COUNTROW() – To count the number of records present in the CSV file named
‘Sdetails.csv’.
OR

Write syntax to create a reader object and write object to read and write the content of a CSV

file. Write a Program in Python that defines and calls the following user defined functions:

(i) ADD() – To accept and add data of an employee to a CSV file ‘empdata.csv’. Each record

consists of a list with field elements as Eid, Ename, Salary and City to store employee id ,

employee name, employee salary and city.

(ii) SEARCH()- To display the records of the employees whose salary is more than 50000.

***** End of Paper*****

11
Page 11 of 12 | KVS –Lucknow Region | Session 2023-24
12
Page 12 of 12 | KVS –Lucknow Region | Session 2023-24
SET-2
KENDRIYA VIDYALAYA SANGATHAN (LUCKNOW REGION)
XII- PRE-BOARD EXAMINATION 2023-24
Computer Science (083)
Time allowed: 3 hours Maximum marks: 70

Note – Please award full marks for any alternative correct code / set of instruction especially in Python
programming.
MARKING SCHEME

Section – A

Q01. Ans: True (1)

Q02. Ans: (c) _123 (1)

Q03. Ans: (b) (1, 2, [1, 3.5], 3) (1)

Q04. Ans: (b) False (1)

Q05. Ans: (d) [‘Economy’, ’Digital’] (1)

Q06. Ans: (d) None of these (1)

Q07. Ans: (c) ALTER (1)

Q08. Ans: (c) DROP (1)

Q09. Ans: (a) Statement1 (1)

Q10. Ans: (c) Cardinality (1)

Q11. Ans: (a) When you open a file for reading, if the file does not exist, an error occurs. (1)

Q12. Ans: (d) LIKE (1)

Q13. Ans: (c) URL (1)

Q14. Ans: (a) True (1)

Q15. Ans: (d) SELECT MAX(SALARY) AND MEAN(SALARY) FROM EMPLOYEE; (1)

Q16. Ans: (b) mycon.connect(host=”localhost”,user=”root”,passwd=”MyPass”,database=”test”) (1)

Q17. Ans: (b) Both A and R are true and R is not the correct explanation for A (1)

Q18. Ans: (c) A is True but R is False (1)

1
Page 1 of 11| KVS – Lucknow Region | Session 2023-24
Section – B

Q19. Ans: (2)

def factorial(N ):

fact=1

while N>0:

fact*=N

N=N-1

print("Factorial=",fact)

#main()

factorial(5)

Q20. Differentiate between Star Topology and Bus Topology. Write two points of difference. (2)

Ans:

S.No. Star topology Bus Topology

1 In Star topology all the devices are In Bus topology each device in the
connected to a central hub/node. network is connected to a single cable
which is known as the backbone

2 In Star topology if the central hub fails In Bus topology the failure of the network
then the whole network fails. cable will cause the whole network to fail.

OR

Write two point of difference between Bridge and Gateway.

Ans:

S.No. Bridge Gateway


1 Bridge connect two different Gateway is used to connect two different
Networks working on the same Networks working on the different
protocol protocols
2 In bridge, format of packet is not In Gateway format of packet is changed.
changed

2
Page 2 of 11| KVS – Lucknow Region | Session 2023-24
Q21. Ans: Output will be as follows (1)

(a) oetcnlg hl rwn p (1)


(b) {'name': 'aditya', 'age': 16}
{'name': 'aditya', 'age': 16, 'address': 'Mumbai'}

Q22. Degree: The number of attributes or columns in a relation is called the Degree of the relation. (2)

Attribute: An attribute is a specification that defines a property of an object (column / fields of a


relation) Example: Any valid example to show degree and attribute.

Q23. (a) (i) File Transfer Protocol (ii) Post Office Protocol (1)

(b) A Media Access Control address (MAC address) is a hardware identifier that uniquely
identifies each device on a network. Primarily, the manufacturer assigns it. They are often found
(1)
on a device's network interface controller (NIC) card.

Q24. Ans: [2, 26, 23, 18] (1/2 mark for each correct digit) OR (2)

Ans: (4, 6, 8, 7, 5, 3)(1/2 marks for each two consecutive digits & ½ marks for parenthesis)

Q25. (1 MARKS FOR DIFFERENCE AND 1 MARKS FOR EXAMPLE) (2)

S.No. WHERE HAVING

1 It is used to fetch the records from the It is used to fetch the record from the
table based on the specified condition. groups based on the specified condition.

2 It is used before group by or order by It is used along with group by clause

3 Any valid appropriate example Any valid appropriate example

OR

The GROUP BY clause is used to get the summary data based on one or more group of records.
The groups can be formed on one or more columns. For example, the GROUP BY query will be
used to count the number of employees in each department or to get the department wise total
salaries etc. It uses HAVING clause to retrieve records based on specified condition for the given
column(s) of the group by clause.

Example: any valid example

Section – C

3
Page 3 of 11| KVS – Lucknow Region | Session 2023-24
Q26. (1)

BNO NAME CITY ITEMCODE INAME PRICE

1001 Ashok Delhi 11 HDD 2500

1001 Ashok Delhi 12 Keyboard 850

1001 Ashok Delhi 13 RAM 1100

1002 Manish Jaipur 11 HDD 2500

1002 Manish Jaipur 12 Keyboard 850

1002 Manish Jaipur 13 RAM 1100

1003 Rahul Lucknow 11 HDD 2500

1003 Rahul Lucknow 12 Keyboard 850

1003 Rahul Lucknow 13 RAM 1100

(a) 1 mark for correct result.

(b) (2)

(1/2 mark for each correct output)

(i) Manager

Director

Clerk

(ii) Delhi 90000

Mumbai 175000

Kolkata 85000

(iii) Peter 45000

Jack 85000

Harry 90000

(iv) Harry 90000 Delhi

Q27. (a)

def COUNT_W5():

4
Page 4 of 11| KVS – Lucknow Region | Session 2023-24
obj = open("story1.txt","r")

text = obj.read()

L = text.split()

count = 0

print("Six characters words are: - ", end = "")

for i in L:

if len(i) == 6:

print(i , end=" ")

count += 1

print("\nThe total no of words with length of 6 characters is: ",count)

COUNT_W5()

Q27. OR (b) (3)

def VC_COUNT():

obj=open("THEORY.TXT","r")

text=obj.read()

VCOUNT=0

CCOUNT=0

for i in text:

if( i.isalpha()):

if i in ('a','e','i','o','u') or i in ('A','E','I','O','U'):

VCOUNT+=1

else:

CCOUNT+=1

print("Total vowels are: ",VCOUNT)

print("Total consonants are: ",CCOUNT)

VC_COUNT()

5
Page 5 of 11| KVS – Lucknow Region | Session 2023-24
Q28. (a) (1/2 marks for each correct output) (3)

(i) CODING 2

NETWORKING 1

ANALYSIS 1

TESTING 1

(ii) ‘2017-04-10’ ‘2003-05-12’

(iii) RAVI CODING 45000

SUMAN NETWORKING 50000

MONU CODING 57800

RUPALI ANALYSIS 39600

ROHIT TESTING 33700

(iv) SUMAN 2500

REPALI 3000

½ mark for each output

(b) mysql> DESC EMPLOYEE; (1 mark for correct command)

Q29. def INTERCHANGE(L): (3)

ChangedList=L

i=0

if len(ChangedList)%2==0:

while i<=(len(ChangedList)-1):

ChangedList[i],ChangedList[i+1]=ChangedList[i+1],ChangedList[i]

i=i+2

else:

while i<=(len(ChangedList)-2):

ChangedList[i],ChangedList[i+1]=ChangedList[i+1],ChangedList[i]

i=i+2

6
Page 6 of 11| KVS – Lucknow Region | Session 2023-24
return ChangedList

List=[5,6,7,8,9]

print(List)

NewList = INTERCHANGE(List)

print(NewList)

Q30. def Push_record(): # (1½ mark for correct push element) (3)

for i in List:

if i[2]=="Delhi":

Record.append(i)

print(Record)

def Pop_record(): # (1½ mark for correct push element)

while True:

if len(Record)==0:

print('Empty Stack')

break

else:

print(Record.pop())

OR

data = [1,2,3,4,5,6,7,8]
stack = []
def push(stack, data):
for x in data:
if x % 2 == 0:
stack.append(x)
def pop(stack):
if len(stack)==0:
return "stack empty"
else:
return stack.pop()
push(stack, data)
print(pop(stack))
½ mark should be deducted for all incorrect syntax. Full marks to be awarded for any other logic
that produces the correct result.

7
Page 7 of 11| KVS – Lucknow Region | Session 2023-24
Section – D

Q31. (i)MCODE unique values (1 mark) (4)

(ii) Degree = 4 (after removing one column) (1/2 mark)

Cardinality = 7 (after 2 more record added) (1/2 mark)

(iii) (a) mysql>alter table MOBILES add GST int; (1 mark)

(b) mysql>update MOBILES set GST=(PRICE*0.18) (1 mark)

OR

(iii) (a) mysql>insert into MOBILES values(‘M06’,’iPHONE13’,’APPLE’,110000,’2022-03-01’);

(1 mark)

(b) mysql>delete from MOBILES where MODEL=’NARZO50’; (1 mark)

Q32 (i) pickle (1 mark for correct module) (4)

(ii) Statement2: f=open("student.dat","rb") (1 mark)

(iii) Statement3: rec=pickle.load(f) (1 mark)

Statement4: if(rec[0]==7): (1 mark)

Section - E

Q33. (i) Admin block, Justification – maximum number of computers (5)

(ii) Firewall

(iii)

MBA ADMIN

MBBS BTECH

(iv) (a) Switch/Hub in each block to connect all the computers of that block.

8
Page 8 of 11| KVS – Lucknow Region | Session 2023-24
(b) Repeater between MBBS and BTECH block due to 190 meter of distance apart from each
other..

(v) VoIP protocol

Q34. (a) Ans: Comp.Sc.- 083#083 (1 mark for comp.sc. and 1 marks for rest) (5)

(b) Statement1: mycursor=con1.cursor()

Statement2: mycursor.execute(query)

Statement3: con1.commit()

(1 mark for each correct statement)

OR

(a) Ans: 9$8$25$27$ (1 mark for first 5 characters and 1 mark for next 5 characters)

(b) Statement1: mycursor=con1.cursor()

Statement2: mycursor.execute("select * from Product where Price>500")

Statement3: data=mycursor.fetchall()
(1 mark for each correct statement)

Q35. CSV and TXT files store information in plain text. The first row in the file defines the names (5)
for all subsequent fields. In CSV files, fields are always separated by commas. In TXT files, fields
can be separated with a comma, semicolon, or tab. (1 marks)

import csv #( ½ mark for import csv)

def INSERT(): #(1 ½ for correct definition of function)


fh=open("Sdetails.csv",'w')
swriter=csv.writer(fh)
ans='y'
swriter.writerow(['RollNo','Name','Class','Marks'])
ans='y'
while ans=='y' or ans=='Y':
rn=int(input("Enter Roll No"))
nm=input("Enter Name")
cl=int(input("Enter class"))
mk=int(input("Enter marks"))

9
Page 9 of 11| KVS – Lucknow Region | Session 2023-24
srec=[rn,nm,cl,mk]
swriter.writerow(srec)
ans=input("if you want to enter more record press Y/N")
fh.close()

def COUNTROW(): #(1 ½ for correct definition of function)


with open("Sdetails.csv",'r', newline='\r\n') as fh:
sreader=csv.reader(fh)
count=0
for r in sreader:
count+=1
print("total record = ",count)
fh.close()
#main program
INSERT()
COUNTROW() ( ½ mark for both function call statements)
OR

Syntax to create reader object:

Object=csv.reader(“filehandle”) ( ½ mark)

Object=csv.writer(“filehandle”)( ½ mark)

import csv #( ½ mark for import csv)


def ADD( ): # (1½ mark for correct definition)
f=open("empdata.csv",'w')
swriter=csv.writer(f)
ans='y'
swriter.writerow(['Eid','EName','Salary','City'])
ans='y'
while ans=='y' or ans=='Y':
eid=int(input("Enter employee id"))
enm=input("Enter Employee Name")
es=int(input("Enter Salary"))

10
Page 10 of 11| KVS – Lucknow Region | Session 2023-24
ec=input("Enter City")
erec=[eid,enm,es,ec]
swriter.writerow(erec)
ans=input("if you want to enter more record press Y/N")
f.close()

def SEARCH(): #(1 ½ mark for correct definition)

with open("empdata.csv",'r', newline='\r\n') as fh:


ereader=csv.reader(fh)
for r in ereader:
if int(r[2])>50000:
print(r[0],r[1],r[2],r[3])
break
else:
print("Employee Data not found")

#main (1/2 marks of functions calling)


ADD()
SEARCH()
*****End Of Paper*****

11
Page 11 of 11| KVS – Lucknow Region | Session 2023-24
KENDRIYA VIDYALAYA SANGATHAN
GUWAHATI REGION
PRE BOARD – II (Session 2023-24)
Class : XII Subject: (083) Computer Science
Maximum Marks : 70 Time Allowed: 03:00 Hours
General Instructions:
• Please check this question paper contains 35 questions.
• The paper is divided into 4 Sections- A, B, C, D and E.
• Section A, consists of 18 questions (1 to 18). Each question carries 1 Mark.
• Section B, consists of 7 questions (19 to 25). Each question carries 2 Marks.
• Section C, consists of 5 questions (26 to 30). Each question carries 3 Marks.
• Section D, consists of 2 questions (31 to 32). Each question carries 4 Marks.
• Section E, consists of 3 questions (33 to 35). Each question carries 5 Marks.
• All programming questions are to be answered using Python Language only.

SECTION – A
Q1. State True or False (1)
"In Python, data type of a variable depends on its value"
Q2. The correct definition of column ‘alias’ is (1)
a. A permanent new name of column
b. A new column of a table
c. A view of existing column with different name
d. A column which is recently deleted
Q3 What will be the output of the following python expression? print(2**3**2) (1)
a. 64 b. 256 c. 512 d. 32
Q4. 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.
Q5. In MYSQL database, if a table, Alpha has degree 5 and cardinality 3, and another table, Beta has (1)
degree 3 and cardinality 5, what will be the degree and cardinality of the Cartesian product of
Alpha and Beta?
a. 5,3 b. 8,15 c. 3,5 d. 15,8
Q6. Identify the device on the network which is responsible for forwarding data from one (1)
device to another
a. NIC b. Router c. RJ45 d. Repeater
Q7. Choose the most correct statement among the following – (1)

Page 1 of 10
a. a dictionary is a sequential set of elements
b. a dictionary is a set of key-value pairs
c. a dictionary is a sequential collection of elements key-value pairs
d. a dictionary is a non-sequential collection of elements
Q8. Select the correct output of the code: (1)
a = "Year 2024 at all the best"
a = a.split('a')
b = a[0] + "-" + a[1] + "-" + a[3]
print (b)

a. Year – 0- at All the best


b. Ye-r 2024 -ll the best
c. Year – 024- at All the best
d. Year – 0- at all the best
Q9. Which of the following statement(s) would give an error during execution? (1)
S=["CBSE"] # Statement 1
S+="Delhi" # Statement 2
S[0]= '@' # Statement 3 S=S+"Thank
you" # Statement 4
a) Statement 1 b) Statement 2 c) Statement 3 d) Statement 4
Q10. Give the output: (1)
dic1={‘r’:’red’,’g’:’green’,’b’:’blue’}
for i in dic1:
print (i,end=’’)
a. rgb
b. RGB
c. RBG
d. rbg
Q11. Which function is used to display the unique values of a column of a table? (1)
a. sum()
b. unique()
c. distinct()
d. return()
Q12. Select the correct output of the code: (1)
for i in "QUITE":
print([i.lower()], end= "#")
a. q#u#i#t#e#
b. [‘quite#’]
c. ['q']#['u']#['i']#['t']#['e']#
d. [‘quite’] #

Q13. The statement which is used to get the number of rows fetched by execute() method of (1)
cursor:

Page 2 of 10
a. cursor.rowcount b. cursor.rowscount()
c. cursor.allrows() d. cursor.countrows()
Q14. Select the correct statement, with reference to SQL: (1)
a. Aggregate functions ignore NULL
b. Aggregate functions consider NULL as zero or False
c. Aggregate functions treat NULL as a blank string
d.NULL can be written as 'NULL' also.
Q15. is a communication protocol responsible to control the transmission of data over a (1)
network.
a. TCP (b) SMTP (c) PPP (d)HTTP
Q16. Which method is used to move the file pointer to a specified position. (1)
a. tell()
b. seek()
c. seekg()
d. tellg()

Q17 and 18 are ASSERTION AND REASONING based questions. Mark the correct choice as (1)
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
C. A is True but R is False
d. A is false but R is True
Q17. Assertion (A):- The number of actual parameters in a function call may not be equal to the (1)
number of formal parameters of the function.
Reasoning (R):- During a function call, it is optional to pass the values to default
parameters.

Q18. Assertion (A): A tuple can be concatenated to a list, but a list cannot be concatenated to a (1)
tuple.
Reason (R): Lists are mutable and tuples are immutable in Python.

SECTION B
Q19. 1+1
(i) Expand the following terms: =2
SMTP , FTP

(ii) Give one difference between XML and HTML.


OR
(i) Write short note on TELNET

(ii) Name the following


Two commonly used web browsers

Page 3 of 10
Q20. a) Rishaan has written a code to input a number and check whether it is even or odd number. (2)
His code is having errors. Observe the following code carefully and rewrite it after removing
all syntax and logical errors. Underline all the corrections made.
Def checkNumber(N):
status = N%2
return
#main-code
num=int( input(“ Enter a number to check :))
k=checkNumber(num)
if k = 0:
print(“This is EVEN number”)
else:
print(“This is ODD number”)
Q21. a) Write a function countNow(CITY) in Python, that takes the dictionary, CITY as an argument (2)
and displays the names (in uppercase) of the CITY whose names are longer than 5
characters.
For example, Consider the following dictionary
CITY={1:"Delhi",2:"Guwahati",3:"Ajmer",4:"Jaipur",5:"Udaipur”}
The output should be:
GUWAHATI
JAIPUR
UDAIPUR
OR
a) Write a Python code to accept a word /String a mixed case and pass it to a function the
function should count the number of vowels present in the given string and return the
number of vowels to the main program.
Sample Input : computer science
Sample output : No of vowels = 6
Q22. Predict the output of the Python code given below: (2)
def Swap (a,b ) :
if a>b:
print(“changed ”,end=“”)
return b,a
else:
print(“unchanged ”,end=“”)
return a,b
data=[11,22,16,50,30]
for i in range (4,0,-1):

Page 4 of 10
print(Swap(data[i],data[i-1]))
Q23. Choose the best option for the possible output of the following code (2)
import random
L1=[random.randint(0,10) for x in range(3)]
print(L1)
(a) [0,0,7] (b) [9,1,7] (c) [10,10,10] (d) All are possible

OR
import random
num1=int(random.random()+0.5)
What will be the minimum and maximum possible values of variable num1
Q24. Ms. Tejasvi has just created a table named “Student” containing columns sname, Class and Mark. (2)
After creating the table, she realized that she has forgotten to add a primary key column in the
table. Help her in writing an SQL command to add a primary key column StuId of integer type to
the table Student.
Thereafter, write the command to insert the following record in the table:
StuId- 1299
Sname- Shweta
Class: XII
Mark: 98
Q25. Predict the output of the following code: (2)
value = 50
def display(N):
global value
value = 25
if N%7==0:
value = value + N
else:
value = value - N
print(value, end="#")
display(20)
print(value)
OR
Predict the output of the Python code given below:
a=20
def call():
global a
b=20
a=a+b
return a
print(a)
call()
print(a)

Page 5 of 10
SECTION – C
Q26. Predict the output of the Python code given below: (3)

Q27. a) Consider the table CLUB given below and write the output of the SQL queries that follow. (3)

CCODE CNAME MAKE COLOUR CAPACITY CHARGES


105 Fortuner Toyota White 7 1500
245 Nexon Tata Black 5 1000
130 Duster Renault Green 6 2000
225 Kwid Renault Grey 5 2500
120 Baleno Suzuki Red 5 4000
207 Nano Tata Blue 4 3500

(i) SELECT DISTINCT MAKE FROM CAR;


(ii) SELECT MAKE, COUNT(*) FROM CAR GROUP BY MAKE;
(iii) SELECT CNAME FROM CAR WHERE CAPACITY>5 ORDER BY CNAME;
Q28. Write a function in Phyton to read lines from a text file visiors.txt, and display only those lines, (3)
which are starting with an alphabet 'P'.
If the contents of file is :
Visitors from various cities are coming here. Particularly, they
want to visit the museum.
Looking to learn more history about countries with their cultures. The output should be:
Particularly, they want to visit the museum.
OR
Write a method in Python to read lines from a text file book.txt, to find and display the
occurrence of the word 'are'. For example, if the content of the file is:
Books are referred to as a man’s best friend. They are very beneficial for mankind and have
helped it evolve. Books leave a deep impact on us and are responsible for uplifting our mood.

The output should be 3.

Page 6 of 10
Q29. A relation Toys is given below : (3)
T_no Name Company Price Qty
T001 Doll Barbie 1200 10
T002 Car Seedo_wheels 550 12
T003 Mini House Barbie 1800 15
T004 tiles Seedo_wheels 450 20
T005 Ludo Seedo_wheels 200 24

Write SQL commands to:


a. Display the average price of each type of company having quantity more than 15.
b. Count the type of toys manufactured by each company.
c. Display the total price of all toys.

Q30. A list, NList contains following record as list elements: (3)


[City, Country, distance from Delhi]
Each of these records are nested together to form a nested list. Write the following user defined
functions in Python to perform the specified operations on the stack named travel.

(i) Push_element(NList): It takes the nested list as an argument and pushes a list object
containing name of the city and country, which are not in India and distance is less than 3500 km
from Delhi.
(ii) Pop_element(): It pops the objects from the stack and displays them. Also, the function should
display “Stack Empty” when there are no elements in the stack.

For example: If the nested list contains the following data:


NList=[["New York", "U.S.A.", 11734],
["Naypyidaw", "Myanmar", 3219],
["Dubai", "UAE", 2194],
["London", "England", 6693],
["Gangtok", "India", 1580],
["Columbo", "Sri Lanka", 3405]]
The stack should contain:
['Naypyidaw', 'Myanmar'],
['Dubai', 'UAE'],
['Columbo', 'Sri Lanka']
The output should be:
['Columbo', 'Sri Lanka']
['Dubai', 'UAE']
['Naypyidaw', 'Myanmar']
Stack Empty

Page 7 of 10
SECTION – D
Q31. Consider the following tables Consumer and Stationary. (4)

Table: Stationary
StationaryNa
S_ID Company Price
me
BP01 Ball Pen Reynolds 10
PL02 Pencil Natraj 5
ER05 Eraser Natraj 3
PL01 Pencil Apsara 6
GP02 Gel Pen Reynolds 15

Table: Consumer
C_ID ConsumerName City S_ID
01 Pen House Delhi PL01
06 Write Well Mumbai GP02
12 Topper Delhi BP01
15 Good Learner Delhi PL02
16 Motivation Bangalore PL01
Write SQL statements for (i) to (iv)
(i) To display the consumer detail in descending order of their name.
(ii) To display the Name and Price of Stationaries whose Price is in the range 10 to 15.
(iii) To display the ConsumerName, City and StationaryName for stationaries of "Reynolds"
Company
iv) To increase the Price of all stationary by 2 Rupees

Q32 (a) What does CSV stand for? (4)


(b) Write a Program in Python that defines and calls the following user defined functions:
(i) InsertRow() – To accept and insert data of an student to a CSV file ‘class.csv’. Each
record consists of a list with field elements as rollno, name and marks to store roll
number, student’s name and marks respectively.
(ii) COUNTD() – To count and return the number of students who scored marks greater than
75 in the CSV file named ‘class.csv’.
Section – E
Q33. XYZ Media house campus is in Delhi and has 4 blocks named Z1, Z2, Z3 and Z4. The tables given (5)
below show the distance between different blocks and the number of computers in each block.

Page 8 of 10
The company is planning to form a network by joining these blocks.
i. Out of the four blocks on campus, suggest the location of the server that will provide the best
connectivity. Explain your response.
ii. For very fast and efficient connections between various blocks within the campus, suggest a
suitable topology and draw the same.
iii. Suggest the placement of the following devices with justification
(a) Repeater
(b) Hub/Switch
iv. VoIP technology is to be used which allows one to make voice calls using a broadband internet
connection. Expand the term VoIP.
v. The XYZ Media House intends to link its Mumbai and Delhi centers. Out of LAN, MAN, or
WAN, what kind of network will be created?
Justify your answer.
Q34. 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”

OR
A binary file “STUDENT.DAT” has structure (admission_number, Name, Percentage). Write a
function countrec() in Python that would read contents of the file “STUDENT.DAT” and display the
details of those students whose percentage is above 75. Also display number of students scoring
above 75%

Page 9 of 10
Q35 (i) Define the term Domain with respect to RDBMS. Give one example to support your answer. 5

(ii) Kabir wants to write a program in Python to insert the following record in the table 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 Python and MySQL:


Username - root
Password - tiger
Host - localhost

The values of fields rno, name, DOB and fee has to be accepted from the user. Help Kabir to write
the program in Python.
OR
(i) Give one difference between Primary key and unique key.

(ii) Sartaj has created a table 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 Python and MySQL:


Username - root
Password - tiger
Host - localhost

Page 10 of 10
KENDRIYA VIDYALAYA SANGATHAN
GUWAHATI REGION
PRE BOARD – II EXAMINATION (Session 2023-24)
Class : XII Time Allowed : 03:00 Hours
Subject: (083) Computer Science Maximum Marks : 70

General Instructions:
• Please check this question paper contains 35 questions.
• The paper is divided into 4 Sections- A, B, C, D and E.
• Section A, consists of 18 questions (1 to 18). Each question carries 1 Mark.
• Section B, consists of 7 questions (19 to 25). Each question carries 2 Marks.
• Section C, consists of 5 questions (26 to 30). Each question carries 3 Marks.
• Section D, consists of 2 questions (31 to 32). Each question carries 4 Marks.
• Section E, consists of 3 questions (33 to 35). Each question carries 5 Marks.
• All programming questions are to be answered using Python Language only.
SECTION – A
Q1. True (1)
Q2. C ) A view of existing column with different name (1)
Q3. c) 512 (1)
Q4. c) {'A':4000, 'B':2500, 'C':3000} (1)
Q5. b) 8,15 (1)
Q6. b) Router (1)
Q7. (b) a dictionary is a set of key-value pairs (1)
Q8. b)Ye-r 2024 -ll the best (1)
Q9. d) Statement 4 (1)
Q10. a) rgb (1)
Q11. c) distinct() (1)
Q12. c) ['q']#['u']#['i']#['t']#['e']# (1)
Q13. a)cursor.rowcount (1)
Q14. a) Aggregate functions ignore NULL (1)
Q15. a. TCP (1)
Q16. b) SEEK (1)
Q17. a) (1)
Q18. d) (1)

Page 1 of 7
SECTION – B
Q19. (i) ½ mark for each correct expansion (2)
HTML( Hypertext mark Up language)
We use pre-defined tags
Static web development language – only focuses on how data looks
It use for only displaying data, cannot transport data
Not case sensitive

XML (Extensible Markup Language)


we can define our own tags and use them
Dynamic web development language – as it is used for transporting and storing data
Case sensitive
1 mark for any one correct difference No mark to be awarded if only full form is given
OR
(I) 1 mark for correct definition
(ii) 1/2 mark for each correct name of web browser.
Q20. Def checkNumber(N): # Def should be def (2)
status = N%2
return # return what? Should be return status
#main-code
num=int( input(“ Enter a number to check :)) # Message not enclosed within quotation
mark
k=checkNumber(num)
if k = 0: # must be k = = 0
print(“This is EVEN number”)
else:
print(“This is ODD number”)

(½ mark for each correct correction made and underlined.)


Q21. ½ mark for correct function header (2)
½ mark for correct loop
½ mark for correct if statement
½ mark for displaying the output
OR
½ mark for correct function header
½ mark for correct loop
½ mark for correct if statement
½ mark for displaying the output
Q22. unchanged (30, 50) (2)
changed (16, 50)
unchanged (16, 22)
changed (11, 22)
(½ mark for each correct Output)

Page 2 of 7
Q23. d) All are possible (2)
OR
Minimum 0 and maximum 1
(1 mark for each correct Output)
Q24. 1 mark for correct ALTER TABLE command (2)
SQL Command to add primary key:
ALTER TABLE Student ADD StuId INTEGER PRIMARY KEY;
1 mark for correct INSERT command
As the primary key is added as the last field, the command for inserting data will be:
INSERT INTO Student VALUES("Shweta","XII",98,1299);
Alternative answer:
INSERT INTO Student(Stuid,Sname,class,Mark) VALUES(1299,"Shweta","XII",98);
Q25. 50#5 (2 marks for correct answer) (2)
OR
20
40
(2 marks for correct answer)
SECTION – C
Q26. ND-*34 (3)
(½ mark for each correct character )
Q27. 1 mark for each correct output (3)
(i)
MAKE
Toyota
Tata
Renault
Suzuki
(ii)
MAKE COUNT(*)
Toyota 1
Tata 2
Renault 2
Suzuki 1
(iii)
CNAME
Duster
Fortuner
Q28. def rdlines(): (3)
file = open('visitors.txt','r') for line in file:
if line[0] == 'P': print(line)
file.close()

Page 3 of 7
# Call the rdlines function. rdlines()
½ mark for function header
1 mark for opening file
1 mark for correct for loop and condition
½ mark for closing file
OR
def count_word():
file = open('india.txt','r') count = 0
for line in file:
words = line.split() for word in
words:
if word == 'India': count += 1
print(count) file.close()
# call the function count_word(). count_word()
½ mark for function header
1 mark for opening file
1 mark for correct for loop and condition
½ mark for closing file
Q29. Select company, avg(Price) from toys group by company having Qty>15; (3)
Select Company, count(distinct name) from toys group by Company;
Select name, sum(Price* Qty) from toys;
½ mark for the Select with avg(), ½ mark for the having clause
½ mark for the Select with count() , ½ mark for group by clause
½ mark for the Select with sum() , ½ mark for the group by clause
Q30. (3)

1 ½ marks for each function

Page 4 of 7
SECTION – D
Q31. i) SELECT * FROM Consumer ORDER BY ConsumerName DESC (4)
(ii) SELECT StationaryName, Price FROM Stationary WHERE Price>=10 AND Price<=15
(iii) SELECT C.ConsumerName, C.City, S.StationaryName FROM Stationary S, Consumer C
WHERE C.S_ID=S.S+ID AND S.Company="Reynolds";
iv) UPDATE Stationary SET Price=Price+2

Q32. (a) Comma separated value 1 marks (4)


(b) (i) 2 Marks
def InsertRow():
import csv
f=open("class.csv","a+",newline="")
rno=int(input("Enter roll no. :"))
name=int(input("Enter name :"))
marks=int(input("Enter marks :"))
wo=csv.writer(f)
wo.writerow([rno, name, marks])
f.close()

(b)(ii) 2 Marks
def COUNTD():
import csv
count=0
f=open("class.csv","r")
ro=csv.reader(f)
for i in ro:
if i[2]>75:
count+=1
return count
½ mark for opening and closing file
½ mark for reader object
½ mark for print heading
½ mark for printing data
SECTION – E
Q33. i. Z2 as it has maximum number of computers. (5)
ii. For very fast and efficient connections between various blocks within the campus suitable
topology: Star Topology

Page 5 of 7
iii. Repeater: To be placed between Block Z2 to Z4 as distance between them is more than 100
metres.

Hub/Switch: To be placed in each block as each block has many computers that needs to be
included to form a network.
iv. Voice Over Internet Protocol
v. WAN as distance between Delhi and Mumbai is more than 40kms.
(1 mark for each correct answer)
34. import pickle 5
def createFile():
fobj=open("Book.dat","ab")
BookNo=int(input("Book Number : "))
Book_name=input("Name :")
Author = input("Author:" )
Price = int(input("Price : "))
rec=[BookNo,Book_Name,Author,Price]
pickle.dump(rec,fobj)
fobj.close()
def CountRec(Author):
fobj=open("Book.dat","rb")
num = 0
try:
while True:
rec=pickle.load(fobj)
if Author==rec[2]:
num = num + 1
except:
fobj.close()
return num
or
import pickle
def CountRec():
fobj=open("STUDENT.DAT","rb")
num = 0
try:
while True:
rec=pickle.load(fobj)
if rec[2] > 75:
print(rec[0],rec[1],rec[2],sep="\t")
num = num + 1
except:
fobj.close()
return num

Page 6 of 7
Q35. Domain is a set of values from which an attribute can take value in each row. For example, roll no (5)
field can have only integer values and so its domain is a set of integer values
½ mark for correct definition
½ mark for correct example

½ mark for importing correct module


1 mark for correct connect()
½ mark for correctly accepting the input
1 ½ mark for correctly executing the query
½ mark for correctly using commit()
OR

(I) 1 mark for correct difference


(II)

½ mark for importing correct module


1 mark for correct connect()
1 mark for correctly executing the query
½ mark for correctly using fetchall()
1 mark for correctly

Page 7 of 7
के न्द्रीय विद्यालय संगठन , बेंगलुरू संभाग
KENDRIYA VIDYALAYA SANGATHAN, BENGALURU REGION
प्रथम प्री बोर्ड परीक्षा – 2023-24
FIRST PRE BOARD EXAMINATION – 2023-24
Subject: Computer Science (083)
Time: 3:00 Hrs Maximum Marks: 70
General Instructions:
 Please check this question paper contains 35 questions.
 The paper is divided into 4 Sections- A, B, C, D and E.
 Section A, consists of 18 questions (1 to 18). Each question carries 1 Mark.
 Section B, consists of 7 questions (19 to 25). Each question carries 2 Marks.
 Section C, consists of 5 questions (26 to 30). Each question carries 3 Marks.
 Section D, consists of 2 questions (31 to 32). Each question carries 4 Marks.
 Section E, consists of 3 questions (33 to 35). Each question carries 5 Marks.
 All programming questions are to be answered using Python Language only.

SECTION - A
1 State True or False 1
“If a loop terminates using break statement, loop else will not execute”
2 BETWEEN clause in MySQL cannot be used for 1
a) Integer Fields b) Varchar fields
c) Date Fields d) None of these
3 What will be the output of the following code snippet? 1
a=10
b=20
c=-5
a,b,a = a+c,b-c,b+c
print(a,b,c)
a) 5 25 -5 b) 5 25 25
c) 15 25 -5 d) 5 25 15
4 What is the result of the following code in python? 1
S="ComputerExam"
print(S[2]+S[-4]+S[1:-7])
a) mEomput b) mEompu
c) MCompu d) mEerExam
5 ____________ command is used to add a new column in an existing table in MySQL? 1
6 The IP (Internet Protocol) of TCP/IP transmits packets over Internet using ________ 1
switching.
a) Circuit b) Message
c) Packet d) All of the above
7 Consider a list L = [5, 10, 15, 20], which of the following will result in an error. 1
a) L[0] += 3 b) L += 3 c) L *= 3 d) L[1] = 45
8 Which of the following is not true about dictionary ? 1
a) More than one key is not allowed
b) Keys must be immutable

Page 1 of 8
c) Values must be immutable
d) When duplicate keys encountered, the last assignment wins
9 Which of the following statements 1 to 4 will give the same output? 1
tup = (1,2,3,4,5)
print(tup[:-1]) #Statement 1
print(tup[0:5]) #Statement 2
print(tup[0:4]) #Statement 3
print(tup[-4:]) #Statement 4
a) Statements 1 and 2 b) Statements 2 and 4
c) Statements 2 and 5 d) Statements 1 and 3
10 What possible outputs(s) will be obtained when the following code is 1
executed?
import random
VALUES = [10, 20, 30, 40, 50, 60, 70, 80]
BEGIN = random.randint(1,3)
LAST = random.randint(BEGIN, 4)
for x in range(BEGIN, LAST+1):
print(VALUES[x], end = "-")
a) 30-40-50- b) 10-20-30-40-
c) 30-40-50-60- d) 30-40-50-60-70-
11 Which of the following command is used to move the file pointer 2 bytes ahead from the 1
current position in the file stream named fp?
a) fp.seek(2, 1) b) fp.seek(-2, 0)
c) fp.seek(-2, 2) d) fp.seek(2, -2)
12 Predict the output of the following code: 1
def ChangeLists(M , N):
M[0] = 100
N = [2, 3]
L1 = [-1, -2]
L2 = [10, 20]
ChangeLists(L1, L2)
print(L1[0],"#", L2[0])
a) -1 # 10 b) 100 # 10
c) 100 # 2 c) -1 # 2
13 Which of the following is not a function of csv module? 1
a) readline() b) writerow()
c) reader() d) writer()
14 State True or False 1
“A table in RDBMS can have more than one Primary Keys”
15 COUNT(*) function in MySQL counts the total number of _____ in a table. 1
a) Rows b) Columns
c) Null values of column d) Null values of a row
16 Which of the following is not a method for fetching records from MySQL table using Python 1
interface?
a) fetchone() b) fetchrows()
c) fetchall() d) fetchmany()

Page 2 of 8
Q17 and 18 are ASSERTION AND REASONING based questions. Mark the correct choice
as
(a) Both A and R are true and R is the correct explanation for A
(b) Both A and R are true and R is not the correct explanation for A
(c) A is True but R is False
(d) A is false but R is True
17 Assertion (A):- Text file stores information in ASCII or UNICODE characters. 1
Reasoning (R):- In text file there is no delimiter(EOL) for a line.
18 Assertion (A):- HAVING clause is used with aggregate functions in SQL. 1
Reasoning (R):- WHERE clause places condition on individual rows.
SECTION – B
19 Differentiate between Circuit Switching and Packet Switching. 2
OR
Write one similarity and one point of difference between HTML and XML
20 Rewrite the following code in python after removing all syntax error(s) and underline each 2
correction made by you in the code.
D = dict[]
c=1
while c < 5:
k = input(“Name: “)
v = int(input(“Age: “)
D(k) = v
print(popitem())
for a,b in D.item:
print(a, b)
21 Write the output of the following code: 2
L1=[100,900,300,400,500]
START=1
SUM=0
for C in range (START, 4):
SUM=SUM+L1[C]
print(C,":",SUM)
SUM=SUM+L1[0]*10
print(SUM)
22 (a) Given is a Python string declaration: 1
st = ‘AMPLIFY&AMPLITUTE’
Write the output of : print(st.count(‘PLI’,2,12))
1
(b) Write the output of the code given below:
D = {‘A’:’AJAY’ , ‘GRADE’:’A’}
print(list(D.values()))
23 Expand the following terms: 2
(i) PPP (ii) SMTP (iii) VoIP (iv) TCP/IP
24 Explain the following: 2
(i) Primary Key (ii) Foreign Key

Page 3 of 8
25 Define constraint in context with Relational Database Management System. Explain any two 2
constraints of MySQL.

SECTION – C
26 Predict the output of the Python code given below: 3
x = 25
def modify(s, c=2):
global x
for a in s:
if a in 'QWEiop':
x //= 5
print(a.upper(),'@',c*x)
else:
x += 5
print(a.lower(),'#',c+x)
string = 'We'
modify(string,10)
print(x, '$', string)

27 Write the output of the queries (i) to (iii) based on the table PRODUCTS given below:

Table: PRODUCTS
CODE ITEM QTY PRICE TDATE
1001 Plastic Folder 14'' 100 3400 2014-12-14
1004 Pen Stand Standard 200 4500 NULL
1005 Stapler Mini 250 1200 2015-02-28
1009 Punching Machine Small NULL 1400 2015-03-12
1003 Stapler Big 100 1500 NULL

i) SELECT COUNT(TDATE) FROM PRODUCTS;


ii) SELECT MAX(TDATE) FROM PRODUCTS WHERE PRICE BETWEEN 1000 AND
1400;
iii) SELECT ITEM, QTY*PRICE AS TOTAL FROM PRODUCTS
WHERE QTY > 200 AND ITEM LIKE ‘%tap%’ ;
28 Write a method COUNTWORDS() in Python to read data from text file ‘ARTICLE.TXT’ and 3
display the count of words which ends with a vowel.

For example, if the file content is as follows:

An apple a day keeps you healthy and wise

The COUNTWORDS() function should display the output as:


Total words which ends with vowel = 4

Page 4 of 8
29 Consider the table TRAINER given below: 3

Table: TRAINER
TID TNAME CITY HIREDATE SALARY
101 SUNAINA BOMBAY 1998-10-15 90000
102 ANAMIKA DELHI 1994-12-24 80000
103 DEEPTI CHANDIGARH 2001-12-21 82000
104 MEENAKSHI DELHI 2002-12-25 78000
105 RICHA BOMBAY 1996-01-12 95000
106 MANIPRABHA CHENNAI 2001-12-12 69000

Based on the given table, write SQL queries for the following:
(i) Display TNAME, CITY and HIREDATE of those trainers who were hired in the year 2001
(ii) Change the name of city as MUMBAI wherever name of city is BOMBAY
(iii) Add primary key constraint in the existing TRAINER table, to make TID as primary key.
30 Write separate user defined functions for the following : 3
(i) PUSH(N) This function accepts a list of names, N as parameter. It then pushes only those
names in the stack named OnlyA which contain the letter 'A'.
(ii) POPA(OnlyA) This function pops each name from the stack OnlyA and displays it. When
the stack is empty, the message "EMPTY" is displayed.
For example :
If the names in the list N are
['ANKITA', 'NITISH', 'ANWAR', 'DIMPLE', 'HARKIRAT']
Then the stack OnlyA should store
['ANKITA', 'ANWAR', 'HARKIRAT']
And the output should be displayed as
HARKIRAT ANWAR ANKITA EMPTY

SECTION – D
31 Consider PASSENGERS and TRAINS tables given below: 4
Table: PASSENGERS
PNR TNO PNAME GENDER AGE TRAVELDATE
P001 13005 R N PANDEY MALE 45 2020-12-25
P002 12015 P TIWARY MALE 28 2020-11-10
P003 12015 S TIWARY FEMALE 22 2020-11-10
P004 12030 S K SAXENA MALE 51 2021-12-10
P005 12030 S SAXENA FEMALE 35 2021-12-10
P006 12030 P SAXENA FEMALE 12 2021-12-10
P007 13005 N S SINGH MALE 52 2021-05-09
P008 12030 J K SHARMA MALE 65 2022-01-28
P009 12030 R SHARMA FEMALE 58 2022-01-28

Table: TRAINS
TNO TNAME START END
11096 Ahimsa Express Pune Junction Ahmedabad Junction
12015 Ajmer Shatabdi New Delhi Ajmer Junction

Page 5 of 8
10651 Pune Hublj Special Pune Junction Habibganj
13005 Amritsar Mail Howrah Junction Amritsar Junction
12002 Bhopal Shatabdi New Delhi Habibganj
12417 Prayag Raj Express Allahabad Junction New Delhi
14673 Shaheed Express Jaynagar Amritsar Junction
12314 Sealdah Rajdhani New Delhi Sealdah
12498 Shane Punjab Amritsar Junction New Delhi
12451 Shram Shakti Express Kanpur Central New Delhi
12030 Swarna Shatabdi Amritsar Junction New Delhi

Write SQL queries for the following:


(i) Display the passenger names (PNAME), travel date (TRAVELDATE) and train name
(TNAME) from which each passenger has travelled from PASSENGERS and TRAINS
tables.
(ii) Display the average age of all passengers gender wise.
(iii) Display the details of trains in ascending order of train numbers (TNO)
(iv) Display starting stations (START) of TRAINS table without repetition.
32 Deepali is creating a python program for a Library and created a csv file Books.csv to store 4
the details of books. The structure of Books.csv is:
[BookID, Title, Author, Price]
Where
BookID stores Book ID (integer)
Title stores the title of book (string)
Author stores the author of the book (string)
Price stores the price of the book (float)
She wants to write code for the following user defined functions:
(i) AddBook() – to accept a record from the user and add it to the file Book.csv.
(ii) TotalCost() – to read the csv file Book.csv, convert the price of each book into float data
type, find and display the sum of prices of all the books
As a Python expert, help her complete the task.
OR
Sanjay is working on a binary file, PRODUCTS.DAT, containing records of the following
structure:
{‘PID’:Product ID, ‘PNAME’:Product Name , ‘PRICE’:Product Price}
Help him to write the following user defined functions:
(i) appendData(), that reads the values of Product ID, Product Name and Product price
from the user into a dictionary and append it into binary file PRODUCTS.DAT.
(ii) findProduct(product_id) that accepts product_id as argument to read binary file
PRODUCTS.DAT and display the details of that product.

Page 6 of 8
SECTION - E
33 Medico Group of hospitals is planning to set up its new campus at Pune with its head office 5
at Mumbai. Pune campus will have specialised units for Radiology, Neurology and ENT
alongwith an administrative office in separate buildings. The physical distances between
these units and the number of computers to be installed in these units and administrative
office as given as follows. You as a network expert have to answer the queries as raised by
them in (i) to (v).

MUMBAI PUNE CAMPUS

Distance between various units in metres :

Administrative Office to Radiology Unit 95 m

Neurology Unit to Administrative Office 40 m

Radiology Unit to Neurology Unit 90 m

ENT Unit to Neurology Unit 60 m

ENT Unit to Administrative Office 130 m

ENT Unit to Radiology Unit 150 m

Mumbai Head Office to Pune Campus 147 km

Number of Computers installed at various locations are as follows :

ENT Unit 50

Radiology Unit 70

Administrative Office 120

Neurology 40

Page 7 of 8
(i) Suggest the most suitable location to install the main server to get efficient
connectivity in PUNE campus with justification.
(ii) Suggest and draw the cable layout to efficiently connect various units within the PUNE
campus for connecting the digital devices.
(iii) Suggest the placement of the following device with justification
(a) Repeater
(b) Hub/Switch
(iv) Suggest the topology of the network and network cable for efficiently connecting each
computer installed in each of the unit out of the following :
Topologies: Star Topology, Bus Topology
Network Cable: Co-axial Cable, Ethernet Cable, Single Pair Telephone Cable.
(v) If Mumbai head office is connected with Pune campus, out of the following which type
of network will be formed?
LAN, MAN, PAN, WAN
34 (i) Differentiate between ‘w’ and ‘a’ file modes in Python. 2
(ii) Consider a binary file, FASHION.DAT, containing records of the following structure:
[GID, GNAME, FABRIC, PRICE] 3
Where
GID – Garment ID
GNAME – Garment Name
FABRIC – Type of fabric i.e. COTTON, SILK, SATIN etc.
PRICE – Price of the garment
Write a user defined function, searchFashion(cost), that accepts cost as parameter and
displays all the records from the binary file FASHION.DAT, that have price more than 1500.
35 (i) What is meant by Degree of a table in RDBMS? 1
(ii) Krishna wants to write a program in Python to insert the following record into STAFF
table of COMPANY database using python interface. 4
SID (Staff ID) – Integer
SNAME (Name of staff member) - String
DOJ (Date of Joining) – Date
SALARY – Float
Note the following to establish connectivity between Python and MySQL:
 Username - root
 Password - tiger
 Host - localhost
The values of fields SID, SNAME, DOJ and SALARY has to be accepted from the user. Help
Krishna to write the program in Python.

******** END ********

Page 8 of 8
REGION
BENGALURU
KENDRIYAVDYALAYA SANGATHAN
f-2023-24
2023-24
FIRST PRE BOARD I EXAMINATION
Maximum Marks: 70
MARKING SCHEME (083)
Time: 3:00 Hrs Subject: Computer
Science
Total
Distributionofmarks
Marks

Answer
answer
True SECTON -A mark for
corTCCt
answer
2 d) None of these for correct
Imark
3 c) 15 25 -5 corrcctanswer
mark for
4 b) mEonpu correct answer
1mark for
ALTER TABLE correctanswer
mark for
6 c) Packet correct answer
mark for
7 b) L +=3 answer
mark for corect
c) Values must be answer
imnmutable 1mark for correct
d) Statements and 3 1
1mark for correct answer
a) 30-40-50
1mark for correct answer
11 a) fp.seek(2, 1) 1mark for correct answer
12 b) 100 # 10
13 1mark for correct answer 1
a) readline()
14 False mark for correct answer
15 a) Rows 1mark for correct answer
16 b) fetchrows() 1mark for correct answer
017 and 18 are 1mark for correct answer
ASSERTION AND
questions. Mark the correct choiceREASONING
as
based
(a) Both A andR are true
and R is the correct
(b) Both A and R are true explanation for A
andR is not the correct
for A explanation
(c) Ais True but R is False
(d)A is false but R is True
17 (c)
18 (b)
SECTION - B
19
Circuit Switching Packet Switching
Physical link must be Works on storc and I
mark
cstablishcd irst.
A uniform path is
forward
There is nounitorm path
correct each fOr any two
differences 2
followed throughout the that is followed end to
sessio. endthrough the session
It is ideal for voice li is Used minly for data
Page I of 6
Iransmission
Corrcct
Similarities OR foronc any
Both arc used to Imark markfor
I
Pre defined tagS developweb pages
can be used in both
Sinnilarity.
one corrcctd1fference

Dtferences
HTML is used 1o
wcb pages develop
static wcb pages, XML for dynamic
New fags can be
20 D dict) defined in XMI mark for
cach
½
corrcction made

while c <5:
k=input(Name: )
V= int(input(Age: )
DÊkl = V
print(D.popitem0)
for a,b in D.items):
print(a, b)
correct
21 Write the output of the ½ mark for cach
I:900
following code: line of output
2:2200
3:3600
4600
22 (a) 1 1mark for correct output

(b) ['AJAY", 'A] 1mark for correct output

23 (i)PPP- Point to Point Protocol ½ mark for each


(ii) SMTP - Simple MailTransfer Protocol
correct
full formn
(iii) VolP Voice over Internet Protocol
(iv) TCP/IP Transmission Control Protocol /Internet Protocgl
24 (i) Primary Key - Attribute or combination of attributes that 1mark
each for correct
uniquely identifies the rows. 2
(ii) Foreign Key- Non key attributes that derive its values from explanation
table
25 the Primary Key/Unique key of another
Arule or a check that is applicable one of more columns.
UNIQUE, DEFAULT 1mark for
NOTNULL, PRIMARY KEY, the
(Explanation of. any two
constraints)
V
mark each fordefinition.
any two
SECTION-C constraints.
26 W @ 50 1
e #20 mark cach ior
line of output COrrect
Page 2 of6
()30 29 28

POPA(OnlyA):def (ii) PUSH(N):


'HARKIRAT]
defOnlyA=0 BOMBAY';
N= =(ii)
(ii1)CITY WHERE fil.close()
print("Total
()) Note: forCountfil.read)
open('ARTICLE.TXT',r) =0 data =
else:ifOnlyA[=-
): for data.split) words fil =%tap%;
PRODUCTS in) I)SWe
name:
if'A'in UPDATE SELECT if w WHERE
while
print('EMPTY') name [ANKITA",
NITISH, ALTER Any Count
t=| w[-1] in
words: Stapler
Mini ITEM
HIREDATE MAX(TDATE)COUNT(TDATE)
SELECT COUNT(TDATE)
SELECT FROMSELECT
2015-03-12
nlyA.pop(),end="OnlyA")OnlyA.append(name) in other words in PRICE
N:
TABLE
TRAINER TNAME, 'aeiouAEIOU:
WHERE 3
correct
!= which BETWEEN
ITEM,MAX(TDATE) M
: TRAINER LIKE
SET
CITY, logic ends QTY
'ANWAR', 2000%; QTY**PRICE
HIREDATE may
CITY 300000 TOTAL > 1000
ADD with 200
be ) FROM
= vowel=,count)
marked AND AND
PRIMARYMUMBAI'
Page DIMPLE, AS
FROM ITEM
TOTAL 1400:
PRODUCTS
3
of PRODUCTS:
6 KEY WHERE TRAINER LIKE

(TID) FROM
function query output. statement ½file
1 mark 1 ½and if I
mark
mark readindatg a mark openi ng mark I
marks
output mark I
for for for for
for each and for for
each
displaying correct correctly clocorsingrectly cach
correct
loop cor ect
the
the

3
6ofPage4 D=}
float(input('Enter Pice=
data product input('Enter
:)) price pname=
produt
int(input('Enter pid
=
dictiothwrenaritiyng I name
:)
ID
iforntomark data open('PRODUCTS.DAT,ab')
:)product biil=
readi
the ng for mark appendData(): def
½
file closing
the pickle import
openi
and ng for mark 2 (i)
OR
=,total) print("Total
cost
fil.close()
int(x[3|) total+ total
=
data: in forx
total
0=
dataprinting for mark ½ print(data[0])
total list(cr) data=
calculating for mark V½ csv.reader(fill) =Cr
objcct reader for mark Va open('Books.csv',
r) =fil
fileclosing TotalCost(): def
opening
and for mark ½
(ii)
fil.ciosc0
cw.writerow(data)
=['BookID'"TitlePr;Aiceut] hor,; =csv.writer(fil) headings CW
price] author, title, [bid, dat=a
float(input(':pr') iceEnter
name
:) autinput(Enter
hor
input(Enter
:') title book
authorprice
=
t(i:)nputID
,newlopen(ine=")'Binooks. cbooksv'('"Eanter title=
for mark ½ bid
row writing fileclosing
I AddBook(): =fil def
opening for mark
and correctly
for mark ½ csv mpor
accepting TRAINS; ORDERFROM START DISTINCT
TRAINS
data
TNO; BY FROM SELECT (i) 32
4
(iv)
*
SELET GROUP
BY(i)
FROM
AVG(AGE)
TRAVELDATE, GENDER, GENDER:PASSENGERS
.T P.I
RAI NSO-
T TNO: SELET WHERE
query TNAMI. SECTID
ON-ASSENGERS (i1)
cach
Imark
for
AME, P.
correct PSELECT
NA FROM
P/
0) 31
POPA(OnlA)
y
PUSUtNy
of5 Page5
default beginning
by
atdefault. the ponter
at file Places
difierences cor ect the ponter er file byend
Places
datawriting for Used
2 two append1ng
data for Used 'wmode
any () 34
for each mark mode 'a'
I (v)
WAN
Cable Cable: Network
Topology
Ethernet Topologies:
Star (iv)
Hub/Switch (b)
units/office all In -
Radiology
unit
Between Repeater- (a)
Administrative
and office (iii)
ii Unit
Neurology
Radiology Unit Unit
ENT
Administrative| Officc
(i)
netwo reduce
the efficiency
and network traffic.
Admi
itOfas
ficen,plisatc1ngrativcomput
e ers, plain number muumst increase
cedofmaximbe wil
here server
Serthe verrequires
answer ()
for mark
SECTIOE
N-
corTecI each 33
bfil.close()
dictionary except:
mark ½
print(D) -if
D
printung product
tforID
the
comparing
mark
forrecord

open('PRODUCTS.DAD[Tpi|PcbIkD)le'}.lproaodducti(d:bfil)
%
True: while
mark ½ findProduct(pidryo: duct def
for
file closing
the
reading try:
lhc mark ½
for bfil
opening
and
(1)
DPRIpic|pkler.idcump(bley bfiDl.c,lose()
pname AME] DTN.
con.commit()
commit() using
mcur.eXecute(qry,
val).
correctly for mark ½ sal) dt, =(sid,
sn, Wval
qucry executing
the
%s): VALUES(%s,
%s, %s, STUDENT INTO'INSERT dsusaf
YYYY-MM-DD:) joining input('
ectly for mark ½1 ofdateEnter = dt
input accepting
the name:) member input("'Enter
staff
ID:)int(input('
Staff Enter =Sn
for mark ½
orrectly
connect() mc=
ur =sid
for mark
l ms.connect (dathosta-base-COMPANY)
localhost' Con.cursor()
correct passwd-tiger', user='root!,
module Correct
½ mysql.connector =con
rting tor mark msas import
known es
Attribut )
definition Degree as is columns/
aof table.
mark I
for bfil.cnumber
loofsc) Total () 35
corTCCI
file
mark 5 CXcept:
for list
closIng 1S00:print(L)L{3|> if
thc
rinting
mark
or pricc

ASHIONDATH) load(bfil) poicpkelne(.'F L


he mark % True: while
for record
ing scarchtashion(cost): dsel
3 try
mark
for 5
adiing mark bfile
for file
thand trv
b
mark piCkle mport
for
opcnin ParticWrite
CINENfiA
paran le
he TypeWrite
MA Whe
SET-2
KENDRIYA VIDYALAYA SANGATHAN (LUCKNOW REGION)
XII- PRE-BOARD EXAMINATION 2023-24
Computer Science (083)
Time allowed: 3 hours Maximum marks: 70
General Instructions:
 Please check this question paper contains 35 questions.
 The paper is divided into five sections- A, B, C, D and E.
 Section A, consists of 18 questions (1 to 18). Each question carries 01 mark.
 Section B, consists of 07 questions (19 to 25). Each question carries 02 marks.
 Section C consists of 05 questions (26 to 30). Each question carries 03 marks.
 Section D consists of 02 questions (31 to 32). Each question carries 04 marks.
 Section E consists of 03 questions (33 to 35). Each question carries 5marks.
 All programming questions are to be answered using Python Language only.
 15 minutes time has been allotted to read this question paper.

Section – A
Q01. State True or False (1)
“Python is a platform independent, case sensitive and interpreted language”
Q02. Which of the following(s) is/are valid Identifier(s) in Python? (1)
(a) for (b) elif (c) _123 (d) None
Q03. What will be the output of the following Python code? (1)
T1=(1,2,[1,2],3)

T1[2][1]=3.5

print(T1)

(a) (1,2,[3.5,2],3) (b) (1,2,[1,3.5],3) (c) (1,2,[1,2],3.5) (d) Error Message


Q04. What will be the output of the following expression if the value of a=0, b=1 and c=2? (1)
print(a and b or not c )
(a) True (b) False (c) 1 (d) 0
Q05. What should be the output of the following code? (1)
String = “India will be a global player in the digital economy”
Str1= String.title(); Str2=Str1.split()
print(Str2[len(Str2)-1:-3:-1])
(a) [‘Digital’,’Economy’] (b) [‘The’,’Digital’,’Economy’]
(c) [‘economy’,’digital’] (d) [‘Economy’,’Digital’]
Q06. Which of the following statement is incorrect? (1)
(a) A file handle is a reference to a file on disk.
1
Page 1 of 12 | KVS –Lucknow Region | Session 2023-24
(b) File handle is used to read and write data to a file on disk.
(c) All the functions that you perform on a disk file can’t be performed through file handle.
(d) None of these
Q07. Fill in the blank: - (1)
_____________ command is used to add a new column into an existing table in SQL.
(a) UPDATE (b) INSERT (c) ALTER (d) CREATE
Q08. Which of the following command is a DDL command? (1)
(a) SELECT (b) GROUP BY (c) DROP (d) UNIQUE
Q09. Which of the following statement(s) would give an error after executing the following code? (1)
name_marks{'atul':88,'basab':45,'chetan':90} #Statement1
upgrade={} #Statement2
for key in name_marks.keys(): #Statement3
if (name_marks[key]>50): #Statement4
upgrade[key]=name_marks[key] #Statement5
print(upgrade) #Statement6
(a) Statement1 (b) Statement3 (c) Statement4 (d) Statement5
Q10. Fill in the blank: (1)
Number of records/ tuples/ rows in a relation or table of a database is referred to as ________
(a) Domain (b) Degree (c) Cardinality (d) Integrity
Q11. Which of the following statement is not true regarding opening modes of a file? (1)
(a) When you open a file for reading, if the file does not exist, an error occurs.
(b) When you open a file for writing, if the file does not exist, an error does not occur.
(c) When you open a file for appending content, if the file does not exist, an error does not occur.
(d) When you open a file for writing, if the file exists, new content added to the end of the file.
Q12. The __________________ clause is used for pattern matching in MySQL queries. (1)
(a) ALL (b) DESC (c) MATCH (d) LIKE
Q13. A __________________ specifies the distinct address for each resource on the Internet. (1)
(a) FTP (b) WWW (c) URL (d) HTTP
Q14. What will be the output of the following Python code? (1)
print(5<10 and 10<5 or 4<9 and not 3<-3)
(a) True (b) False (c) Error Message (d) None of these
Q15. Which of the following query is incorrect? Assume table EMPLOYEE with attributes (1)
EMPCODE, NAME, SALARY and CITY.
(a) SELECT COUNT(*) FROM EMPLOYEE;
(b) SELECT COUNT(NAME) FROM EMPLOYEE;
(c) SELECT AVG(SALARY) FROM EMPLOYEE;
(d) SELECT MAX(SALARY) AND MEAN(SALARY) FROM EMPLOYEE;
Q16. Which one of the following syntax is correct to establish a connection between Python and (1)
MySQL database using the function connect( ) of mysql.connector package? Assume that import
2
Page 2 of 12 | KVS –Lucknow Region | Session 2023-24
mysql.connector as mycon is imported in the program
.(a) mycon.connect(host = “hostlocal”, user = “root”, password = “MyPass”)
(b) mycon.connect(host = “localhost”, user = “root”, passwd = “MyPass”, database = “test”)

(c) mycon.connect(“host”=“localhost”, “user”= “root”, “passwd”=”MyPass”, “database”= “test”)

(d) mycon.connect(“localhost” = host, “root”=user, “MyPass”=passwd)

Q-17 and Q-18 are ASSERTION AND REASONING based questions. Mark the correct choice as
(a) Both A and R are true and R is the correct explanation for A
(b) Both A and R are true and R is not the correct explanation for A
(c) A is True but R is False &
(d) A is False but R is True
Q17. Assertion(A): Dictionary is an unordered collection of data values that stores the key: value pair. (1)
Reason(R): Immutable means they cannot be changed after creation.
Q18. Assertion(A): Access mode ‘a’ opens a file for appending content at the end of the file. (1)
Reason(R): The file pointer is at the end of the file if the file exists and opens in write mode.
Section – B
Q19. Manish has designed a Python program to calculate factorial of a number passed as argument, (2)
but he is getting errors while executing the code. Rewrite his code after removing errors and
underline each correction.
def factorial():
fact=1
while N>0:
fact=*N
N=N-1
print(“Factorial’ ,fact)
#main( )
Factorial(5)
Q20. Differentiate between Star Topology and Bus Topology. Write two points of difference. (2)
OR
Write two point of difference between Bridge and Gateway.
Q21. (a) Write the output of when Python string declaration is given as follows: - (1)
Mystr=”I love technology while growing up”
print(Mystr[1:len(Mystr):2])
(1)
(b) Write the output of the code given below:
Student_details = {"name": "aditya", "age": 16}
New=Student_details.copy()
New['address'] = "Mumbai"
print(Student_details);
print(New)

Q22. Explain the Relational Database Management System terminologies- Degree and Attribute of a (2)
relation. Give example to support your answer.
Q23. (a) Write the full forms of the following: - (i) FTP (ii) POP (2)

3
Page 3 of 12 | KVS –Lucknow Region | Session 2023-24
(b) What is MAC address?

Q24. Predict the output of the Python code given below: (2)
def modify(L):
for C in range(len(L)):
if C%2==1:
L[C]*=2
else:
L[C]//=2
#Main
N=[5,13,47,9]
modify(N)
print(N)
OR
Predict the output of the Python code given below:
T=(1,2,3,4,5,6,7,8,9)
T1=T[2:8:2]
T2=T[-2:-8:-2]
T3=T1+T2
print(T3[::-1])
Q25. Differentiate between WHERE and HAVING clause used in MySQL with appropriate example. (2)
OR
Explain the use of GROUP BY clause in MySQL with an appropriate example.
Section – C
Q26. (a) Consider the following tables – BILLED and ITEM (1+2)

Table: BILLED
BNO NAME CITY
1001 Ashok Delhi
1002 Manish Jaipur
1003 Rahul Lucknow
Table: ITEM
ITEMCODE INAME PRICE
11 HDD 2500
12 Keyboard 850
13 RAM 1100

What will be the output of the following SQL query statement?


SELECT * FROM BILLED, ITEM;
(b) Write the output of the queries (i) to (iv) based on the table EMPLOYEE given below:

4
Page 4 of 12 | KVS –Lucknow Region | Session 2023-24
Table: EMPLOYEE
EMPID NAME DESIGNATION SALARY CITY
101 Harry Manager 90000 Delhi
102 Sam Director 120000 Mumbai
103 Peter Clerk 45000 Delhi
104 Jack Manager 85000 Kolkata
105 Robert Clerk 55000 Mumbai
(i) SELECT DISTINCT DESIGNATION FROM EMPLOYEE;
(ii) SELECT CITY, SUM(Salary) FROM EMPLOYEE GROUP BY CITY HAVING
SALARY > 50000;
(iii)SELECT NAME, SALARY FROM EMPLOYEE WHERE CITY IN
(‘DELHI’,’KOLKATA’) ORDER BY NAME DESC;
(iv) SELECT NAME, SALARY, CITY FROM EMPLOYEE WHERE NAME LIKE ‘H%’
AND SALARY BETWEEN 50000 AND 90000;

Q27. (a) Write a method COUNT_W5() in Python which read all the content of a text file (3)
‘STORY.TXT’ and count &display all those words whose length is 6 character long.
For Example: - If the file content is as follows:
God made the mother earth and the man made countries;
These countries having states and states consists cities.
Then the output of the method will be
Six characters words are: - mother, These, having, states,cities,output,method
The total no of words with length of 6 characters is: 6
OR
(b) Write a function VC_COUNT() in Python, which should read each character of a text file
“THEORY.TXT” and then count and display all the vowels and consonants separately(including
upper cases and small cases).
Example:
If the file content is as follows:
A boy is playing there. There is a playground.
The VC_COUNT() function should display the output as:
Total vowels are: 14
Total consonants are: 22
Q28. (a) Write the outputs of the SQL queries (i) to (iv) based on the relations ENGINEER and (2+1)
SALARY given below:
Table: ENGINEER
5
Page 5 of 12 | KVS –Lucknow Region | Session 2023-24
EID NAME AGE DEPARTMENT DOJ GENDER
101 RAVI 34 CODING 2007-09-05 M
102 SUMAN 29 NETWORKING 2010-10-10 F
103 MONU 36 CODING 2003-10-20 M
104 RUPALI 32 ANALYSIS 2012-05-12 F
105 ROHIT 24 TESTING 2017-04-10 M

Table: SALARY
EID BASIC HRA DA
101 40000 3000 2000
102 45000 2500 2500
103 50000 5000 2800
104 35000 3000 1600
105 30000 2500 1200
(i) SELECT DEPARTMENT, COUNT(*) FROM ENGINEER GROUP BY
DEPARTMENT;
(ii) SELECT MAX(DOJ), MIN(DOJ) FROM ENGINEER;
(iii) SELECT NAME, DEPARTMENT, (BASIC+HRA+DA) AS “TOTALSALARY”
FROM ENGINEER, SALARY WHERE ENGINEER.EID =SALARY.EID;
(iv) SELECT NAME, HRA FROM ENGINEER E, SALARY S WHERE E.EID=S.EID
AND GENDER = ’F’;
(b) Write a command to view the structure of a table.
Q29. Write a function INTERCHANGE(L), where L is the list of elements passed as argument to the (3)
function. The function returns another list named ‘ChangedList’ that contain values interchanged
as the even index value with next consecutive odd index value of the L.
For example:
If L contains [25,30,35,40,45]
The ChangedList will have [30,25,40,35,45 ]
Q30. A list named as Record contains following format of for students: [student_name, class, city]. (3)
Write the following user defined functions to perform given operations on the stack named
‘Record’:
(i) Push_record(Record) – To pass the list Record = [ ['Rahul', 12,'Delhi'], [‘Kohli',11,'Mumbai'],
['Rohit',12,'Delhi'] ] and then Push an object containing Student name, Class and City of student
belongs to ‘Delhi’ to the stack Record and display and return the contents of stack
(ii) Pop_record(Record) – To pass following Record [[“Rohit”,”12”,”Delhi”] [“Rahul”,
12,”Delhi”] ] and then to Pop all the objects from the stack and at last display “Stack Empty”

6
Page 6 of 12 | KVS –Lucknow Region | Session 2023-24
when there is no student record in the stack. Thus the output should be: -
[“Rohit”,”12”,”Delhi”]
[“Rahul”, 12,”Delhi”]
Stack Empty
OR
A list of numbers is used to populate the contents of a stack using a function push(stack, data)
where stack is an empty list and data is the list of numbers. The function should push all the
numbers that are even to the stack. Also write the function pop() that removes the top element of
the stack on its each call.
Section – D
Q31. Manoj is working in a mobile shop and assigned a task to create a table MOBILES with (1+1+2)
record of mobiles as Mobile code, Model, Company, Price and Date of Launch. After
creation of the table, he has entered data of 5 mobiles in the MOBILES table.
MOBILES
MCODE MODEL COMPANY PRICE DATE_OF_LAUNCH
M01 9PRO REALME 17000 2021-01-01
M02 NOTE11 MI 21000 2021-10-12
M03 10S MI 14000 2022-02-05
M04 NARZO50 REALME 13000 2020-05-01
M05 iPHONE12 APPLE 70000 2021-07-01
Based on the data given above answer the following questions:
(i) Identify the most appropriate column, which can be considered as Primary key.
(ii) Write the degree and cardinality of the above table, after removing one column and two
more record added to the table.
(iii) Write the statements to:
(a) Add a new column GST with data type integer to the table.
(b) Insert the value of GST in the new column as 18% of PRICE.
OR (Option for part iii only)
(iii) Write the statements to:
(a) To insert a new record of mobile as MobileCode – M06, Company Apple,
Model- iPHONE13, Price-110000 and Date of launch – ‘2022-03-01’.
(b) To delete the record of mobile with model as NARZO50.
Q32. Arun, during Practical Examination of Computer Science, has been assigned an (1+1+2)
incomplete search() function to search in a pickled file student.dat. The File student.dat is
created by his Teacher and the following information is known about the file.

7
Page 7 of 12 | KVS –Lucknow Region | Session 2023-24
 File contains details of students in [Rollno, Name, Marks] format.

 File contains details of 10 students (i.e. from Rollno 1 to 10) and separate list of each

student is written in the binary file using dump().

Arun has been assigned the task to complete the code and print details of Roll Number 7.

import _________________ # Statement1


def search( ):
f=______________________ #Statement2
found=0
while True:
try:
rec=pickle._____________ #Statement3
if(_________________): #Statement4
print(rec); found=1
except: break
if (found==0):
print("Record not found")
(i) Which module should be imported in the program? (Statement 1)
(ii) Write the correct statement required to open a file student.dat. (Statement 2)
(iii) Which statement should arun fill in Statement 3 to read the data from the binary file,
student.dat and in Statement 4 to match the Rollno.
Section – E
Q33. Signature Training Institute is planning to set up its centre in Jaipur with four specialized blocks (5)
for MBBS, MBA, BTECH and ADMIN. The physical distance between these blocks and the
number of computers to be installed in each block is given below. The Head Quarter of the
Institute is in Delhi. You as a Network expert have to answer the queries raised by their board of
directors as given (i) to (v).
JAIPUR CAMPUS

MBA ADMIN

MBBS BTECH

Distance between blocks in meter:

8
Page 8 of 12 | KVS –Lucknow Region | Session 2023-24
MBBS to MBA - 60
MBBS to ADMIN - 190
MBBS to BTECH - 110
MBA to BTECH - 120
MBA to ADMIN - 50
No of computers to be installed in each Block:
ADMIN - 50
MBBS - 15
MBA - 25
BTECH - 40

(i) Suggest the most appropriate block to house the SERVER in Jaipur Campus to get the best
and effective connectivity. Justify your answer.
(ii) Suggest a device/software to be installed in Jaipur campus to take care of data security.
(iii) Suggest the best wired medium and draw the cable layout to economically connect all the
blocks with the campus.
(iv) Suggest the placement of the following devices with appropriate reasons:
(a) Switch / Hub (b) Repeater
(v) Suggest a protocol that shall be needed to provide video conferencing solution between
Jaipur campus and Delhi Head Quarter.
Please note that there is internal choice in Q34 & Q35.
Q34. (a) Write the output of the code given below: (2+3)
def Funstr(S):
T=""
for i in S:
if i.isdigit():
T=T+i
return T

A="Comp.Sc.- 083"
B=Funstr(A)
print(A,'\n',B, sep="#")
(b) The code given below inserts the following record in the table employee:
EmpNo – integer
EmpName – string
Salary – integer
City – string
Note the following to establish connectivity between Python and MYSQL:
 Username is root
 Password is tiger
 The table exists in a MYSQL database named COMPANY.
 The details (EmpNo, EmpName, Salary and City) are to be accepted from the user.

Write the following missing statements to complete the code:

9
Page 9 of 12 | KVS –Lucknow Region | Session 2023-24
Statement 1 – to form the cursor object
Statement 2 – to execute the command that inserts the record in the table Employee.
Statement 3 - to add the record permanently in the database

import mysql.connector as mysql


def sql_data():
con1=mysql.connect(host="localhost",user="root", passwd="tiger", database=
"company")
mycursor=_________________ #Statement 1
EmpNo=int(input("Enter Employee Number : "))
EmpName=input("Enter Employee Name : ")
Salary=int(input("Enter Employee Salary: "))
City=input("Enter Employee City Name: "))
query="insert into Employee values({},'{}',{},’{}’)".format(EmpNo,EmpName, Salary,City)
______________________ #Statement 2
______________________ # Statement 3
print("Data Added successfully")
OR
(a) Predict the output of the code given below:
def ListChange(L):
for i in range(len(L)):
if L[i]%2==0:
L[i]=L[i]*2
if L[i]%3==0:
L[i]=L[i]*3
if L[i]%5==0:
L[i]=L[i]*5
L=[3,4,5,9]
ListChange(L)
for i in L:
print(i, end="$")
(b) The code given below reads the following record from the table named Product and
displays only those records whosepriceis greater than 500:
PNo – integer
PName – string
Price – integer
Note the following to establish connectivity between Python and MYSQL:
 Username is root

10
Page 10 of 12 | KVS –Lucknow Region | Session 2023-24
 Password is tiger
 The table exists in a MYSQL database named school.
Write the following missing statements to complete the code:
Statement 1 – to form the cursor object
Statement 2 – to execute the query that extracts records of those products whose Priceare
greater than 500.
Statement 3- to read the complete result of the query (records whose price are greater than
500) into the object named data, from the table Product in the database.
import mysql.connector as mysql
def sql_data():
con1=mysql.connect(host="localhost",user="root",passwd="tiger", database="ABCD")
mycursor=_______________ #Statement 1
print("Product detail whose price greater than 500 are : ")
_________________________ #Statement 2
data=__________________ #Statement 3
for i in data:
print(i)
print()
Q35. How CSV files are different from normal text files? (5)
Write a program in Python that defines and calls the following user defined functions:

(i) INSERT() – To accept and add data of a Student to a CSV file ‘Sdetails.csv’. Each record
consists of a list with field elements as RollNo, Name, Class and Marks to store roll number of
students, name of student, class and marks obtained by the student.
(ii) COUNTROW() – To count the number of records present in the CSV file named
‘Sdetails.csv’.
OR

Write syntax to create a reader object and write object to read and write the content of a CSV

file. Write a Program in Python that defines and calls the following user defined functions:

(i) ADD() – To accept and add data of an employee to a CSV file ‘empdata.csv’. Each record

consists of a list with field elements as Eid, Ename, Salary and City to store employee id ,

employee name, employee salary and city.

(ii) SEARCH()- To display the records of the employees whose salary is more than 50000.

***** End of Paper*****

11
Page 11 of 12 | KVS –Lucknow Region | Session 2023-24
12
Page 12 of 12 | KVS –Lucknow Region | Session 2023-24
SET-2
KENDRIYA VIDYALAYA SANGATHAN (LUCKNOW REGION)
XII- PRE-BOARD EXAMINATION 2023-24
Computer Science (083)
Time allowed: 3 hours Maximum marks: 70

Note – Please award full marks for any alternative correct code / set of instruction especially in Python
programming.
MARKING SCHEME

Section – A

Q01. Ans: True (1)

Q02. Ans: (c) _123 (1)

Q03. Ans: (b) (1, 2, [1, 3.5], 3) (1)

Q04. Ans: (b) False (1)

Q05. Ans: (d) [‘Economy’, ’Digital’] (1)

Q06. Ans: (d) None of these (1)

Q07. Ans: (c) ALTER (1)

Q08. Ans: (c) DROP (1)

Q09. Ans: (a) Statement1 (1)

Q10. Ans: (c) Cardinality (1)

Q11. Ans: (a) When you open a file for reading, if the file does not exist, an error occurs. (1)

Q12. Ans: (d) LIKE (1)

Q13. Ans: (c) URL (1)

Q14. Ans: (a) True (1)

Q15. Ans: (d) SELECT MAX(SALARY) AND MEAN(SALARY) FROM EMPLOYEE; (1)

Q16. Ans: (b) mycon.connect(host=”localhost”,user=”root”,passwd=”MyPass”,database=”test”) (1)

Q17. Ans: (b) Both A and R are true and R is not the correct explanation for A (1)

Q18. Ans: (c) A is True but R is False (1)

1
Page 1 of 11| KVS – Lucknow Region | Session 2023-24
Section – B

Q19. Ans: (2)

def factorial(N ):

fact=1

while N>0:

fact*=N

N=N-1

print("Factorial=",fact)

#main()

factorial(5)

Q20. Differentiate between Star Topology and Bus Topology. Write two points of difference. (2)

Ans:

S.No. Star topology Bus Topology

1 In Star topology all the devices are In Bus topology each device in the
connected to a central hub/node. network is connected to a single cable
which is known as the backbone

2 In Star topology if the central hub fails In Bus topology the failure of the network
then the whole network fails. cable will cause the whole network to fail.

OR

Write two point of difference between Bridge and Gateway.

Ans:

S.No. Bridge Gateway


1 Bridge connect two different Gateway is used to connect two different
Networks working on the same Networks working on the different
protocol protocols
2 In bridge, format of packet is not In Gateway format of packet is changed.
changed

2
Page 2 of 11| KVS – Lucknow Region | Session 2023-24
Q21. Ans: Output will be as follows (1)

(a) oetcnlg hl rwn p (1)


(b) {'name': 'aditya', 'age': 16}
{'name': 'aditya', 'age': 16, 'address': 'Mumbai'}

Q22. Degree: The number of attributes or columns in a relation is called the Degree of the relation. (2)

Attribute: An attribute is a specification that defines a property of an object (column / fields of a


relation) Example: Any valid example to show degree and attribute.

Q23. (a) (i) File Transfer Protocol (ii) Post Office Protocol (1)

(b) A Media Access Control address (MAC address) is a hardware identifier that uniquely
identifies each device on a network. Primarily, the manufacturer assigns it. They are often found
(1)
on a device's network interface controller (NIC) card.

Q24. Ans: [2, 26, 23, 18] (1/2 mark for each correct digit) OR (2)

Ans: (4, 6, 8, 7, 5, 3)(1/2 marks for each two consecutive digits & ½ marks for parenthesis)

Q25. (1 MARKS FOR DIFFERENCE AND 1 MARKS FOR EXAMPLE) (2)

S.No. WHERE HAVING

1 It is used to fetch the records from the It is used to fetch the record from the
table based on the specified condition. groups based on the specified condition.

2 It is used before group by or order by It is used along with group by clause

3 Any valid appropriate example Any valid appropriate example

OR

The GROUP BY clause is used to get the summary data based on one or more group of records.
The groups can be formed on one or more columns. For example, the GROUP BY query will be
used to count the number of employees in each department or to get the department wise total
salaries etc. It uses HAVING clause to retrieve records based on specified condition for the given
column(s) of the group by clause.

Example: any valid example

Section – C

3
Page 3 of 11| KVS – Lucknow Region | Session 2023-24
Q26. (1)

BNO NAME CITY ITEMCODE INAME PRICE

1001 Ashok Delhi 11 HDD 2500

1001 Ashok Delhi 12 Keyboard 850

1001 Ashok Delhi 13 RAM 1100

1002 Manish Jaipur 11 HDD 2500

1002 Manish Jaipur 12 Keyboard 850

1002 Manish Jaipur 13 RAM 1100

1003 Rahul Lucknow 11 HDD 2500

1003 Rahul Lucknow 12 Keyboard 850

1003 Rahul Lucknow 13 RAM 1100

(a) 1 mark for correct result.

(b) (2)

(1/2 mark for each correct output)

(i) Manager

Director

Clerk

(ii) Delhi 90000

Mumbai 175000

Kolkata 85000

(iii) Peter 45000

Jack 85000

Harry 90000

(iv) Harry 90000 Delhi

Q27. (a)

def COUNT_W5():

4
Page 4 of 11| KVS – Lucknow Region | Session 2023-24
obj = open("story1.txt","r")

text = obj.read()

L = text.split()

count = 0

print("Six characters words are: - ", end = "")

for i in L:

if len(i) == 6:

print(i , end=" ")

count += 1

print("\nThe total no of words with length of 6 characters is: ",count)

COUNT_W5()

Q27. OR (b) (3)

def VC_COUNT():

obj=open("THEORY.TXT","r")

text=obj.read()

VCOUNT=0

CCOUNT=0

for i in text:

if( i.isalpha()):

if i in ('a','e','i','o','u') or i in ('A','E','I','O','U'):

VCOUNT+=1

else:

CCOUNT+=1

print("Total vowels are: ",VCOUNT)

print("Total consonants are: ",CCOUNT)

VC_COUNT()

5
Page 5 of 11| KVS – Lucknow Region | Session 2023-24
Q28. (a) (1/2 marks for each correct output) (3)

(i) CODING 2

NETWORKING 1

ANALYSIS 1

TESTING 1

(ii) ‘2017-04-10’ ‘2003-05-12’

(iii) RAVI CODING 45000

SUMAN NETWORKING 50000

MONU CODING 57800

RUPALI ANALYSIS 39600

ROHIT TESTING 33700

(iv) SUMAN 2500

REPALI 3000

½ mark for each output

(b) mysql> DESC EMPLOYEE; (1 mark for correct command)

Q29. def INTERCHANGE(L): (3)

ChangedList=L

i=0

if len(ChangedList)%2==0:

while i<=(len(ChangedList)-1):

ChangedList[i],ChangedList[i+1]=ChangedList[i+1],ChangedList[i]

i=i+2

else:

while i<=(len(ChangedList)-2):

ChangedList[i],ChangedList[i+1]=ChangedList[i+1],ChangedList[i]

i=i+2

6
Page 6 of 11| KVS – Lucknow Region | Session 2023-24
return ChangedList

List=[5,6,7,8,9]

print(List)

NewList = INTERCHANGE(List)

print(NewList)

Q30. def Push_record(): # (1½ mark for correct push element) (3)

for i in List:

if i[2]=="Delhi":

Record.append(i)

print(Record)

def Pop_record(): # (1½ mark for correct push element)

while True:

if len(Record)==0:

print('Empty Stack')

break

else:

print(Record.pop())

OR

data = [1,2,3,4,5,6,7,8]
stack = []
def push(stack, data):
for x in data:
if x % 2 == 0:
stack.append(x)
def pop(stack):
if len(stack)==0:
return "stack empty"
else:
return stack.pop()
push(stack, data)
print(pop(stack))
½ mark should be deducted for all incorrect syntax. Full marks to be awarded for any other logic
that produces the correct result.

7
Page 7 of 11| KVS – Lucknow Region | Session 2023-24
Section – D

Q31. (i)MCODE unique values (1 mark) (4)

(ii) Degree = 4 (after removing one column) (1/2 mark)

Cardinality = 7 (after 2 more record added) (1/2 mark)

(iii) (a) mysql>alter table MOBILES add GST int; (1 mark)

(b) mysql>update MOBILES set GST=(PRICE*0.18) (1 mark)

OR

(iii) (a) mysql>insert into MOBILES values(‘M06’,’iPHONE13’,’APPLE’,110000,’2022-03-01’);

(1 mark)

(b) mysql>delete from MOBILES where MODEL=’NARZO50’; (1 mark)

Q32 (i) pickle (1 mark for correct module) (4)

(ii) Statement2: f=open("student.dat","rb") (1 mark)

(iii) Statement3: rec=pickle.load(f) (1 mark)

Statement4: if(rec[0]==7): (1 mark)

Section - E

Q33. (i) Admin block, Justification – maximum number of computers (5)

(ii) Firewall

(iii)

MBA ADMIN

MBBS BTECH

(iv) (a) Switch/Hub in each block to connect all the computers of that block.

8
Page 8 of 11| KVS – Lucknow Region | Session 2023-24
(b) Repeater between MBBS and BTECH block due to 190 meter of distance apart from each
other..

(v) VoIP protocol

Q34. (a) Ans: Comp.Sc.- 083#083 (1 mark for comp.sc. and 1 marks for rest) (5)

(b) Statement1: mycursor=con1.cursor()

Statement2: mycursor.execute(query)

Statement3: con1.commit()

(1 mark for each correct statement)

OR

(a) Ans: 9$8$25$27$ (1 mark for first 5 characters and 1 mark for next 5 characters)

(b) Statement1: mycursor=con1.cursor()

Statement2: mycursor.execute("select * from Product where Price>500")

Statement3: data=mycursor.fetchall()
(1 mark for each correct statement)

Q35. CSV and TXT files store information in plain text. The first row in the file defines the names (5)
for all subsequent fields. In CSV files, fields are always separated by commas. In TXT files, fields
can be separated with a comma, semicolon, or tab. (1 marks)

import csv #( ½ mark for import csv)

def INSERT(): #(1 ½ for correct definition of function)


fh=open("Sdetails.csv",'w')
swriter=csv.writer(fh)
ans='y'
swriter.writerow(['RollNo','Name','Class','Marks'])
ans='y'
while ans=='y' or ans=='Y':
rn=int(input("Enter Roll No"))
nm=input("Enter Name")
cl=int(input("Enter class"))
mk=int(input("Enter marks"))

9
Page 9 of 11| KVS – Lucknow Region | Session 2023-24
srec=[rn,nm,cl,mk]
swriter.writerow(srec)
ans=input("if you want to enter more record press Y/N")
fh.close()

def COUNTROW(): #(1 ½ for correct definition of function)


with open("Sdetails.csv",'r', newline='\r\n') as fh:
sreader=csv.reader(fh)
count=0
for r in sreader:
count+=1
print("total record = ",count)
fh.close()
#main program
INSERT()
COUNTROW() ( ½ mark for both function call statements)
OR

Syntax to create reader object:

Object=csv.reader(“filehandle”) ( ½ mark)

Object=csv.writer(“filehandle”)( ½ mark)

import csv #( ½ mark for import csv)


def ADD( ): # (1½ mark for correct definition)
f=open("empdata.csv",'w')
swriter=csv.writer(f)
ans='y'
swriter.writerow(['Eid','EName','Salary','City'])
ans='y'
while ans=='y' or ans=='Y':
eid=int(input("Enter employee id"))
enm=input("Enter Employee Name")
es=int(input("Enter Salary"))

10
Page 10 of 11| KVS – Lucknow Region | Session 2023-24
ec=input("Enter City")
erec=[eid,enm,es,ec]
swriter.writerow(erec)
ans=input("if you want to enter more record press Y/N")
f.close()

def SEARCH(): #(1 ½ mark for correct definition)

with open("empdata.csv",'r', newline='\r\n') as fh:


ereader=csv.reader(fh)
for r in ereader:
if int(r[2])>50000:
print(r[0],r[1],r[2],r[3])
break
else:
print("Employee Data not found")

#main (1/2 marks of functions calling)


ADD()
SEARCH()
*****End Of Paper*****

11
Page 11 of 11| KVS – Lucknow Region | Session 2023-24
PB23CS01

KENDRIYA VIDYALAYA SANGATHAN ERNAKULAM REGION


PRE-BOARD EXAMINATION 2023-24
COMPUTER SCIENCE (083)
Time allowed: 3 Hours Maximum Marks: 70
General Instructions:
 Please check this question paper contains 35 questions.
 The paper is divided into 5 Sections- A, B, C, D and E.
 Section A, consists of 18 questions (1 to 18). Each question carries 1 Mark.
 Section B, consists of 7 questions (19 to 25). Each question carries 2 Marks.
 Section C, consists of 5 questions (26 to 30). Each question carries 3 Marks.
 Section D, consists of 2 questions (31 to 32). Each question carries 4 Marks.
 Section E, consists of 3 questions (33 to 35). Each question carries 5 Marks.
 All programming questions are to be answered using Python Language only.

Q.NO QUESTION MARKS

SECTION - A
1 Which of the following is a keyword in Python?
a) true b) For c) pre-board d) False 1

2 What will be the output for the following Python statement?


print(20//3*2+(35//7.0))
1
a) 17.0 b) 17 c) 8.5 d) 8

3 In MYSQL database, if a table, BOOK has degree 8 and cardinality 7, and


another table, SALE has degree 4 and cardinality 7, what will be the degree and
1
cardinality of the Cartesian product of BOOK and SALE ?
a) 32 , 49 b) 12, 49 c) 12 ,14 d) 32,14
4 What is “ C “ stands in TCP/IP ?
1
a) Common b) Centre c)Control d) Coordinate
5 What is printed by the following statements?
ANIMAL={"dog":10,"tiger":5,"elephant":15,"Cow":3}
1
print("Tiger" not in ANIMAL)
a) True b)False c)Error d) None
6 Consider the following statements and choose the correct output from the given
options :
EXAM="COMPUTER SCIENCE" 1
print(EXAM[:12:-2])
a) EN b) CI c)SCIENCE d) ENCE
7 What will be the output of the following code ?
1
Tuple1=(10,)

1
Tuple2=Tuple1*2
print(Tuple2)
a) 20 b) (20,) c) (10,10) d) Error
8 Fill in the blanks:
The SQL keyword ---------------- is used in SQL expression to select records 1
based on patterns
9 What possible outcome will be produced when the following code is executed?
import random
value=random.randint(0,3)
fruit=["APPLE","ORANGE","MANGO","GRAPE"]
for i in range(value):
print(fruit[i],end='##')
print()

a) APPLE##
1
b) APPLE#
ORANGE##

c) APPLE## ORANGE##

d) ORANGE##
MANGO##
APPLE##
10 Select the network device from the following, which connects, networks with
different protocols 1
a) Bridge b)Gateway c)Hub d) Router
11 State whether the following statement is TRUE or FALSE :
1
The value of the expression 4/3*(2-1) and 4/(3*(2-1)) is the same
12 In the relational models , cardinality actually refers to --------------
a) Number of tuples b) Number of attributes 1
c) Number of tables d) Number of constraints
13 Data structure STACK is also known as ----------- list
a)First In First Out b) First In Last Out 1
c)Last In First Out d) Last In Last Out
14 Which function is used to write a list of strings in a file?
1
a) writeline( ) b) writelines( ) c) write() d) writeall( )
15 Which of the following is NOT a guided communication medium?
a) Twisted pair cable b) Microwave 1
c) Coaxial cable d) Optical fibre
16 Which of the following function header is correct?
a) def fun(a=1,b):
b) def fun(a=1,b,c=2): 1
c) def fun(a=1,b=1,c=2):
d) def fun(a=1,b=1,c=2,d):
Q17 and 18 are ASSERTION AND REASONING based questions. Mark the
correct choice as
(a) Both A and R are true and R is the correct explanation for A
(b) Both A and R are true and R is not the correct explanation for A .
(c) A is True but R is False

2
(d) A is false but R is True
17 Assertion ( A): In SQL, the aggregate function avg() calculates the average
value on a set of values and produces a single result.
Reason ( R): The aggregate functions are used to perform some fundamental 1
arithmetic tasks such as min(), max(), sum() etc

18 Assertion(A): Python overwrites an existing file or creates a non-


existing file when we open a file with ‘w’ mode.
1
Reason(R): a+ mode is used only for writing operations

SECTION - B
19 i) Expand the following :
a) SMTP b) VoIP
ii) Give one disadvantage of Star topology
1+1=2
OR
i) What is a web browser ?
ii) Define the term MAC Address
20 Rewrite the following code in Python after removing all syntax error(s) and
underline each correction done in the code .
30 = num
for k in range(0,num)
2
IF k%4==0 :
print(k*4)
Else:
print(k+3)
21 Write a function letter_count(lst) that takes a list of string and returns a
dictionary where the keys are the letters from lst and the values are the number
of times that letter appears in the lst.
For example: if the passed list, lst is :
lst=list(“apple”)
2
Then it should return a dictionary as {‘a’:1,’p’:2,’l’:1,’e’:1}
OR
Write a function max_length( ) ,that takes a list of string as argument and
display the longest string from the list.

22 Predict the output of the following code:

lst=[2,4,6,8,10]
for i in range(1,5):
2
lst[i-1]=lst[i]
for i in range(0,5):
print(lst[i],end=' ')

23 Consider the following list of elements and write Python statement to print the
output of each question.
elements=['apple',200,300,'red','blue','grapes'] 2
i) print(elements[3:5])
ii) print(elements[::-1])

3
OR
Consider the following list exam and write Python statement for the following
questions:
exam=[‘english’,’physics’,’chemistry’,’cs’,’biology’]
i) To insert subject “maths” as last element
ii) To display the list in reverse alphabetical order
24 Satheesh has created a database “school” and table “student”. Now he wants to
view all the databases present in his laptop. Help him to write SQL command
for that , also to view the structure of the table he created.

OR
2
Meera got confused with DDL and DML commands. Help her to select only
DML command from the given list of command.
UPDATE , DROP TABLE, SELECT , CREATE TABLE , INSERT INTO,
DELETE , USE
25 Predict the output for the following Python snippet

def calc(p,q=3):
ans=1
for x in range(q):
ans=ans*p 2
return ans
power=calc(3)
print(power,'9')
power=calc(3,2)
print(power,'27')
SECTION C
26 Predict the output of the Python code given below:
def calculate(str):
text=''
x=range(len(str)-1)
for i in x:
if str[i].isupper():
text+=str[i]
elif str[i].islower(): 3
text+=str[i+1]
else:
text+='@'
return text
start='Pre-board Exam'
final=calculate(start)
print(final)

4
27 Consider the following table DOCTOR given below and write the output of the
SQL Queries that follows :

D_ID D_NAME D_DEPT GENDER EXPERIENCE


101 JOSEPH ENT MALE 10
104 GUPTA MEDICINE MALE 12
106 SUMAN ORTHO FEMALE 7
111 HANEEF ENT MALE 12 3
123 DEEPTI CARDIOLOGY FEMALE 6
132 VEENA SKIN FEMALE 12
i) SELECT D_NAME FROM DOCTOR WHERE GENDER=MALE
AND EXPERIENCE=12 ;
ii) SELECT DISTINCT(D_DEPT) FROM DOCTOR ;
iii) SELECT D_NAME , EXPERIENCE FROM DOCTOR ORDER BY
EXPERIENCE ;

28 Write a function in Python to count the number of lines in a text fie ‘EXAM.txt’
which start with an alphabet ‘T’ .
OR 3
Write a function in Python that count the number of “can” words present in a
text file “DETAILS.txt” .
29 Consider the following Table “TEACHER”

T_ID NAME AGE SEX DEPT D_O_JOIN SALARY


902 SANDEEP 45 M COMPUTER 10/10/2002 56000
813 SANGEETA 34 F HISTORY 24/9/2010 50000
771 JOEL 48 M ENGLISH 4/5/2001 67900
703 MANVITH 36 M MATHS 27/09/2012 48000
606 NEENA 32 F ENGLISH 23/5/2013 40000
537 ABHILASH 42 M MATHS 6/2/2006 47000
420 MUHSIN 49 M ENGLISH 8/3/2003 70450 3
412 SUBESH 52 M HINDI 10/11/1999 60500
345 RENJINI 36 F COMPUTER 27/4/2010 45000
218 DEEPTI 28 F HINDI 2/2/2016 40000
160 SHUBHAM 39 M SCIENCE 19/9/2011 45000

Based on the above table, Write SQL command for the following :
i) To show all information about the teacher of maths department
ii) To list name and department whose name starts with letter ‘M’
iii) To display all details of female teacher whose salary in between
35000 and 50000

5
30 Thushar received a message(string) that has upper case and lower-case alphabet.
He want to extract all the upper case letters separately .Help him to do his task
by performing the following user defined function in Python:
a) Push the upper case alphabets in the string into a STACK
3
b) Pop and display the content of the stack.
For example:
If the message is “All the Best for your Pre-board Examination”
The output should be : E P B A
SECTION D
31 Consider the table PRODUCT and CLIENT given below:
PRODUCT
PR_ID PR_NAME MANUFACTURER PRICE QTY
BS101 BATH SOAP PEARSE 45.00 25
SP210 SHAMPOO SUN SILK 320.00 10
SP235 SHAMPOO DOVE 455.00 15
BS120 BATH SOAP SANTOOR 36.00 10
TOOTH
TB310 COLGATE 48.00 15
BRUSH
FW422 FACE WASH DETOL 66.00 10
BS145 BATH SOAP DOVE 38.00 20
4

CLIENT
C_ID C_NAME CITY PR_ID
01 DREAM MART COCHIN BS101
02 SHOPRIX DELHI TB310
03 BIG BAZAR DELHI SP235
04 LIVE LIFE CHENNAI FW422
Write SQL Queries for the following:
i) Display the details of those clients whose city is DELHI
ii) Increase the Price of all Bath soap by 10
iii) Display the details of Products having the highest price
iv) Display the product name, price, client name and city with their
corresponding matching product Id.
32 Gupta is writing a program to create a csv file “employee.csv” which will
contain user name and password for department entries. He has written the
following code . As a programmer, help him to successfully execute the given
task.
import ---------------- #statement 1
def add_emp(username,password):
4
f=open(‘employee.csv’, ’----------‘) # statement 2
content=csv.writer(f)
content.writerow([username,password])
f.close()
def read_emp( ):
with open (‘employee.csv’,’r’) as file:

6
content_reader=csv.-------------------(file) # statement 3
for row in content_reader:
print(row[0],row[1])
file.close( )
add_emp(‘mohan’,’emp123#’)
add_emp(‘ravi’,’emp456#’)
read_emp() #statement 4
i) Name the module he should import in statement 1
ii) In which mode , Gupta should open the file to add record in to the
file ? (statement 2)
iii) Fill in the blank in statement 3 to read the record from a csv file
iv) What output will he obtain while executing statement 4 ?
SECTION E
33 Oxford college, in Delhi is starting up the network between its different wings.
There are four Buildings named as SENIOR, JUNIOR, ADMIN and HOSTEL
as shown below:

JUNIOR SENIOR ADMIN HOSTEL


The distance between various building is as follows:
ADMIN TO SENIOR 200 m
ADMIN TO JUNIOR 150 m
ADMIN TO HOSTEL 50 m
SENIOR TO JUNIOR 250 m
SENIOR TO HOSTEL 350 m
JUNIOR TO HOSTEL 350 m
Number of computer in each building is :
5
SENIOR 130
JUNIOR 80
ADMIN 160
HOSTEL 50

i) Suggest the cable layout of connections between the buildings.


ii) Suggest the most suitable place (i.e., building) to house the server of
this college, provide a suitable reason.
iii) Is there a requirement of a repeater in the given cable layout? Why/
Why not?
iv) Suggest the placement of hub/switch with justification.
v) The organisation also has inquiry office in another city about 50-60
km away in hilly region. Suggest the suitable transmission media to
interconnect to college and inquiry office out of the following:
a. Fiber optic cable
b. Microwave
c. Radiowave

7
34 i) What is Pickling or Serialization?
ii) A binary file “salary.DAT” has structure [employee id, employee
name, salary]. Write a function countrec() in Python that would read
contents of the file “salary.DAT” and display the details of those
employee whose salary is above 20000.

OR 2+3=5
i) What is the difference between ‘r’ and ‘rb’ mode in Python file ?
ii) A binary file “STUDENT.DAT” has structure [admission_number,
Name, Percentage]. Write a function countrec() in Python that would
read contents of the file “STUDENT.DAT” and display the details of
those students whose percentage is above 90. Also display number
of students scoring above 90%
35 i) What do you mean by a Primary key in RDBMS ?
ii) Complete the following database connectivity program by writing
the missing statements and performing the given query
import ------------------- as mysql # statement 1
con=mysql. ---------(host=’localhost’,user=’root’,passwd=’123’ ,
database=’student’) # statement 2
cursor=con.cursor( )
cursor.execute(--------------------------------) # statement 3
data=cursor. ----------------------------------- # statement 4
for rec in data:
print(rec)
con.close( )
a) Complete the statement 1 by writing the name of package need to be
imported for database connectivity .
b) Complete the statement 2 by writing the name of method require to
create connection between Python and mysql.
c) Complete the statement 3 by writing the query to display those
students record whose mark is between 50 and 90 from table 1+4=5
“student”
d) Complete the statement 4 to retrieve all records from the result set.
OR
i) What is the difference between UNIQUE and PRIMARY KEY
constraints ?
ii) Maya has created a table named BOOK in MYSQL database,
LIBRARY
BNO(Book number )- integer
B_name(Name of the book) - string
Price (Price of one book) –integer

Note the following to establish connectivity between Python and


MySQL: Username – root, Password – writer,Host – localhost.

Maya, now wants to display the records of books whose price is


more than 250. Help Maya to write the program in Python

************************************

8
PB23CS01

KENDRIYA VIDYALAYA SANGATHAN


ERNAKULAM REGION
1st PRE BOARD EXAMINATION 2023 – 24

COMPUTER SCIENCE (083)


Class: XII
Time allowed: 3 Hours Maximum Marks: 70

MARKING SCHEME
Q.NO QUESTION MARKS

SECTION - A
1 Which of the following is a keyword in Python ?
a) true b) For c) pre-board d) False 1

2 What will be the output for the following Python statement ?

print(20//3*2+(35//7.0))
1
a) 17.0 b) 17 c) 8.5 d) 8

3 In MYSQL database, if a table, BOOK has degree 8 and cardinality 7, and


another table, SALE has degree 4 and cardinality 7, what will be the degree and
1
cardinality of the Cartesian product of BOOK and SALE ?
b) 32 , 49 b) 12, 49 c) 12 ,14 d) 32,14
4 What is “ C “ stands in TCP/IP ?
1
a) Common b) Centre c)Control d) Coordinate
5 What is printed by the following statements ?
ANIMAL={"dog":10,"tiger":5,"elephant":15,"Cow":3}
1
print("Tiger" not in ANIMAL)
a) True b)False c)Error d) None
6 Consider the following statements and choose the correct output from the given
options :
EXAM="COMPUTER SCIENCE" 1
print(EXAM[:12:-2])
a) EN b) CI c)SCIENCE d) ENCE
7 What will be the output of the following code ?
Tuple1=(10,)
1
Tuple2=Tuple1*2
print(Tuple2)

1
a) 20 b) (20,) c) (10,10) d) Error
8 Fill in the blanks :
The SQL keyword ---------------- is used in SQL expression to select records
1
based on patterns
LIKE
9 What possible outcome will be produced when the following code is executed ?
import random
value=random.randint(0,3)
fruit=["APPLE","ORANGE","MANGO","GRAPE"]
for i in range(value):
print(fruit[i],end='##')
print()

a) APPLE## 1
b) APPLE#
ORANGE##

c) APPLE## ORANGE##

d) ORANGE##
MANGO##
APPLE##
10 Select the network device from the following ,which connects , networks with
different protocols 1
a) Bridge b)Gateway c)Hub d) Router
11 State whether the following statement is TRUE or FALSE :
The value of the expression 4/3*(2-1) and 4/(3*(2-1)) is the same 1
TRUE
12 In the relational models , cardinality actually refers to --------------
a) Number of tuples b) Number of attributes 1
c) Number of tables d) Number of constraints
13 Data structure STACK is also known as ----------- list
a)First In First Out b) First In Last Out 1
c)Last In First Out d) Last In Last Out
14 Which function is used to write a list of strings in a file ?
1
a) Writeline( ) b) writelines( ) c) write() d) writeall( )
15 Which of the following is NOT a guided communication medium ?
a) Twisted pair cable b) Microwave 1
c)Coaxial cable d) Optical fibre
16 Which of the following function headers is correct ?
a) def fun(a=1,b):
b) def fun(a=1,b,c=2): 1
c) def fun(a=1,b=1,c=2):
d) def fun(a=1,b=1,c=2,d):
Q17 and 18 are ASSERTION AND REASONING based questions. Mark the
correct choice as
(a) Both A and R are true and R is the correct explanation for A

2
(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
17 Assertion ( A): In SQL, the aggregate function avg() calculates the average
value on a set of values and produces a single result.
Reason ( R): The aggregate functions are used to perform some fundamental
1
arithmetic tasks such as min(), max(), sum() etc

(b) Both A and R are true and R is not the correct explanation for A .
18 Assertion(A): Python overwrites an existing file or creates a non-
existing file when we open a file with ‘w’ mode.
Reason(R): a+ mode is used only for writing operations
1
(c) A is True but R is False

SECTION - B
19 i) Expand the following :
a) SMTP : Simple Mail Transfer Protocol
b) VoIP : Voice Over Internet Protocol
ii) Give one disadvantage of Star topology
Star topology has a single point of failure. If the central hub or switch fails,
the entire network will be down. This can be a major problem for networks
that require high availability. Or any other dis advantage.
OR
i) What is a web browser ?

A software application used to access information on the World Wide Web is 1+1=2
called a Web Browser. When a user requests some information, the web browser
fetches the data from a web server and then displays the webpage on the user's
screen.
ii) Define the term MAC Address

A MAC address (media access control address) is a 12-digit hexadecimal


number assigned to each device connected to the network. Primarily specified as
a unique identifier during device manufacturing, the MAC address is often
found on a device's network interface card (NIC).

20 Rewrite the following code in Python after removing all syntax error(s) and
underline each correction done in the code .
num=30
for k in range(0,num): ½ mark
if k%4==0 : each
print(k*4)
else:
print(k+3)
21 Write a function letter_count( lst) that takes a list of string and returns a
dictionary where the keys are the letters from lst and the values are the number
2
of times that letter appears in the lst.
For example: if the passed list is :

3
Lst=list(“apple”)
Then it should return a dictionary as {‘a’:1,’p’:2,’l’:1,’e’:1}
OR
Write a function max_length( ) ,that takes a list of string as argument and
display the longest string from the list.
Correct Program : 2 Marks

22 Predict the output of the following code:

lst=[2,4,6,8,10]

for i in range(1,5):

lst[i-1]=lst[i] 2
for i in range(0,5):

print(lst[i],end=' ')
output:
4 6 8 10 10

23 Consider the following list of elements and write Python statement to print the
output of each questions.
elements=['apple',200,300,'red','blue','grapes']
i) print(elements[3:5])

['red', 'blue']

ii) print(elements[::-1])

['grapes', 'blue', 'red', 300, 200, 'apple'] 2

OR
Consider the following list exam and write Python statement for the following
questions:
i) To insert subject “maths” as last element
exam.append(‘maths’)
ii) To display the list in reverse alphabetical order
exam.sort(reverse=True)

24 Satheesh has created a database “school” and table “student”. Now he wants to
view all the databases present in his laptop. Help him to write SQL command
for that , also to view the structure of the table he created.

SHOW DATABASES
2
DESCRIBE/DESC student
OR

Meera got confused with DDL and DML commands. Help her to select only
DML command from the given list of command.

4
UPDATE , DROP TABLE, SELECT , CREATE TABLE , INSERT INTO,
DELETE , USE

DML: UPDATE,SELECT,INSERT INTO,DELETE


25 Predict the out put for the following Python snippet

def calc(p,q=3):
ans=1
for x in range(q):
ans=ans*p
return ans
power=calc(3) 2
print(power,'9')
power=calc(3,2)
print(power,'27')

OUTPUT:
27 9
9 27

SECTION C
26 Predict the output of the Python code given below:
def calculate(str):
text=''
x=range(len(str)-1)
for i in x:
if str[i].isupper():
text+=str[i]
elif str[i].islower():
text+=str[i+1]
3
else:
text+='@'
return text
start='Pre-board Exam'
final=calculate(start)
print(final)

OUTPUT:
Pe-@oard @Eam

5
27 Consider the following table DOCTOR given below and write the out put of the
SQL Queries that follows :

D_ID D_NAME D_DEPT GENDER EXPERIENCE


101 JOSEPH ENT MALE 10
104 GUPTA MEDICINE MALE 12
106 SUMAN ORTHO FEMALE 7
111 HANEEF ENT MALE 12
123 DEEPTI CARDIOLOGY FEMALE 6
132 VEENA SKIN FEMALE 12
i) SELECT D_NAME FROM DOCTOR WHERE GENDER=MALE
AND EXPERIENCE=12 ;
GUPTA
HANEEF 3
ii) SELECT DISTINCT(D_DEPT) FROM DOCTOR ;
DISTINCT(D_DEPT)
ENT
MEDICINE
ORTHO
CARDIOLOGY
SKIN
iii) SELECT D_NAME , EXPERIENCE FROM DOCTOR ORDER BY
EXPERIENCE;
D_NAME EXPERIENCE
DEEPTI 6
SUMAN 7
JOSEPH 10
GUPTA 12
HANEEF 12
VEENA 12

28 Write a function in Python to count the number of lines in a text fie ‘EXAM.txt’
which start with an alphabet ‘T’ .

Correct function prototype ½ mark


Correct opening text file statement ½ mark
Correct logic 1 and ½ marks
Closing the file ½ mark 3

OR
Write a function in Python that count the number of “can” words present in a
text file “DETAILS.txt” .
def count_word():
count=0

6
f=open("textfiles.txt","r")
contents=f.read()
word=contents.split()
for i in word:
if i==’can’:
count+=1
print("Number of words in the File is :",count )
f.close()
count_word()

Correct function prototype ½ mark


Correct opening text file statement ½ mark
Correct logic 1 and ½ marks
Closing the file ½ mark
29 Consider the following Table “TEACHER”

T_ID NAME AGE SEX DEPT D_O_JOIN SALARY


902 SANDEEP 45 M COMPUTER 10/10/2002 56000
813 SANGEETA 34 F HISTORY 24/9/2010 50000
771 JOEL 48 M ENGLISH 4/5/2001 67900
703 MANVITH 36 M MATHS 27/09/2012 48000
606 NEENA 32 F ENGLISH 23/5/2013 40000
537 ABHILASH 42 M MATHS 6/2/2006 47000
420 MUHSIN 49 M ENGLISH 8/3/2003 70450
412 SUBESH 52 M HINDI 10/11/1999 60500
1MARK
345 RENJINI 36 F COMPUTER 27/4/2010 45000
EACH
218 DEEPTI 28 F HINDI 2/2/2016 40000
160 SHUBHAM 39 M SCIENCE 19/9/2011 45000

Based on the above table , Write SQL command for the following :
i) To show all information about the teacher of maths department
SELECT * FROM TEACHER WHERE DEPT=’MATHS’;
ii) To list name and department whose name starts with letter ‘M’
SELECT NAME,DEPT FROM TEACHER WHERE NAME LIKE ‘M%’;
iii) To display all details of female teacher whose salary in between
35000 and 50000
SELECT * FROM TEACHER WHERE SEX=’F’ AND SALARY BETWEEN
35000 AND 50000 ;

30 Thushar received a message(string) that has upper case and lower case 1 mark
alphabet.He want to extract all the upper case letters separately .Help him to do for push
his task by performing the following user defined function in Python: (), 1 mark

7
a) Push the upper case alphabets in the string into a STACK for pop()
b) Pop and display the content of the stack. and 1
For example: mark for
If the message is “All the Best for your Pre-board Examination” displaying
The output should be: E P B A

Ans:
def push(s,ch):
s.append(ch)
def pop(s):
if s!=[]:
return s.pop()
else:
return None
string=“All the Best for your Pre-board Examination”
st=[]
for ch in string:
if ch.isupper():
push(st,ch)
while True:
item=pop(st)
if item!=None:
print(item,end= ‘ ‘)
else:
break
SECTION D
31 Consider the table PRODUCT and CLIENT given below:

PR_ID PR_NAME MANUFACTURER PRICE QTY


BS101 BATH SOAP PEARSE 45.00 25
SP210 SHAMPOO SUN SILK 320.00 10
SP235 SHAMPOO DOVE 455.00 15
BS120 BATH SOAP SANTOOR 36.00 10
TOOTH
TB310 COLGATE 48.00 15
BRUSH 1 mark
FW422 FACE WASH DETOL 66.00 10 each
BS145 BATH SOAP DOVE 38.00 20

PRODUCT
C_ID C_NAME CITY PR_ID
01 DREAM MART COCHIN BS101
02 SHOPRIX DELHI TB310
03 BIG BAZAR DELHI SP235
04 LIVE LIFE CHENNAI FW422

8
Write SQL Queries for the following :
i) Display the details of those clients whose city is DELHI
SELECT * FROM CLIENT WHERE CITY=’DELHI’;
ii) Increase the Price of all Bath soap by 10
UPDATE PRODUCT SET PRICE=PRICE+10 WHERE PR_NAME=’BATH
SOAP’;
iii) Display the details of Products having the highest price
SELECT * FROM PRODUCT WHERE PRICE=(SELECT MAX(PRICE)
FROM PRODUCT) ;
iv) Display the product name , price, client name and city with their
corresponding matching product Id .
SELECT PR_NAME , PRICE ,C_ID, CITY FROM PRODUCT , CLIENT
WHERE PRODUCT.PR_ID=CLIENT.PR_ID ;

32 Gupta is writing a program to create a csv file “employee.csv” which will


contain user name and password for department entries. He has written the
following code. As a programmer, help him to successfully execute the given
task.

import ---------------- #statement 1


def add_emp(username,password):
f=open(‘employee.csv’, ’----------‘) # statement 2
content=csv.writer(f)
content.writerow([username,password])
f.close()

def read_emp( ):
with open (‘employee.csv’,’r’) as file:
content_reader=csv.-------------------(file) # statement 3
for row in content_reader:
print(row[0],row[1]) 4
file.close( )
add_emp(‘mohan’,’emp123#’)
add_emp(‘ravi’,’emp456#’)
read_emp() #statement 4

i) Name the module he should import in statement 1


import csv
ii) In which mode , Gupta should open the file to add record in to the
file ? (statement 2)
Mode a
iii) Fill in the blank in statement 3 to read the record from a csv file
reader
iv) What output will he obtain while executing statement 4 ?
mohan emp123#
ravi emp456#

9
SECTION E
33 Oxford college, in Delhi is starting up the network between its different wings.
There are four Buildings named as SENIOR, JUNIOR, ADMIN and HOSTEL
as shown below:

JUNIOR SENIOR ADMIN HOSTEL

The distance between various building is as follows:

ADMIN TO SENIOR 200 m


ADMIN TO JUNIOR 150 m
ADMIN TO HOSTEL 50 m
SENIOR TO JUNIOR 250 m
SENIOR TO HOSTEL 350 m
JUNIOR TO HOSTEL 350 m

Number of computer in each building is :

SENIOR 130
1 mark
JUNIOR 80 each
ADMIN 160
HOSTEL 50

i) Suggest the cable layout of connections between the buildings.

ADMIN

SENIOR
JUNIOR HOSTEL

ii) Suggest the most suitable place (i.e., building) to house the server of
this college , provide a suitable reason.

ADMIN, as number of computers are more in ADMIN building

10
iii) Is there a requirement of a repeater in the given cable layout? Why/
Why not?

Yes, between ADMIN TO JUNIOR and ADMIN TO SENIOR distance is more


than 100 m.

iv) Suggest the placement of hub/switch with justification.

In all building as it is required to connect all computers in to a network.

v) The organisation also has inquiry office in another city about 50-60
km away in hilly region. Suggest the suitable transmission media to
interconnect to college and inquiry office out of the following :
a. Fiber optic cable
b. Microwave
c. Radiowave

Radio wave
34 i) What is Pickling or Serialization?
The process of converting Python object hierarchy into byte stream so that it can
be written into a file.
ii) A binary file “salary.DAT” has structure [employee id, employee
name, salary]. Write a function countrec() in Python that would read
contents of the file “salary.DAT” and display the details of those
employee whose salary is above 20000.

def countrec():
num=0
fobj=open(“salary.dat”,’rb’)
try:
while True:
rec=pickle.load(fobj)
if rec[2]> 20000:
print(rec[0],rec[1],rec[2])
2+3=5
except:
fobj.close()
OR

i) What is the difference between ‘r’ and ‘rb’ mode in Python file ?
r is used to read text files and rb is used to read binary files
ii) A binary file “STUDENT.DAT” has structure [admission_number,
Name, Percentage]. Write a function countrec() in Python that would
read contents of the file “STUDENT.DAT” and display the details of
those students whose percentage is above 90. Also display number of
students scoring above 90%
import pickle
def countrec():
fobj=open(‘student.dat’,’rb’)
num=0
try:

11
while True:
rec=pickle.load(fobj)
if rec[2]>90:
num=num+1
print(re[0],rec[1],rec[2])
except:
fobj.close()
return num

35
i) What do you mean by a Primary key in RDBMS ?
In the relational model of databases, a primary key is a specific choice of a
minimal set of attributes that uniquely specify a tuple in a relation.
ii) Complete the following database connectivity program by writing
the missing statements and performing the given query
import ------------------- as mysql # statement 1
con=mysql. ---------(host=’localhost’,user=’root’,passwd=’123’ ,
database=’student’) # statement 2
cursor=con.cursor( )
cursor.execute(--------------------------------) # statement 3
data=cursor. ----------------------------------- # statement 4
for rec in data:
print(rec)
con.close( )
i) Complete the statement 1 by writing the name of package
need to be imported for database connectivity .
mysql.connector
ii) Complete the statement 2 by writing the name of method
require to create connection between Python and mysql. 1+4=5
connect()
iii) Complete the statement 3 by writing the query to display
those students record whose mark is between 50 and 90
from table “student”
select * from student where mark between 50 and 90
iv) Complete the statement 4 to retrieve all records from the
result set.

cursor.fetchall()

OR

i) What is the difference between UNIQUE and PRIMARY KEY


constraints ?
The difference between a UNIQUE constraint and a Primary Key is
that per table may only have one Primary Key but may define more
than one UNIQUE constraints

12
ii) Maya has created a table named BOOKt in MYSQL database,

LIBRARY

BNO(Book number )- integer

B_name(Name of the book) - string

Price (Price of one book) –integer

Note the following to establish connectivity between Python and

MySQL:

Username - root

Password - writer

Host – localhost

Maya, now wants to display the records of books whose price is


more than 250. Help Maya to write the program in Python

1 mark each for creating connection object,


Creating cursor,
Writing sql command

13
KENDRIYA VIDYALAYA SANGTHAN, CHANDIGARH REGION
PRE-BOARD EXAMINATION - 2023-24

Class: XII

Computer Science (083)


Time allowed: 3 Hours Maximum Marks: 70

General Instructions:
• Please check this question paper contains 35 questions.
• The paper is divided into 4 Sections- A, B, C, D and E.
• Section A, consists of 18 questions (1 to 18). Each question carries 1 Mark.
• Section B, consists of 7 questions (19 to 25). Each question carries 2 Marks.
• Section C, consists of 5 questions (26 to 30). Each question carries 3 Marks.
• Section D, consists of 3 questions (31 to 32). Each question carries 4 Marks.
• Section E, consists of 2 questions (33 to 35). Each question carries 5 Marks.
• All programming questions are to be answered using Python Language only.

Ques. Question Marks


No.
SECTION A
1 State True or False: 1
“Python is a case sensitive language i.e. upper and lower cases are treated differently.”

2 In a table in MYSQL database, an attribute Aof datatype char(20)has the value 1


“Rehaan”. The attribute B of datatype varchar(20) has value “Fatima”. How many
characters are occupied by attribute A and attribute B?
a. 20,6 b. 6,20
c. 9,6 d. 6,9

3 What will be the output of the following statement: 1


print(5-2**2**2+99//11)
a. -20 b. -2.0
c. -2 d. Error
4 Select the correct output of the code: 1
for i in "QUITE":
print(i.lower(), end="#")
a. q#u#i#t#e# b. ['quite#’] c. ['quite'] # d. [‘q’]#[‘u’]#[‘i’]#[‘t’]#[‘e’]#
5 In MYSQL database, if a table, Workshas degree 3 and cardinality 3, andanother table, 1
Jobs has degree 3 and cardinality 3, what will be the degree and cardinality of the
Cartesian product of Worksand Jobs?
a. 9,9 b. 6,6
c. 9,6 d. 6,9 [1]
6 A set of rules that governs data communication in computer networks is called … 1
a. Standard b. protocol c. Stack d. none of these

7 Given the followingdictionaries 1

dict_exam={"Exam":"AISSCE", "Year":2023} dict_result={"Total":500,


"Pass_Marks":165}

Which statement will merge the contents of both dictionaries?


a. dict_exam.update(dict_result)
b. dict_exam + dict_result
c. dict_exam.add(dict_result)
d. dict_exam.merge(dict_result)
8 Consider the statements given below and then choose the correct outputfrom the 1
given options:
pride="#Azadi Ka Amrut@75"
print(pride[-2:2:-2])
Options

a. 7TRAa d
b. 7tRAa d
c. 7TrAa d
d. 7trAa d
9 Which of the following statement(s) would give an error after executing the 1
Following code?
S="Welcome to class XII" # Statement 1
print(S) # Statement 2
S="Thank you" # Statement 3
S[0]= '@' # Statement 4
S=S+ "Thank you" # Statement 5

a. Statement 3 b. Statement 4
c. Statement 5 d. Statement 4 and 5

10 What will be the output of the following code? 1

a. Delhi#Mumbai#Chennai#Kolkata# b. Mumbai#Chennai#Kolkata#Mumbai#
c. Mumbai# Mumbai #Mumbai # Delhi# d. Mumbai# Mumbai #Chennai # Mumbai

[2]
11 Fill in the blank: 1
The modem at the received computer end acts as a .
a. Model
b. Modulator
c. Demodulator
d. Convertor

12 Consider the code given below: 1

Which of the following statements should be given in the blank for#Missing Statement,
if the output produced is 110?
Options:

a. global a
b. global b=100
c. global b
d. global a=100
13 State whether True or False : 1
When you connect your mobile phone with your laptop, the network formed is called as
LAN.
14 Fill in the blank: 1

is a candidate key which is not selected as a primary key.


a. Primary Key b. Foreign Key c. Candidate Key d. Alternate Key

15 Fill in the blank: 1

___________is the transfer of small pieces of data across various networks.

16 The correct syntax of seek()is: 1


a. file_object.seek(offset [, reference_point])
b. seek(offset [, reference_point])
c. seek(offset, file_object)
d. seek.file_object(offset) [3]
Q17 and 18 are ASSERTION AND REASONING based questions. Mark the correct
choice as
(a) Both A and R are true and R is the correct explanation for A
(b) Both A and R are true and R is not the correct explanation for A
(c) A is True but R is False
(d) A is false but R is True
17 Assertion (A):- Dictionaries are mutables.. 1
Reasoning (R):- The contents of the dictionary can be changed after it has been created

18 Assertion (A):- If the arguments in a function call statement match the number 1
and order of arguments as defined in the function definition, such argumentsare called
positional arguments.
Reasoning (R):- During a function call, the argument list first contains default
argument(s) followed by positional argument(s).
SECTION B
19 Expand the following terms related to Computer Networks: 1+1=2
(i) a. SMTP b. POP

(ii) Out of the following, which is the fastest wired and wireless medium of
transmission?
Infrared, coaxial cable, optical fiber, microwave, Ethernet cable
OR

(i) Differentiate between web server and web browser.


(ii) Give one advantages and two disadvantages of star topology.
20 The code given below accepts a number as an argument and returns the reverse number. 2
Observe the following code carefully and rewrite it after removing all syntax and logical
errors. Underline all the corrections made.

Def oddtoeven(L)
For i in range(len(L)):
if(L[i]%2 !=0):
L[i] = L[i]*2
print(L)
21 Write a function count (city) in Python, that takes the dictionary, PLACES as an 2
argument and displays the names (in lowercase) of the places whose names are less than
7 characters.
For example, Consider the following dictionary

City ={1:"Delhi",2:"London",3:"Kolkata",4:"NewYork",5:"Moscow"}
The output should be: “Delhi”, ”London”, ”Moscow”
OR
Write a function, Words_Length(STRING), that takes a string as an argument and
returns a tuple containing length of each word of a string.For example, if the string is
"this too shall pass", the tuple will have (4, 3, 5,4)

[4]
22 Predict the output of the following code: 2

23 Predict the output of the Python code given below: 1+1=2

OR
Predict the output of the Python code given below:

24 Ms. Shweta has just created a table named “Employee” containing columns Empno, 2
Ename,Department and Salary.

After creating the table, she realized that she has forgotten to apply primary key
constraint in Empno column. Help her in writing an SQL command toadd a primary
key constraint to Empno column to the table Employee.
OR
Angel has created table School with column sid,Student_name,DOB,Fee,City. Later
she realized that she has forgotten to apply primary key in sid, also she wants to
change the column name from sid to student_id. Help her to change the column
name to student_id from sid and also apply primary key in it.
[5]
25 Predict the output of the following code: 2

SECTION C
26 Predict the output of the Python code given below: 3

27 Consider the table MEMBER given below and write the output of the SQLqueries that 1*3=3
follow.

MID MNAME AG GENDE GAME PAY DOAPP


E R
5246 AMRITA 35 FEMALE CHESS 900 2006- 03-27
4687 SHYAM 37 MALE CRICKET 1300 2004- 04-15
1245 MEENA 23 FEMALE VOLLEYBAL 1000 2007- 06-18
L
1622 AMRIT 28 MALE KARATE 1000 2007- 09-05
1256 AMINA 36 FEMALE CHESS 1100 2003- 08-15
1720 MANJU 33 FEMALE KARATE 1250 2004- 04-10
2321 VIRAT 35 MALE CRICKET 1050 2005- 04-30

[6]
(i) SELECT COUNT(DISTINCT GAME) FROM MEMBER;
(ii) SELECT MNAME, GAME FROM MEMBER WHERE
DOAPP<"2007-01-01" AND MNAME LIKE "AM%";
(iii) SELECT MNAME, AGE, PAY FROM CLUB WHEREGENDER =
"FEMALE" AND PAY BETWEEN 1000 AND 1200;
28 Write a function in Python to read a text file, Story.txtand displays those lines which 3
begin with the word ‘Once’.
OR
Write a method COUNTLINES () in Python to read lines from text file ‘FILE.TXT’ and
display the lines which are starting with any vowel.

29 Consider the table HRMgiven below: 1*3=3


Table: HRM

ID Name Designation Salary Incentive


P01 Mohit Manager 99000 5800

P02 Rakesh Clerk 70000 2600

P03 Suresh Superviser 48000 NULL


P04 Sahil Clerk 61000 2900

P05 Rubeena Superviser 50000 3100

Based on the given table, write SQL queries for the following:
(i) Increase the salary by 5% of all employees who are not getting any
incentive.
(ii) Display Name and Total Salary (sum of Salary and Allowance) of all
employees. The column heading ‘Total Salary’ should alsobe displayed.
(iii) Delete the record of Supervisors who have salary less than
50000

30 A list contains following record of a customer: 3


[Patient_name, Phone_number, City]
Write the following user defined functions to perform given operations on the stack
named status:
(i) Push_element() - To Push an object containing name and Phone number of
patients who live in Delhi to the stack
(ii) (ii) Pop_element() - To Pop the objects from the stack and display them. Also,
display “Stack Empty” when there are no elements in the stack.
For example: If the lists of customer details are:
[“Kabir”, “99999999999”,”Goa”]
[“Neha”, “8888888888”,”Delhi”]
[“Mehul”,”77777777777”,”Delhi”]
[“Asimita”, “1010101010”,”Goa”]
The stack should contain
[“Neha”, “8888888888”] [7]
[“Mehul”,”77777777777”]

The output should be:


[“Neha”, “8888888888”]
[“Mehul”,”77777777777”]
Stack Empty
SECTION D
31 Consider the Item and company Table 1*4=4
Table : Item
Icode IName Price Rating Cid
I01 Mobile 12000 5 A01
I02 TV 20000 4 A02
I03 OVEN 5000 7 A03
I04 EARPHONE 5000 8 A04
I05 WATCH 10000 6 A05
I06 CAMERA 11000 6 A06

Table : Company

CId Cname
A01 Apple
A02 Samsung
A03 Philips
A04 Xiomi
A05 Vivo
A06 Oppo
Write SQL queries :
i. Display item name and company name from the tables Item and Company
ii. Display the structure of table Item.
iii. Display the maximum rating for each company.
iv. Display the item name, price and rating in ascending order of
rating.

32 Vihaan is a Python programmer working in a school. For the Annual Sports Event, 4
he has created a csv file named Sports.csv, to store theresults of students in different
sports events. The structure of Sports.csv is :
[Player_Id, Player_Name, Game, Result]
Where
Player_Idis Player ID (integer)
Player_nameis Player Name (string)
Game is name of game in which student is participating(string)

Result is result of the game whose value can be either 'Winner', 'Defeated'or 'NO
result'
[8]Vihaan wants to write thefollowing user
For efficiently maintaining data of the event,
defined functions:
input() – to input a record from the user and add it to the file Sports.csv. The column
headings should also be added on top of thecsv file.
Winner_Count()– to count the number of player who have won any event.
As a Python expert, help him complete the task.
SECTION E
33 NMS Training Institute is planning to set up its Centre in Bhubaneswar with four 1*5=5
specialized blocks for Medicine, Management, Law courses along with an Admission
block in separate buildings. The physical distances between these blocks and the number
of computers to be installed in these blocks are given below. You as a network expert
have to answer the queries raised by their board of directors as given in (i) to (iv).
Shortest distances between various locations in meters:
Admin Block to Management Block 50
Admin Block to Medicine Block 30
Admin Block to Law Block 65
Management Block to Medicine Block 40
Management Block to Law Block 125
Law Block to Medicine Block 35
Number of Computers installed at various locations are as follows:

Admin Block 250


Management Block 100
Medicine Block 45
Law Block 95

(i). Suggest the most suitable location to install the main server of this institution to get
efficient connectivity.
(ii). Suggest by drawing the best cable layout for effective network connectivity of the
blocks having server with all the other blocks.
(iii). Suggest the device to be installed in each of these buildings for connecting
computers installed within the building.
(iv) Suggest the most suitable wired medium for efficiently connecting each computer
installed in every building out of the following network cables:
• Coaxial Cable
• Ethernet Cable
• Single Pair
• Telephone Cable. [9]
(v) Suggest a device/software to be installed to take care of data security.

34 (i) Differentiate between w and a file modes in Python. 2+3=5

(ii) Consider a file, Movie.DAT, containing records of the following structure:


[MovieName, Banner, YearofRelease]
Write a function, CaptureData(), that reads contents from the file Movie.DAT and
copies the records with Banner as “YashRaj” to the file named Yashrajfilms.DAT.
The function should return thetotal number of records copied to the file
Yashrajfilms.DAT.
OR
(Option for part (ii) only)
A Binary file, CINEMA.DAThas the following structure:
{MNO:[MNAME, MTYPE]}
Where
MNO – Movie Number
MNAME – Movie Name
MTYPEis Movie Type
Write a user defined function, find Type(mtype), that accepts mtype
as parameter and displays all the records from the binary file
CINEMA.DAT, that have the value of Movie Type as mtype.

35 (i) What do you mean by tuple in relation data model.


(ii) Rehaan wants to write a program in Python to insert the 1+4=5
followingrecord in the table named EMP in MYSQL database,
Company:
a. eno(Empno )- integer
b. ename(Name) - string
c. DOB (Date of birth) – Date
d. Salary – float
Note the following to establish connectivity between Python andMySQL:
e. Username - root
f. Password – password
g. Host - localhost
The values of fields eno, name, DOBand salary has to be accepted from the user. Help
Rehaan to write the program in Python.
OR
(i) Give one difference between Primary key and Unique.
(ii) Gurmehar has created Product in MYSQL database,
Product:
a. Pno(Product Number )- integer
b. Pname(Product Name) - string
c. DOM (Date of Manufacture) – Date
d. Price – float
Note the following to establish connectivity
[10] between Python andMySQL:
e. Username - root
f. Password – password
g. Host – localhost
Gurmehar, now want to display the records of the product whose price is more than
10000. Help Gurmehar to write the program in
python

[11]
KENDRIYA VIDYALAYA SANGATHAN ::HYDERABAD REGION
SECOND PRE-BOARD EXAMINATION 2023-24
COMPUTER SCIENCE (083)
Class: XII
Time Allowed: 03:00 Hrs. Max Marks:70
General Instructions:
(a) Please check this question paper contains 35 questions.
(b) The paper is divided into 4 Sections- A, B, C, D and E.
(c) Section A, consists of 18 questions (1 to 18). Each question carries 1 Mark.
(d) Section B, consists of 7 questions (19 to 25). Each question carries 2 Marks.
(e) Section C, consists of 5 questions (26 to 30). Each question carries 3 Marks.
(f) Section D, consists of 2 questions (31 to 32). Each question carries 4 Marks.
(g) Section E, consists of 3 questions (33 to 35). Each question carries 5 Marks.
(h) All programming questions are to be answered using Python Language only.
Q.No Question Marks
SECTION A
1. State True or False: 1
Python Keywords cannot be variables.
2. What will be the datatype of d, if d = (15) ? 1
(a) int (b) tuple (c) list (d) string
3. What will be the output of the following expressions: a) 2**3**2 b) (2**3)**2 1
a) a: 512 b. 64
b) a: 64 b. 512
c) a: 1024 b. 64
d) a: 64 b. 64
4. Table A has 3 rows and 4 columns and Table B has 5 rows and 6 columns. What is 1
the degree and cardinality of Cartesian product of A and B?
a) Degree is 15 and Cardinality is 15
b) Degree is 10 and Cardinality is 10
c) Degree is 10 and Cardinality is 15
d) Degree is 15 and Cardinality is 10
5. What will be output of the following code: 1
d1={1:2,3:4,5:6}
d2=d1.get(3,5)
print(d2)
a) 3 b) 4 c) 5 d) Error
6. Consider the given expression: 1
3 and 5<15 or 3<13 and not 12<2
Which of the following is the correct value of the expression?
a) True b) False c) None d) NULL
7. What will be the output of the following code:- 1
s="one two three"
s=s.split()
print(s)
a) ['one', 'two', 'three'] b) ('one', 'two', 'three') c) [one, two, three]
d) None
8. Hanu wants to connect 10 computers in her office. What is the type of network? 1
a) LAN b) WAN c) PAN d) FAN
9. Consider the statements given below and then choose the correct output 1
from the given options:
s=”KVS@CBSE 2023”
print(s[-2:2:-2])
a) 22EB@ b) 2023@kvs c) KVS@2023 d) 30 SCS
10. Which of the following MySQL command/clause is used to sort the data in a table 1
a) SORT b) ASCENDING c) ORDER BY d) DROP
11. Which of the following device is responsible for signal boosting 1
a) Repeater b) Router c) Switch d) Modem
12. ____function returns the current position of file pointer 1
a) tell() b) seek() c) first() d) last()
13. In the URL www.kvsangathan.nic.in , _____ tells the type of website 1
a) www b) .in c) kvsangathan d) .nic
14. Which of the following is not an Aggregate function. 1
a) COUNT b) MIN c) MAX d) DISTINCT
15. What will be the output of the following code: 1
t=(2,3,[4,5,6],7)
t[2]=4
print(t)
a) (2,3,4,7) b) (2,3,[4],7) c) Type error d) None
16. What possible output(s) are expected to be displayed on screen at the time of 1
execution of the program from the following code?
import random
points=[30,50,20,40,45]
begin=random.randint(1,3)
last=random.randint(2,4)
for c in range(begin,last+1):
print(points[c],"#",end=’’)
(a) 20#50#30# (b) 20#40#45 (c) 50#20#40# (d) both (b) and (c)
Q 17 and 18 are ASSERTION AND REASONING based questions. Mark the
correct choice as
(a)Both A and R are true and R is the correct explanation for A
(b)Both A and R are true and R is not the correct explanation for A
(c)A is True but R is False (d)A is False but R is True
17. Assertion (A): CSV module allows to write a single record into each row in CSV file 1
using write row() function.
Reason (R): The write row() function creates header row in csv file by default.
18. Assertion (A):- In Python, statement return [expression] exits a function. 1
Reasoning (R):- Return statement passes back an expression to the caller. A
return statement with no arguments is the same as return None.
SECTION B
19. i) Expand the following terms: SMTP, URL 2
ii) Difference between HTML and XML
OR
i) What is Band width?
ii) Define baud rate?
20. Rewrite the program after correcting all the errors and underline each correction. 2
n=int(input("Enter number:"))
temp==n
rev=0
While(n>0)
dig=n%10
rev=rev*10+dig
n=n//10
if(temp==rev):
print(The number is a palindrome!)
else:
print("The number isn't a palindrome!")
21. Predict output of the following code fragment – 2
L=[12,23,18,9,17]
for i in range(len(L)):
if(L[i]%3==0):
L[i]=0
else:
L[i]=1
print(L)
OR
Write the output of the code given below:
book_dict = {"title": "You can win", “copies”:15}
book_dict['author'] = “Shiv Khera”
book_dict['genre'] = "Motivation"
print(book_dict.items())

22. Mr. Avinash wants to create a table in MySQL for Employee (eid (Primary Key), 2
ename, salary)
OR
Write any two differences between DELETE and DROP commands
23. Write a python statement for each of the following tasks using built-in functions/ 2
methods only:
i)To add list of elements L2=[11,12,14] to existing list L1=[10,15].
ii)To make the elements in sorted manner.
OR
A list named stu_percentage stores the percentage of students of a class. Write
python command to import the required module and display the most common
percentage from the given list.
24. Find output generated by the following code: 2
string="aabbcc"
count=3
while True:
if string[0]=='a':
string=string[2:]
elif string[-1]=='b':
string=string[:2]
else:
count+=1
break
print(string)
print(count)
25. Find output generated by the following code: 2
def Compy(N1,N2=10):
return N1 > N2
NUM= [10,23,14,54,32]
for VAR in range (4,0,-1):
A=NUM[VAR]
B=NUM[VAR-1]
if VAR > len(NUM)//2:
print(Compy(A,B),'#', end=' ')
else:
print(Compy(B),'%',end=' ')

SECTION C
26. Write a Python program to count number of words in a given string that start 3
with vowels.
27. Write the SQL command for the following on the basis of given table. 3
Table: SPORTS
StudentNo Class Name Game1 Grade1 Game2 Grade2
10 7 Sammer Cricket B Swimming A
11 8 Sujit Tennis A Skating C
12 7 Kamal Swimming B Football B
13 7 Venna Tennis C Tennis A
14 9 Archana Basketball A Cricket A
15 10 Arpit Cricket A Athletics C

i) Display the names of the students who have grade ‘A’ in either Game 1 or
Game 2 or both.
ii) Display the number of students having the GRADE1 as ‘A’ in Game1.
iii) Display number of students in each class group.

28. Write a Python program to read the text file abc.txt and print only the lines that 3
start with ‘s’

OR
Write a function in Python to read lines from a text file book.txt, to find and display
the occurrence of the word 'are'. For example, if the content of the file is:
Books are referred to as a man’s best friend. They are very beneficial for mankind
and have helped it evolve. Books leave a deep impact on us and are responsible
for uplifting our mood.
The output should be 3.
29. a. Define the term Domain with respect to RDBMS. Give one example to support 3
your answer.
b. What is the syntax of ALTER command in MySQL?
c. How to find referential integrity in MySQL?
30. Write the following functions in Python: 3
(i) Push (st, expression), where expression is a string containing a valid
arithmetic expression with +, -, *, and / operators, and st is a list
representing a stack. The function should push all the operators
appearing in this expression into the stack st.
(ii) Pop(st) to pop all the elements from the stack st and display them. It should
also display the message 'Stack Empty' when the stack becomes empty.
SECTION D
31. Write the SQL query commands based on following table: 4
Table : Book
Book_ Book Author_name Publis Price Type Quan
id name her tity
C0001 Fast Cook Lata Kapoor EPB 355 Cookery 5
F0001 The Tears William Hopkins First 650 Fiction 20
Publ
T0001 My First Brain & Brooke FPB 350 Text 10
c++
T0002 C++ Brain A.W. Rossaine TDH 350 Text 15
works
F0002 Thunderbo Anna Roberts First 750 Fiction 50
lts Publ
Write SQL query for (a) to (d)
a. To show book name, Author name and price of books of First Publ
Publisher
b. To list the names from books of text type
c. To Display the names and price from books in ascending order of their
prices.
d. To increase the price of all books of EPB publishers by 50.

32. Anusha of class 12 is writing a program to create a CSV file “user.csv” 4


which will contain user name and password for some entries. She has written the
following code.
As a programmer, help her to successfully execute the given task.
import ________ # Line 1
def addCsvFile(UserName,PassWord): # to write / add data into the CSV file
f=open(' user.csv','_____') # Line 2
newFileWriter = csv.writer(f)
newFileWriter.writerow([UserName,PassWord])
f.close()
#csv file reading code
def readCsvFile(): # to read data from CSV file
with open(' user.csv','r') as newFile:
newFileReader = csv.________(newFile) # Line 3
for row in newFileReader:
print (row[0],row[1])
newFile.________ # Line 4
addCsvFile('Arjun','123@456')
addCsvFile('Arunima','aru@nima')
addCsvFile('Frieda','myname@FRD')
readCsvFile()
(a) Name the module he should import in Line 1.
(b) In which mode, Anuj should open the file to add data into the file
(c) Fill in the blank in Line 3 to read the data from a csv file.
(d) Fill in the blank in Line 4 to close the file.

SECTION E
33. BeHappy Corporation has set up its new centre at Noida, Uttar Pradesh for its 5
office and web-based activities. It has 4 blocks of buildings.
Distance between the various blocks is as follows:
A to B 40 m
B to C 120
m
C to D 100
m
A to D 170
m
B to D 150
m
A to C 70m
Numbers of computers in each block
Block A 25
Block B 50
Block C 12
5
Block D 10

Suggest the most suitable location to install the main server of this institution to
get efficient connectivity
a. Suggest and draw the cable layout to efficiently connect various blocks of
buildings within the Noida centre for connecting the digital devices
b. Suggest the placement of the following device with justification
i.Repeater
ii. Hub/Switch
c. Which kind of network (PAN/LAN/WAN) will be formed if the Noida office
is connected to its head office in Mumbai?

34. A binary file data.dat needs to be created with following data written it in the 2+3
form of Dictionaries.
EID ENAME SALARY
101 KARTHIK 50000
102 PRUDHVI 55000
103 MANASA 60000

Write the following functions in python accommodate the data and manipulate
it.
a) A function insert() that creates the data.dat file in your system and
writes the three dictionaries.
b) A function() read() that reads the data from the binary file and displays
the dictionaries whose SALARY is greater than 50000.

OR
a. What is the difference between w (write) mode and a (append) mode

b. Write a Program in Python that defines and calls the following user defined 1+4
functions: (i) 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.
(ii) COUNTR() – To count the number of records present in the CSV file
named ‘record.csv’
35. 2+3
a. What is the difference between UNIQUE KEY and PRIMARY KEY?
b. Arushi has created a table named student in MYSQL database, School:
•rno(Roll number )- integer
• name(Name) - string
• clas (Clas) – string
• marks – float
Note the following to establish connectivity between Python and MySQL:
• Username - root • Password - 12345
• Host - localhost
ii)Arushi, now wants to add record of student by taking data
from user. Help arushi to write the program in Python.
OR
a. Define Alternate Key
b. Ravi has created a table named employee in MYSQL database, orgn:
•eid(Roll number )- integer
• ename(Name) - string
• DOJ (Date of joining) – Date
• Salary – float
Note the following to establish connectivity between Python and MySQL:
• Username - root • Password - mysql
2+3
• Host - localhost
Ravi, now wants to display the records of employees whose salary is more
than 25000. Help Ravi to write the program in Python.

***************
KENDRIYA VIDYALAYA SANGATHAN HYDERABAD REGION
PRE-BOARD -1 EXAMINATION - 2023-24
MARKING SCHEME
Class: XII Max Marks:70
Subject: COMPUTER SCIENCE (083) Time: 03:00 Hrs
Q.No Question Mark
s
SECTION A(Each correct answer carries 1 Mark)
1. State True of False: 1
Python Keywords cannot be variables.
Ans: True
2. What will be the datatype of d, if d = (15) ? 1
Ans: (a) int
3. What will be the output of the following expressions: a) 2**3**2 b) (2**3)**2 1
Ans: a) a: 512 b. 64
4. Table A has 3 rows and 4 columns and Table B has 5 rows and 6 columns. What is the degree 1
and cardinality of Cartesian product of A and B?
Ans: c) Degree is 10 and Cardinality is 15
5. What will be output of the following code: 1
d1={1:2,3:4,5:6}
d2=d1.get(3,5)
print(d2)
Ans: b) 4
6. Consider the given expression: 1
3 and 5<15 or 3<13 and not 12<2
Which of the following is the correct value of the expression?
Ans: a) True
7. What will be the output of the following code:- 1
s="one two three"
s=s.split()
print(s)
Ans: a) ['one', 'two', 'three']
8. Hanu wants to connect 10 computers in her office. What is the type of network? 1
Ans: a) LAN
9. Consider the statements given below and then choose the correct output 1
from the given options:
s=”KVS@CBSE 2023”
print(s[-2:2:-2])
Ans: a) 22EB@
10. Which of the following MySQL command/clause is used to sort the data in a table 1
Ans: c) ORDER BY
11. Which of the following device is responsible for signal boosting 1
Ans: a)Repeater
12. ____function returns the current position of file pointer 1
Ans: a) tell()
13. In the URL www.kvsangathan.nic.in tells the type of website 1
Ans: b) .in
14. Which of the following is not an Aggregate function. 1
Ans: d) DISTINCT
15. What will be the output of the following code: 1
t=(2,3,[4,5,6],7)
t[2]=4
print(t)
Ans: c) Type error
16. What possible output(s) are expected to be displayed on screen at the time of 1
execution of the program from the following code?
import random
points=[20,40,10,30,15]
points=[30,50,20,40,45]
begin=random.randint(1,3)
last=random.randint(2,4)
for c in range(begin,last+1):
print(points[c],"#",end=‟‟)
(a) 20#50#30# (b) 20#40#45
(c) 50#20#40# (d) both (b) and (c)
Ans: (d)
Q17and18areASSERTIONANDREASONINGbasedquestions.Markthecorrect choice as 1
(a)BothAandRare trueandRisthe correctexplanationforA
(b)BothAandRaretrue andRisnotthecorrectexplanationforA
(c)AisTruebutRisFalse
(d)AisFalsebutRisTrue
17. Assertion (A): CSV module allows to write a single record into each 1
row in CSV file using writerow() function.
Reason (R): The writerow() function creates header row in csv file by
default.
Ans: (c)A is True but R is False
18. Assertion (A):- In Python, statement return [expression] exits a function. 1
Reasoning (R):- Return statement passes back an expression to the caller.
A return statement with no arguments is the same as return None.
Ans: (a)Both A and R are true and R is the correct explanation for A
SECTION B
19. i) Expand the following terms: SMTP, URL 2
Ans: Simple Mail Transfer Protocol, Uniform Resource Locator
ii) Difference between HTML and XML
Ans: HTML - Hyper Text Markup Language
XML: eXtensible Markup Language
HTML: Commands Predefined
XML: Commands are as per need of user
OR
i) What is Band width?
Ans: Bandwidth is a range of frequencies within a continuous set of
frequencies. It is measured in Hertz.
ii) Define baud rate?
Ans: Baud rate refers to the number of signal or symbol changes that occur
per second.
20. Rewrite the program after correcting all the errors and underline each correction. 2
n=int(input("Enter number:"))
temp=n
rev=0
while(n>0):
dig=n%10
rev=rev*10+dig
n=n//10
if(temp==rev):
print(“The number is a palindrome!”)
else:
print("The number isn't a palindrome!")(1/2 mark for each correction)
21. Predict output of the following code fragment – (for correct answer 2 marks) 2
L=[12,23,18,9,17]
for i in range(len(L)):
if(L[i]%3==0):
L[i]=0
else:
L[i]=1
print(L)
Ans: [0,1,0,0,1]
OR
Write the output of the code given below:
book_dict = {"title": "You can win", “copies”:15}
book_dict['author'] = “Shiv Khera”
book_dict['genre'] = "Motivation"
print(book_dict.items())
Ans: dict_items([('title', 'You can win'), ('copies', 15), ('author', 'Shiv Khera'), ('genre',
'Motivation')])
22. Mr. Avinash wants to create a table in MySQL for Employee(eid (Primary Key), ename, 2
salary)For correct syntax 1 mark and complete query 1 mark
Ans: CREATE TABLE Employee(eid int(6) primary key, ename varchar(60), salaray
float(10,2));
OR
Write any two differences between DELETE and DROP commands
Ans: For each difference 1 mark
DELETE DROP
Is a DML Command Is a DDL Command
Deletes data rows only Deletes the whole table and cannot be retrieved
23. i- L1.extend(L2) 2
ii. L.sort()
1 mark for each correct answer

(OR)

A list named stu_marks stores marks of students of a class. Write the Python command to
import the required module and display the average of the marks in the list.
Solution:

import statistics
stu_marks =[45,60,70,85,40]
print(statistics.mean(stu_marks))

1 mark for correct import statement


1 mark for correct command with mean() and print() (30,60,90)
24. Find output generated by the following code: 2
string="aabbcc"
count=3
while True:
if string[0]=='a':
string=string[2:]
elif string[-1]=='b':
string=string[:2]
else:
count+=1
break
print(string)
print(count)
Ans: bbcc
4
25. Find output generated by the following code: 2
def Compy(N1,N2=10):
return N1 > N2
NUM= [10,23,14,54,32]
for VAR in range (4,0,-1):
A=NUM[VAR]
B=NUM[VAR-1]
if VAR > len(NUM)//2:
print(Compy(A,B),'#', end=' ')
else:
print(Compy(B),'%',end=' ')
Ans: False # True # True % False %
SECTION C
26. Write a Python program to count number of words in a given string that start with vowels. 3
Ex: If s=”an apple a day keeps the doctor away”
Answer should be 4
27. Write the SQL command for the following on the basis of given table. 3
Table : SPORTS
StudentNo Class Name Game1 Grade1 Game2 Grade2
10 7 Sammer Cricket B Swimming A
11 8 Sujit Tennis A Skating C
12 7 Kamal Swimming B Football B
13 7 Venna Tennis C Tennis A
14 9 Archana Basketball A Cricket A
15 10 Arpit Cricket A Athletics C
i) Display the names of the students who have grade „A‟ in either Game 1 or Game 2 or
both.
Ans: SELECT Name from SPORTS WHERE Grade1 LIKE „A‟ or Grade2 LIKE „A‟;
ii) Display the number of students having the GRADE1 as „A‟ in Game1.
Ans: SELECT COUNT(*)FROM SPORTS WHERE Grade1 LIKE „A‟;
iii) Display number of students in each class group.
Ans: SELECT CLASS, COUNT(*) FROM SPORTS WHERE GROUP BY Class;
28. Write a Python program to read the text file abc.txt and print only lines that start with„s‟ 3

Ans:

f=open(“abc.txt”,‟r‟)
s=f.readlines()
for i in s:
if(i[0]==‟s‟):
print(i,” starts with s”)
f.close()
OR

Write a method in Python to read lines from a text file book.txt, to find and display the
occurrence of the word 'are'. For example, if the content of the file is:
Books are referred to as a man‟s best friend. They are very beneficial for mankind and have
helped it evolve. Books leave a deep impact on us and are responsible for uplifting our mood.

The output should be 3.

Ans:

f=open(“abc.txt”,‟r‟)
s=f.read()
print(s.count(“are”))
f.close()

29. a. Domain is a term used in relational database management systems (RDBMS) to 3


describe the data type and constraints of a column in a table. A domain defines the
range of possible values that a column can store in a database . For example, a column
that stores user emails can have a domain of email addresses.
b. The syntax to rename a table in MySQL is:
ALTER TABLE table_name RENAME TO new_table_name; table_name.
c. The only way you can enforce referential integrity in MySQL is by using a foreign
key. This is an indexed column in a child table that refers to a primary key in a parent
table.
30. Write the following functions in Python: 3
(i) Push(st, expression), where expression is a string containing a valid arithmetic expression
with +, -, *, and / operators, and st is a list representing a stack. The function should push all
the operators appearing in this expression into the stack st.
(ii) Pop(st) to pop all the elements from the stack st and display them. It should also display
the message 'Stack Empty' when the stack becomes empty.
Ans:
exp=input("Enter expression:")
st=[]
def Push(st,expression):
st.append(expression)
def Pop(st):
if st!=[]:
return st.pop()
else:
return "Stack is empty"
for i in exp:
if i.isdigit() or i.isalpha():
pass
else:
Push(st,i)
while True:
if st!=[ ]:
print(Pop(st))
else:
break
SECTION D
31. Write the SQL query commands based on following table for (a) to (d) 4
Table : Book
Book_id Book_name Author_name Publisher Price Type Quantity
C0001 Fast Cook Lata Kapoor EPB 355 Cookery 5
F0001 The Tears William First Publ 650 Fiction 20
Hopkins
T0001 My First c++ Brain & Brooke FPB 350 Text 10
T0002 C++ Brain A.W. Rossaine TDH 350 Text 15
works
F0002 Thunderbolts Anna Roberts First Publ 750 Fiction 50
a. To show book name, Author name and price of books of “First Publ” Publisher
b. To list the names from books of text type
c. To Display the names and price from books in ascending order of their prices.
d. To increase the price of all books of EPB publishers by 50.
Ans: a. SELECT Book_name, Author_name, Price FROM Book WHERE Publisher =
„First Publ‟;
b. SELECT Book_name FROM Book WHERE Type = „Text‟;
c. SELECT Book_name, Price FROM Book ORDER BY Price ASC;
d. UPDATE Book SET Price=Price+50 WHERE Publisher = “EPB”;
32. Anusha of class 12 is writing a program to create a CSV file “user.csv” 4
which will contain user name and password for some entries. She has written thefollowing code. As
a programmer, help her to successfully execute the giventask.
Ans:
import csv # Line 1
def addCsvFile(UserName,PassWord): # to write / add data into the CSV file
f=open(' user.csv','w') # Line 2
newFileWriter = csv.writer(f)
newFileWriter.writerow([UserName,PassWord])
f.close()
#csv file reading code
def readCsvFile(): # to read data from CSV file
with open(' user.csv','r') as newFile:
newFileReader = csv.reader(newFile) # Line 3
for row in newFileReader:
print (row[0],row[1])
newFile.close()# Line 4
addCsvFile('Arjun','123@456')
addCsvFile('Arunima','aru@nima')
addCsvFile('Frieda','myname@FRD')
readCsvFile()
(a) Name the module he should import in Line 1.
(b) In which mode, Anuj should open the file to add data into the file
(c) Fill in the blank in Line 3 to read the data from a csv file.
(d) Fill in the blank in Line 4 to close the file.
SECTION E
33. BeHappy Corporation has set up its new centre at Noida, Uttar Pradesh for its office and 5
web-based activities. It has 4 blocks of buildings.
a. Suggest the most suitable location to install the main server of this institution to get
efficient connectivity
Ans: Block C is suitable to install the main server
b. Suggest and draw the cable layout to efficiently connect various blocks of buildings
within the Noida centre for connecting the digital devices

or any other suitable layout.


c. Suggest the placement of the following device with justification
i. Repeater We need repeaters when distance to be travelled by signal is
more than 100mts.
ii. Hub/Switch: We need Switch for every block to connect the computers in
a network
d. Which kind of network (PAN/LAN/WAN) will be formed if the Noida office is
connected to its head office in Mumbai?
Ans: WAN
34. A binary file data.dat needs to be created with following data written it in the 2+3
form of Dictionaries.
EID ENAME SALARY
101 KARTHIK 50000
102 PRUDHVI 55000
103 MANASA 60000

Write the following functions in python accommodate the data and


manipulate it.
a) A function insert() that creates the data.dat file in your system and
writes the three dictionaries.
b) A functionread() that reads the data from the binary file and displays
the dictionaries whose SALARYis greater than 50000.

import pickle
def insert():
d1 = {'EID':1001, 'ENAME':'KARTHIK', 'SALARY':50000}
d2 = {' EID':1002, 'ENAME':'PRUDHVI', ' SALARY':55000}
d3 = {' EID':1003, 'ENAME':'MANASA', ' SALARY':60000}
f = open("data.dat","wb")
pickle.dump(d1,f)
pickle.dump(d2,f)
pickle.dump(d3,f)
f.close()
def read():
f = open("data.dat", "rb")
while True:
try:
d = pickle.load(f)
if d['SALARY']>50000:
print(d)
except EOFError:
break
f.close()
OR
a. What is the difference between w (write) mode and a (append) mode
Ans: w mode erases the previous content and append mode adds its content at the end
of the file
b. Write a Program in Python that defines and calls the following user defined functions:
(i) 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. 1+4
(ii) COUNTR() – To count the number of records present in the CSV file named
„record.csv‟.
import csv
def ADD():
f=open(" record.csv",'w')
csvwriter=csv.writer(f)
csvwriter.writerow(['empid','name','mobile'])
while True:
empid=int(input("Enter your employee id:"))
name=input("Enter your name:")
mobile=int(input("Enter your mobile no:"))
csvwriter.writerow([empid,name,mobile])
print("Do you want to enter more records:")
ch=input()
if(ch=='n'):
break
f.close()
def COUNTR():
f=open(”record.csv",'r')
csvreader=csv.reader(f)
cnt=0
for i in csvreader:
cnt+=1
print("No of records in the file:",cnt)
f.close()
ADD()
COUNTR()

35. a) What is the difference between UNIQUE KEY and PRIMARY KEY? 1+4
Ans: UNIQUE KEY allows NULL values but PRIMARY KEY doesn‟t.
1 mark for correct difference
b) The code given below inserts the following record in the table Student:
Ans:
import mysql.connector as mysql
def sqlData():
con1=mysql.connect(host="localhost",user="root", password="toor@123",
database="school")
mycursor = con1.cursor()
rno=int(input("Enter Roll Number :: "))
name=input("Enter name :: ")
clas=int(input("Enter class :: "))
marks=int(input("Enter Marks :: "))
query="insert into student values({},'{}',{},{})".format(rno,name,clas,marks)
mycursor.execute(query)
mycursor. commit()
print ("Data Added successfully")
½ mark for importing correct module
1 mark for correct connect ()
½ mark each for correct code to accept values from user
1/2 mark for correctly executing the query

OR
a) Define Alternate Key?
i) A candidate key is a set of attributes (or attribute) which uniquely identify the tuples
in relation or table.
1 mark for correct definition
ii) import mysql.connector as s 1+4
con=s.connect(host=”localhost”,user=”root”,passwd=”mysql”,database=”o
rgn”)
Mycursor=con.cursor()
Qry=”Select * from employee where salary{}”.format(25000)
Mycursor.execute(qry)
Data=mycursor.fetchall()
For rec in data:
Print(rec)
con.close()
½ mark for importing correct module
1 mark for correct connect()
1 mark for correctly executing the query
½ mark for correctly using fetchall()
1 mark for correctly displaying data
KENDRIYA VIDYALAYA SANGATHAN
RANCHI RAGION
COMPUTER SCINCE (083)
FIRST PRE-BOARD EXAMINATION
Class-XII
Max Marks-70 Time: 3 hrs

General Instructions:
1. This question paper contains five sections, Section A to E.
2. All questions are compulsory.
3. Section A have 18 questions carrying 01 mark each.
4. Section B has 07 Very Short Answer type questions carrying 02 marks each.
5. Section C has 05 Short Answer type questions carrying 03 marks each.
6. Section D has 03 Long Answer type questions carrying 05 marks each.
7. Section E has 02 questions carrying 04 marks each. One internal choice is given in Q35 against part c
only.
8. All programming questions are to be answered using Python Language only.

SECTION A
1 Identify the invalid Python statement from the following. 1
(a) _b=1 (b) __b1= 1 (c) b_=1 (d) 1 = _b

2 Identify the valid arithmetic operator in Python from the following. 1


(a) // (b) < (c) or (d) <>

3 If Statement in Python is __ 1
(a) looping statement (b) selection statement (c) iterative (d) sequential

4 Predict the correct output of the following Python statement – 1


print(4 + 3**3/2)

(a) 8 (b) 9 (c) 8.0 (d) 17.5

5 Choose the most correct statement among the following – 1

(a) a dictionary is a sequential set of elements


(b) a dictionary is a set of key-value pairs
(c) a dictionary is a sequential collection of elements key-value pairs
(d) a dictionary is a non-sequential collection of elements

6 Consider the string state = “Jharkhand”. Identify the appropriate statement that will display the last 1
five characters of the string state?

(a) state [-5:] (b) state [4:] (c) state [:4] (d) state [:-4]

7 What will be the output of the following lines of Python code? 1

if not False:
print(10)
else:
print(20)

Page 1 of 9
(a) 10 (b) 20 (c) True (d) False

8 Consider the Python statement: f.seek(10, 1) 1


Choose the correct statement from the following:

(a) file pointer will move 10 byte in forward direction from beginning of the file
(b) file pointer will move 10 byte in forward direction from end of the file
(c) file pointer will move 10 byte in forward direction from current location
(d) file pointer will move 10 byte in backward direction from current location

9 Which of the following function returns a list datatype? 1

a) d=f.read() b) d=f.read(10) c) d=f.readline() d) d=f.readlines()

10 Identify the device on the network which is responsible for forwarding data from one device to 1
another

(a) NIC (b) Router (c) RJ45 (d) Repeater

11 A table has initially 5 columns and 8 rows. Consider the following sequence of operations 1
performed on the table –
i. 8 rows are added
ii. 2 columns are added
iii. 3 rows are deleted
iv. 1 column is added
What will be the cardinality and degree of the table at the end of above operations?

(a) 13,8 (b) 8, 13 (c) 14,5 (d) 5,8

12 Which of the following constraint is used to prevent a duplicate value in a record? 1

(a) Empty (b) check (c) primary key (d) unique

13 The structure of the table/relation can be displayed using __________ command. 1

(a) view (b) describe (c) show (d) select

14 Which of the following clause is used to remove the duplicating rows from a select statement? 1

(a) or (b) distinct (c) any (d)unique

15 How do you change the file position to an offset value from the start? 1
(a) fp.seek(offset, 0) (b) fp.seek(offset, 1) (c) fp.seek(offset, 2) (d) None of them

16 Which of the following method is used to create a connection between the MySQL database and 1
Python?
(a) connector ( ) (b) connect ( ) (c) con ( ) (d) cont ( )

Q17 and 18 are ASSERTION AND REASONING based questions. Mark the correct choice as
(a) Both A and R are true and R is the correct explanation for A
(b) Both A and R are true and R is not the correct explanation for A
(c) A is True but R is False
(d) A is false but R is True
Page 2 of 9
17 Assertion (A): The function definition calculate(a, b, c=1,d) will give error. 1
Reason (R): All the non-default arguments must precede the default arguments.

18 Assertion (A): CSV files are used to store the data generated by various social media platforms. 1
Reason (R): CSV file can be opened with MS Excel.

SECTION - B
19 Find error in the following code(if any) and correct code by rewriting code and underline the 2
correction;‐

x= int(“Enter value of x:”)


for in range [0,10]:
if x=y
print( x + y)
else:
print( x‐y)

20 (a) 2
Find output generated by the following code:

Str = "Computer"
Str = Str[-4:]
print(Str*2)

OR
Consider the following lines of codes in Python and write the appropriate output:

student = {'rollno':1001, 'name':'Akshay', 'age':17}


student['name']= “Abhay”
print(student)

21 What do you mean by Foreign key? How it is related with Referential Integrity? 2

22 Find output generated by the following code: 2


string="aabbcc"
count=3
while True:
if string[0]=='a':
string=string[2:]
elif string[-1]=='b':
string=string[:2]
else:
count+=1
break
print(string)
print(count)

23 Expand the following terms: 2


i. NIC
ii. TCP/IP
iii. POP
iv. SMTP

Page 3 of 9
24 Write one advantage and one disadvantage of each – STAR Topology and Tree Topology 2

OR

What do you mean by Guided Media? Name any three guided media?

25 Differentiate between DDL and DML? 2

OR

Write the main difference between INSERT and UPDATE Commands in SQL

SECTION - C
26 Write definition of a method/function AddOdd(VALUES) to display sum of odd values from the 3
list of VALUES

27 Define a function SHOWWORD () in python to read lines from a text file STORY.TXT, and 3
display those words, whose length is less than 5.

OR

Write a user defined function in python that displays the number of lines starting with 'H' in the file
para.txt

28 Write the outputs of the SQL queries (a) to (c) based on the relation Furniture 3

No Itemname Type Dateofstock Price Discount


1 White lotus Double Bed 23/02/2002 30000 25
2 Pink feather Baby Cot 20/01/2002 7000 20
3 Dolphin Baby Cot 19/02/2002 9500 20
4 Decent Office Table 01/01/2002 25000 30
5 Comfort Zone Double Bed 12/01/2002 25000 25
6 Donald Baby Cot 24/02/2002 6500 15
7 Royal finish Office Table 20/02/2002 18000 30
8 Royal tiger Sofa 22/02/2002 31000 30
9 Econo sitting Sofa 13/12/2001 9500 25
10 paradise Dining Table 19/02/2002 11500 25
11 Wood Comfort Double Bed 23/03/2003 25000 25
12 Old Fox Sofa 20/02/2003 17000 20
13 Micky Baby Cot 21/02/2003 7500 15

(a) SELECT Itemname FROM Furniture WHERE Type="Double Bed";


(b) SELECT MONTHNAME(Dateofstock) FROM Furniture WHERE Type="Sofa";
(c) SELECT Price*Discount FROM Furniture WHERE Dateofstock>31/12/02;
29 Consider the following table GAMES 3

GCode GameName Number PrizeMoney ScheduleDate


101 Carom Board 2 5000 23‐Jan‐2004
102 Badminton 2 12000 12‐Dec‐2003
103 Table Tennis 4 8000 14‐Feb‐2004
105 Chess 2 9000 01‐Jan‐2004
108 Lawn Tennis 4 25000 19‐Mar‐2004
Write the output for the following queries :
Page 4 of 9
(i) SELECT COUNT(DISTINCT Number) FROM GAMES;
(ii) SELECT MAX(ScheduleDate),MIN(ScheduleDate) FROM GAMES;
(iii) SELECT SUM(PrizeMoney) FROM GAMES;

30 Write PushOn(Book) and Pop(Book) methods/functions in Python to add a new Book and delete a 3
Book from a list of Book titles, considering them to act as push and pop operations of the Stack data
structure.

OR

Mr.Ajay has created a list of elements. Help him to write a program in python with functions,
PushEl(element) and PopEl(element) to add a new element and delete an element from a List of
element Description, considering them to act as push and pop operations of the Stack data structure
. Push the element into the stack only when the element is divisible by 4.

For eg:if L=[2,5,6,8,24,32]


then stack content will be 32 24 8

SECTION - D
31 India Tech Solutions (ITS) is a professional consultancy company. The company is planning 5
to set up their new offices in India with its hub at Hyderabad. As a network adviser, you have
to understand their requirement and suggest them the best available solutions. Their queries
are mentioned as (i) to (v) below.

Physical locations of the blocks of TTC

HR BLOCK MEETING BLOCK

FINANCE BLOCK

Block to block distance (in m)


Block (From) Block (To) Distance
HR Block MEETING 110
HR Block Finance 40
MEETING Finance 80
Expected number of computers
Block Computers
HR 25
Finance 120
MEETING 90

(i)Which will be the most appropriate block, where TTC should plan to install their server?
(ii) Draw a block to block cable layout to connect all the buildings in the most appropriate
manner for efficient communication.
(iii)What will be the best possible connectivity out of the following, you will suggest to
connect the new set up of offices in Bengalore with its London based office.
• Satellite Link
• lInfrared
Page 5 of 9
• Ethernet
(iv)Which of the following device will be suggested by you to connect each computer in each
of the buildings?
• l Switch
• l Modem
• l Gateway
(v) Company is planning to connect its offices in Hyderabad which is less than 1 km. Which
type of network will be formed?

32 Find the output of the following: 2


(a)
fruit_list1 = ['Apple', 'Berry', 'Cherry', 'Papaya']
fruit_list2 = fruit_list1
fruit_list3 = fruit_list1[:]
fruit_list2[0] = 'Guava'
fruit_list3[1] = 'Kiwi'
sum = 0
for ls in (fruit_list1, fruit_list2, fruit_list3):
if ls[0] == 'Guava':
sum += 1
if ls[1] == 'Kiwi':
sum += 20
print (sum)

(b) Consider the table 3


TRAINER
TI TNAME CITY HIREDAT SALAR
D E Y
101 SUNAINA MUMBAI 1998‐10‐15 90000
102 ANAMIKA DELHI 1994‐12‐24 80000
103 DEEPTI CHANDIGA 2001‐12‐21 82000
RG
104 MEENAKSHI DELHI 2002‐12‐25 78000
105 RICHA MUMBAI 1996‐01‐12 95000
106 MANIPRAB CHENNAI 2001‐12‐12 69000
HA

The Following program code is used to increase the salary of Trainer SUNAINA by 2000.

Note the following to establish connectivity between Python and MYSQL:


Username is root
Password is system
The table exists in a MYSQL database named Admin.

Write the following missing statements to complete the code:


Statement 1 – to form the cursor object
Statement 2 – to execute the command that inserts the record in the table Student.
Statement 3- to add the record permanently in the database

import mysql.connector as mydb


mycon = mydb.connect
(host = “localhost”,
user = “root”,
Page 6 of 9
passwd = “system”,
database = “Admin”)
cursor = _______________ #Statement 1
sql = “UPDATE TRAINER SET SALARY = SALARY + 2000
WHERE TNAME = ‘SUNAINA’”
cursor. _______________ #Statement 2
_______________ #Statement 3
mycon.close( )

OR
(a) Write the output of the following Python program code: 2
my_dict = {}
my_dict[(1,2,4)] = 8
my_dict[(4,2,1)] = 10
my_dict[(1,2)] = 12
sum = 0
for k in my_dict:
sum += my_dict[k]
print (sum)
print(my_dict)

(b) Consider the table 3


TABLE : GRADUATE
S.N NAME STIPEN SUBJECT AVERAG DI
O D E V
1 KARAN 400 PHYSICS 68 I
2 DIWAKA 450 COMP Sc 68 I
R
3 DIVYA 300 CHEMISTR 62 I
Y
4 REKHA 350 PHYSICS 63 I
5 ARJUN 500 MATHS 70 I
6 SABINA 400 CHEMISTR 55 II
Y
7 JOHN 250 PHYSICS 64 I
8 ROBERT 450 MATHS 68 I
9 RUBINA 500 COMP Sc 62 I
10 VIKAS 400 MATHS 57 II

The Following program code is used to view the details of the graduate whose subject is
PHYSICS.

Note the following to establish connectivity between Python and MYSQL:


Username is root
Password is system
The table exists in a MYSQL database named Admin.

Write the following missing statements to complete the code:


Statement 1 – to import the proper module
Statement 2 – to create the cursor object.
Statement 3- to Close the connection
Page 7 of 9
import ______________ as mydb #Statement 1
mycon = mydb.connect
(host = “localhost”,
user = “root”,
passwd = “system”,
database = “Admin”)
cursor = _________________ #Statement 2
sql = “SELECT * FROM GRADUATE WHERE SUBJECT = ‘PHYSICS’”
cursor. execute(sql)
mycon.commit ( )
___________________ #Statement 3
33 Sumit is a programmer who is working on a project that requires student data of a school to be 5
stored in a CSV file. Student data consists of roll no, name, class and section. He has written a
program to obtain the student data from user and write it to a CSV file. After getting errors in
the program he left five statements blank in the program as shown below. Help him to find the
answer of the following questions to find the correct code for missing statements.
#Incomplete Code
import_____ #Statement 1
fh = open(_____, _____, newline=‘ ’) #Statement 2
stuwriter = csv._____ #Statement 3
data = []
header = [‘ROLL_NO’, ‘NAME’, ‘CLASS’, ‘SECTION’]
data.append(header)

for i in range(5):
roll_no = int(input(“Enter Roll Number : ”))
name = input(“Enter Name : ”)
Class = input(“Class : ”)
section = input(“Enter Section : ”)
rec = [_____] #Statement 4
data.append(rec)
stuwriter. _____ (data) #Statement 5
fh.close()

(i) Identify the suitable code for blank space in line marked as Statement 1.
(ii) Identify the missing code for blank space in line marked as Statement 2.
(iii) Choose the function name (with argument) that should be used in the blank space of line
marked as Statement 3.
(iv) Identify the suitable code for blank space in line marked as Statement 4.
(v) Choose the function name that should be used in the blank space of line marked as
Statement 5 to create the desired CSV file?

OR

What are the advantages of binary file over text file? Write a Python program in Python to
search the details of the employees (name, designation and salary) whose salary is greater than
5000. The records are stored in the file emp.dat. consider each record in the file emp.dat as a
list containing name, designation and salary.

SECTION - E
34 Based on given table “DITERGENTS” answer following questions.
PID PName Price Category Manufacturer

Page 8 of 9
1 Nirma 40 Detergent Powder Nirma Group
2 Surf 80 Detergent Powder HL
3 Vim Bar 20 Disc washing Bar HL
4 Neem Face Wash 50 Face Wash Himalaya
a) Write SQL statement to display details of all the products not manufactured by HL. 1
b) Write SQL statement to display name of the detergent powder manufactured by HL. 1
c) Write SQL statement to display the name of the Product whose price is more than 0.5 2
hundred.

OR
c) Write SQL statement to display name of all such Product which start with letter ‘N’

35 Arun is a class XII student of computer science. The CCA in-charge of his school wants to 1+1+2
display the words form a text files which are less than 4 characters. With the help of his
computer teacher Arun has developed a method/function FindWords() for him in python
which read lines from a text file Thoughts. TXT, and display those words, which are lesser
than 4 characters. His teachers kept few blanks in between the code and asked him to fill the
blanks so that the code will run to find desired result. Do the needful with the following
python code.

def FindWords():
c=0
file=open(‘NewsLetter.TXT’, ‘_____’) #Statement-1
line = file._____ #Statement-2
word = _____ #Statement-3
for c in word:
if _____: #Statement-4
print(c)
_________ #Statement-5
FindWords()

(i) Write mode of opening the file in statement-1?


(ii) Fill in the blank in statement-2 to read the data from the file.
(iii) Fill in the blank in statement-3 to read data word by word
(iv) Fill in the blank in statement-4, which display the word having lesser than 4 characters

OR (Only for iii and iv above)


(v) Fill in the blank in Statement-5 to close the file.
(vi) Which method of text file will read only one line of the file?

Page 9 of 9
KENDRIYA VIDYALAYA SANGATHAN
RANCHI RAGION
FIRST PREBOARD EXAMINATION
COMPUTER SCIENCE (083)
CLASS XII
MAX MARKS-70 TIME: 3 hrs
MARKING ACHEME
General Instructions:
1. This question paper contains five sections, Section A to E.
2. All questions are compulsory.
3. Section A have 18 questions carrying 01 mark each.
4. Section B has 07 Very Short Answer type questions carrying 02 marks each.
5. Section C has 05 Short Answer type questions carrying 03 marks each.
6. Section D has 03 Long Answer type questions carrying 05 marks each.
7. Section E has 02 questions carrying 04 marks each. One internal choice is given in Q35 against part c
only.
8. All programming questions are to be answered using Python Language only.

SECTION A
1 Identify the invalid Python statement from the following. 1
(a) _b=1 (b) __b1= 1 (c) b_=1 (d) 1 = _b

Ans – (d) 1 = _b
2 Identify the valid arithmetic operator in Python from the following. 1
(a) // (b) < (c) or (d) <>

Ans – (a) // floor division


3 If Statement in Python is __ 1
(a) looping statement (b) selection statement (c) iterative (d) sequential

Ans – (b) selection statement


4 Predict the correct output of the following Python statement – 1
print(4 + 3**3/2)

(a) 8 (b) 9 (c) 8.0 (d) 17.5

Ans – (d) 17.5


5 Choose the most correct statement among the following – 1

(a) a dictionary is a sequential set of elements


(b) a dictionary is a set of key-value pairs
(c) a dictionary is a sequential collection of elements key-value pairs
(d) a dictionary is a non-sequential collection of elements

Ans – (b) a dictionary is a set of key-value pairs


6 Consider the string state = “Jharkhand”. Identify the appropriate statement that will display the last 1
five characters of the string state?

(a) state [-5:] (b) state [4:] (c) state [:4] (d) state [:-4]

Ans – (a) state [-5:]


7 What will be the output of the following lines of Python code? 1
Page 1 of 13
if not False:
print(10)
else:
print(20)

(a) 10 (b) 20 (c) True (d) False

Ans – (a) 10
8 Consider the Python statement: f.seek(10, 1) 1
Choose the correct statement from the following:

(a) file pointer will move 10 byte in forward direction from beginning of the file
(b) file pointer will move 10 byte in forward direction from end of the file
(c) file pointer will move 10 byte in forward direction from current location
(d) file pointer will move 10 byte in backward direction from current location

Ans: (c) file pointer will move 10 byte in forward direction from current location
9 Which of the following function returns a list datatype? 1

a) d=f.read() b) d=f.read(10) c) d=f.readline() d) d=f.readlines()

Ans: d) d=f.readlines()
10 Identify the device on the network which is responsible for forwarding data from one device to 1
another

(a) NIC (b) Router (c) RJ45 (d) Repeater

Ans: (b) Router


11 A table has initially 5 columns and 8 rows. Consider the following sequence of operations 1
performed on the table –
i. 8 rows are added
ii. 2 columns are added
iii. 3 rows are deleted
iv. 1 column is added
What will be the cardinality and degree of the table at the end of above operations?

(a) 13,8 (b) 8, 13 (c) 14,5 (d) 5,8

Ans: (a) 13,8


12 Which of the following constraint is used to prevent a duplicate value in a record? 1

(a) Empty (b) check (c) primary key (d) unique

Ans: (d) unique


13 The structure of the table/relation can be displayed using __________ command. 1

(a) view (b) describe (c) show (d) select

Ans: (b) describe


14 Which of the following clause is used to remove the duplicating rows from a select statement? 1

(a) or (b) distinct (c) any (d)unique


Page 2 of 13
Ans: (b) distinct
15 How do you change the file position to an offset value from the start? 1
(a) fp.seek(offset, 0) (b) fp.seek(offset, 1) (c) fp.seek(offset, 2) (d) None of them
Ans: (a) fp.seek(offset, 0)

16 Which of the following method is used to create a connection between the MySQL database and 1
Python?

(a) connector ( ) (b) connect ( ) (c) con ( ) (d) cont ( )

Ans: (b) connect ( )


Q17 and 18 are ASSERTION AND REASONING based questions. Mark the correct choice as
(a) Both A and R are true and R is the correct explanation for A
(b) Both A and R are true and R is not the correct explanation for A
(c) A is True but R is False
(d) A is false but R is True
17 Assertion (A): The function definition calculate(a, b, c=1,d) will give error. 1
Reason (R): All the non-default arguments must precede the default arguments.

Ans: (a) Both A and R are true and R is the correct explanation for A
18 Assertion (A): CSV files are used to store the data generated by various social media platforms. 1
Reason (R): CSV file can be opened with MS Excel.

Ans: (b) Both A and R are true and R is not the correct explanation for A
SECTION - B
19 Find error in the following code(if any) and correct code by rewriting code and underline the 2
correction;‐

x= int(“Enter value of x:”)


for in range [0,10]:
if x=y
print( x + y)
else:
print( x‐y)

Ans . Correct code:‐


x= int(input(“Enter value of x:”))
for in range (0,10):
if x==y:
print( x+y)
else:
print (x‐y)

½ mark for each correction


20 (a) 2
Find output generated by the following code:

Str = "Computer"
Str = Str[-4:]
print(Str*2)

Ans:
Page 3 of 13
uteruter
OR
Consider the following lines of codes in Python and write the appropriate output:

student = {'rollno':1001, 'name':'Akshay', 'age':17}


student['name']= “Abhay”
print(student)

Ans:
{'rollno': 1001, 'name': 'Abhay', 'age': 17}
21 What do you mean by Foreign key? How it is related with Referential Integrity? 2

Ans:
A foreign key is a non-key attribute whose value is derived from the primary key of another table.
The relationship between two tables is established with the help of foreign key. Referential integrity
is implemented on foreign key.

1 mark for explanation and 1 mark for relation with referential integrity.
22 Find output generated by the following code: 2
string="aabbcc"
count=3
while True:
if string[0]=='a':
string=string[2:]
elif string[-1]=='b':
string=string[:2]
else:
count+=1
break
print(string)
print(count)

Ans:
bbcc
4
23 Expand the following terms: 2
i. NIC
ii. TCP/IP
iii. POP
iv. SMTP

Ans:
i. Network Interface Card
ii. Transmission Control Protocol/ Internet Protocol
iii. Post Office Protocol
iv. Simple Mail Transfer Protocol
½ mark for each expansion
24 Write one advantage and one disadvantage of each – STAR Topology and Tree Topology 2

½ marks for each advantage and disadvantage

OR

Page 4 of 13
What do you mean by Guided Media? Name any three guided media?

Ans –
Guided media – Physical Connection – ½ mark

Twisted pair cable, Co-axial cable, Fiber-optic cable)

½ mark for each name


25 Differentiate between DDL and DML? 2

Ans:
Data Definition Language (DDL): This is a category of SQL commands. All the commands which
are used to create, destroy, or restructure databases and tables come under this category. Examples
of DDL commands are ‐ CREATE, DROP, ALTER.
Data Manipulation Language (DML): This is a category of SQL commands. All the commands
which are used to manipulate data within tables come under this category. Examples of DML
commands are ‐ INSERT, UPDATE, DELETE.

OR

Write the main difference between INSERT and UPDATE Commands in SQL

Ans:
INSERT used to insert data into a table.
UPDATE used to update existing data within a table.

SECTION - C
26 Write definition of a method/function AddOdd(VALUES) to display sum of odd values from the 3
list of VALUES

Ans:
def AddOdd(Values):
n=len(NUMBERS)
s=0
for i in range(n):
if (i%2!=0):
s=s+NUMBERS[i]
print(s)

(2 Marks for Logic 1 mark for function definition)


27 Define a function SHOWWORD () in python to read lines from a text file STORY.TXT, and 3
display those words, whose length is less than 5.

Ans:
def SHOWWORD () :
c=0
file=open(‘STORY.TXT,'r')
line = file.read()
word = line.split()
for w in word:
if len(w)<5:
print( w)
file.close()

Page 5 of 13
(½ Mark for opening the file)
(½ Mark for reading line and/or splitting)
(½ Mark for checking condition)
(½ Mark for printing word)

OR

Write a user defined function in python that displays the number of lines starting with 'H' in the file
para.txt

Ans:
def count H( ):
f = open (“para.txt” , “r” )
lines =0
l=f. readlines ()
for i in L:
if i [0]== ‘H’:
lines +=1
print (“No. of lines are: “ , lines)

(½ Mark for opening the file)


(½ Mark for reading line and/or splitting)
(½ Mark for checking condition)
(½ Mark for printing word)
28 Write the outputs of the SQL queries (a) to (c) based on the relation Furniture 3

No Itemname Type Dateofstock Price Discount


1 White lotus Double Bed 23/02/02 30000 25
2 Pink feather Baby Cot 20/01/02 7000 20
3 Dolphin Baby Cot 19/02/02 9500 20
4 Decent Office Table 01/01/02 25000 30
5 Comfort Zone Double Bed 12/01/02 25000 25
6 Donald Baby Cot 24/02/02 6500 15
7 Royal finish Office Table 20/02/02 18000 30
8 Royal tiger Sofa 22/02/02 31000 30
9 Econo sitting Sofa 13/12/01 9500 25
10 paradise Dining Table 19/02/02 11500 25
11 Wood Comfort Double Bed 23/03/03 25000 25
12 Old Fox Sofa 20/02/03 17000 20
13 Micky Baby Cot 21/02/03 7500 15

(a) SELECT Itemname FROM Furniture WHERE Type="Double Bed";


(b) SELECT MONTHNAME(Dateofstock) FROM Furniture WHERE Type="Sofa";
(c) SELECT Price*Discount FROM Furniture WHERE Dateofstock>31/12/02;

Ans:
(a) (b) (c)
Itemane MONTHNAME(Dateofstock) Price*DIscount
White lotus February 625000
Comfort Zone December 340000
Wood Comfort February 112500

(1 mark for correct Answer)


Page 6 of 13
29 Consider the following table GAMES 3

GCode GameName Number PrizeMoney ScheduleDate


101 Carom Board 2 5000 23‐Jan‐2004
102 Badminton 2 12000 12‐Dec‐2003
103 Table Tennis 4 8000 14‐Feb‐2004
105 Chess 2 9000 01‐Jan‐2004
108 Lawn Tennis 4 25000 19‐Mar‐2004
Write the output for the following queries :
(i) SELECT COUNT(DISTINCT Number) FROM GAMES;
(ii) SELECT MAX(ScheduleDate),MIN(ScheduleDate) FROM GAMES;
(iii) SELECT SUM(PrizeMoney) FROM GAMES;

Ans:

(i) 2
(ii) 19‐Mar‐2004 12‐Dec‐2003
(iii)59000

30 Write PushOn(Book) and Pop(Book) methods/functions in Python to add a new Book and delete a 3
Book from a list of Book titles, considering them to act as push and pop operations of the Stack data
structure.

Ans:
def PushOn(Book):
a=input(“enter book title :”)
Book.append(a)

def Pop(Book):
if (Book = =[ ]):
print(“Stack empty”)
else:
print(“Deleted element :”)
Book.pop()

OR

Mr.Ajay has created a list of elements. Help him to write a program in python with functions,
PushEl(element) and PopEl(element) to add a new element and delete an element from a List of
element Description, considering them to act as push and pop operations of the Stack data structure
. Push the element into the stack only when the element is divisible by 4.

For eg:if L=[2,5,6,8,24,32]


then stack content will be 32 24 8

Ans:
N=[12, 13, 34, 56, 21, 79, 98, 22, 35, 38]
def PUSHEl(S,N):
S.append(N)
def POPEl(S):
if S!=[]:
return S.pop()
else:
Page 7 of 13
return None
ST=[]
for k in N:
if k%4==0:
PUSH(ST,k)
while True:
if ST!=[]:
print(POP(ST),end=" ")
else: break

SECTION - D
31 India Tech Solutions (ITS) is a professional consultancy company. The company is planning 5
to set up their new offices in India with its hub at Hyderabad. As a network adviser, you have
to understand their requirement and suggest them the best available solutions. Their queries
are mentioned as (i) to (v) below.

Physical locations of the blocks of TTC

HR BLOCK MEETING BLOCK

FINANCE BLOCK

Block to block distance (in m)


Block (From) Block (To) Distance
HR Block MEETING 110
HR Block Finance 40
MEETING Finance 80
Expected number of computers
Block Computers
HR 25
Finance 120
MEETING 90

(i)Which will be the most appropriate block, where TTC should plan to install their server?
(ii) Draw a block to block cable layout to connect all the buildings in the most appropriate
manner for efficient communication.
(iii)What will be the best possible connectivity out of the following, you will suggest to
connect the new set up of offices in Bengalore with its London based office.
• Satellite Link
• lInfrared
• Ethernet
(iv)Which of the following device will be suggested by you to connect each computer in each
of the buildings?
• l Switch
• l Modem
• l Gateway
(v) Company is planning to connect its offices in Hyderabad which is less than 1 km. Which
type of network will be formed?
Page 8 of 13
Ans:
(i) TTC should install its server in finance block as it is having maximum number of
computers.
(ii) Any suitable lyout
(iii) Satellite Link.
(iv) Switch.
(v) LAN

32 Find the output of the following: 2


(a)
fruit_list1 = ['Apple', 'Berry', 'Cherry', 'Papaya']
fruit_list2 = fruit_list1
fruit_list3 = fruit_list1[:]
fruit_list2[0] = 'Guava'
fruit_list3[1] = 'Kiwi'
sum = 0
for ls in (fruit_list1, fruit_list2, fruit_list3):
if ls[0] == 'Guava':
sum += 1
if ls[1] == 'Kiwi':
sum += 20
print (sum)

Ans. Output is:


22
(b) Consider the table 3
TRAINER
TID TNAME CITY HIREDATE SALARY
101 SUNAINA MUMBAI 1998‐10‐15 90000
102 ANAMIKA DELHI 1994‐12‐24 80000
103 DEEPTI CHANDIGARG 2001‐12‐21 82000
104 MEENAKSHI DELHI 2002‐12‐25 78000
105 RICHA MUMBAI 1996‐01‐12 95000
106 MANIPRABHA CHENNAI 2001‐12‐12 69000

The Following program code is used to increase the salary of Trainer SUNAINA by 2000.

Note the following to establish connectivity between Python and MYSQL:


Username is root
Password is system
The table exists in a MYSQL database named Admin.

Write the following missing statements to complete the code:


Statement 1 – to form the cursor object
Statement 2 – to execute the command that inserts the record in the table Student.
Statement 3- to add the record permanently in the database

import mysql.connector as mydb


mycon = mydb.connect
(host = “localhost”,
user = “root”,
passwd = “system”,
Page 9 of 13
database = “Admin”)
cursor = _______________ #Statement 1
sql = “UPDATE TRAINER SET SALARY = SALARY + 2000
WHERE TNAME = ‘SUNAINA’”
cursor. _______________ #Statement 2
_______________ #Statement 3
mycon.close( )

Ans:
Statement 1 – mycon.cursor ( )
Statement 2 – execute(sql).
Statement 3- mycon.commit ( )
OR
(a) Write the output of the following Python program code: 2
my_dict = {}
my_dict[(1,2,4)] = 8
my_dict[(4,2,1)] = 10
my_dict[(1,2)] = 12
sum = 0
for k in my_dict:
sum += my_dict[k]
print (sum)
print(my_dict)

Ans. Output is:


30
{(1, 2, 4): 8, (4, 2, 1): 10, (1, 2): 12}
(b) Consider the table 3
TABLE : GRADUATE
S.NO NAME STIPEND SUBJECT AVERAGE DIV

1 KARAN 400 PHYSICS 68 I


2 DIWAKAR 450 COMP Sc 68 I
3 DIVYA 300 CHEMISTRY 62 I
4 REKHA 350 PHYSICS 63 I
5 ARJUN 500 MATHS 70 I
6 SABINA 400 CHEMISTRY 55 II
7 JOHN 250 PHYSICS 64 I
8 ROBERT 450 MATHS 68 I
9 RUBINA 500 COMP Sc 62 I
10 VIKAS 400 MATHS 57 II

The Following program code is used to view the details of the graduate whose subject is
PHYSICS.

Note the following to establish connectivity between Python and MYSQL:


Username is root
Password is system
The table exists in a MYSQL database named Admin.

Write the following missing statements to complete the code:


Statement 1 – to import the proper module
Page 10 of 13
Statement 2 – to create the cursor object.
Statement 3- to Close the connection

import ______________ as mydb #Statement 1


mycon = mydb.connect
(host = “localhost”,
user = “root”,
passwd = “system”,
database = “Admin”)
cursor = _________________ #Statement 2
sql = “SELECT * FROM GRADUATE WHERE SUBJECT = ‘PHYSICS’”
cursor. execute(sql)
mycon.commit ( )
___________________ #Statement 3

Ans:
Statement 1 – mysql.connector
Statement 2 –. mycon.cursor ( )
Statement 3- mycon.close( )
33 Sumit is a programmer who is working on a project that requires student data of a school to be 5
stored in a CSV file. Student data consists of roll no, name, class and section. He has written a
program to obtain the student data from user and write it to a CSV file. After getting errors in
the program he left five statements blank in the program as shown below. Help him to find the
answer of the following questions to find the correct code for missing statements.

#Incomplete Code
import_____ #Statement 1
fh = open(_____, _____, newline=‘ ’) #Statement 2
stuwriter = csv._____ #Statement 3
data = []
header = [‘ROLL_NO’, ‘NAME’, ‘CLASS’, ‘SECTION’]
data.append(header)

for i in range(5):
roll_no = int(input(“Enter Roll Number : ”))
name = input(“Enter Name : ”)
Class = input(“Class : ”)
section = input(“Enter Section : ”)
rec = [_____] #Statement 4
data.append(rec)
stuwriter. _____ (data) #Statement 5
fh.close()

(i) Identify the suitable code for blank space in line marked as Statement 1.
(ii) Identify the missing code for blank space in line marked as Statement 2.
(iii) Choose the function name (with argument) that should be used in the blank space of line
marked as Statement 3.
(iv) Identify the suitable code for blank space in line marked as Statement 4.
(v) Choose the function name that should be used in the blank space of line marked as
Statement 5 to create the desired CSV file?

Ans.
(i) csv
(ii) “Student.csv”,“w”
Page 11 of 13
(iii) writer(fh)
(iv) roll_no,name,Class,section
(v) writerows()

OR

What are the advantages of binary file over text file? Write a Python program in Python to
search the details of the employees (name, designation and salary) whose salary is greater than
5000. The records are stored in the file emp.dat. consider each record in the file emp.dat as a
list containing name, designation and salary.

Ans.
In binary file, there is no terminator for a line and the data is stored after converting it into
machine understandable binary language. A binary file stores the data in the same way as
stored in the memory. Like text file we can’t read a binary file using a text editor.
----------------- 2 marks (any suitable difference)

import pickle as p
L=[]
with open(‘emp.dat’,’rb’) as f:
L=p.load(f)
for r in L:
if r[2]>5000:
print(“name=”,r[0])
print(“designation=”,r[1])
print(“salary=”,r[2])
----------------3 marks (any suitable code)
SECTION - E
34 Based on given table “DITERGENTS” answer following questions.
PID PName Price Category Manufacturer
1 Nirma 40 Detergent Powder Nirma Group
2 Surf 80 Detergent Powder HL
3 Vim Bar 20 Disc washing Bar HL
4 Neem Face Wash 50 Face Wash Himalaya
a) Write SQL statement to display details of all the products not manufactured by HL. 1
b) Write SQL statement to display name of the detergent powder manufactured by HL. 1
c) Write SQL statement to display the name of the Product whose price is more than 0.5 2
hundred.

OR
c) Write SQL statement to display name of all such Product which start with letter
‘N’

Ans:

a) Select * from DITERGENTS where manufacturer = ‘HL’;


b) Select Pname from DITERGENTS where manufacturer != ‘HL’;
c) Select Pname from DITERGENTS where price > price/100;

or
c) Select Pname from DITERGENTS where left(pname) = ‘N’;
Page 12 of 13
35 Arun is a class XII student of computer science. The CCA in-charge of his school wants to 1+1+2
display the words form a text files which are less than 4 characters. With the help of his
computer teacher Arun has developed a method/function FindWords() for him in python
which read lines from a text file Thoughts. TXT, and display those words, which are lesser
than 4 characters. His teachers kept few blanks in between the code and asked him to fill the
blanks so that the code will run to find desired result. Do the needful with the following
python code.

def FindWords():
c=0
file=open(‘NewsLetter.TXT’, ‘_____’) #Statement-1
line = file._____ #Statement-2
word = _____ #Statement-3
for c in word:
if _____: #Statement-4
print(c)
_________ #Statement-5
FindWords()

(i) Write mode of opening the file in statement-1?


(ii) Fill in the blank in statement-2 to read the data from the file.
(iii) Fill in the blank in statement-3 to read data word by word
(iv) Fill in the blank in statement-4, which display the word having lesser than 4 characters

OR (Only for iii and iv above)


(v) Fill in the blank in Statement-5 to close the file.
(vi) Which method of text file will read only one line of the file?

Ans:
(i) r
(ii) read()
(iii) line.split()
(iv) len(c)<4

OR (Only for iii and iv above)


(iii) file.close()
(iv) readline()

Page 13 of 13
Class XII

Computer Science (083)

Marking Scheme

Time Allowed: 3 hours MM: 70

Ques Question and Answers Distribution Total


No of Marks Marks

SECTION A
1 True 1 mark for 1
correct
answer

2 Option d 1 mark for 1


correct
delete answer

3 Option b 1 mark for 1


correct
18 answer

4 Option d 1 mark for 1


(‘BHASA’, ‘ ‘, ‘SANGAM@75’) correct
answer

5 Option b 1 mark for 1


correct
15,50 answer

6 Option a 1 mark for 1


correct
PAN answer

7 Option a 1 mark for 1


correct
r g b answer

8 Option b 1 mark for 1


2@tr correct
answer

[1]
9 Option b 1 mark for 1
correct
Statement 4 answer

10 Option b 1 mark for 1


correct
Wait#Stop# answer

11 Option b 1 mark for 1


correct
SMTP answer

12 Option a 1 mark for 1


correct
21 answer
7
13 True 1 mark for 1
correct
answer

14 Option b 1 mark for 1


correct
It is case sensitive answer

15 Packet 1 mark for 1


correct
answer

16 Option c 1 mark for 1


correct
seek() answer

17 Option a 1 mark for 1


Both A and R are true but R is the correct explanation for A correct
answer

[2]
18 Option a 1 mark for 1
correct
Both A and R are true but R is the correct explanation for A answer

SECTION B
19 (i) ½ mark for 1+1=2
each correct
SMTP – Simple Mail Transfer Protocol expansion

IMAP – Internet Message Access Protocol

(ii)
1 mark for
Active hubs amplify the incoming electric signal, whereas passive hubs any one
do not amplify the electric signal. (Any other valid difference may be
correct
considered)
difference

OR
(i) A network protocol is an established set of rules that determine 1 mark for
how data is transmitted between different devices in the same correct
network.
definition
(ii) Hub is an electronic device that connects several nodes to form
a network and redirect the received information to all the nodes 1 mark for
in a broadcast mode. Whereas Switch is an intelligent device
any one
that connects several nodes to form a network and redirect the
received information only to the intended node(s). correct
difference
(Any other valid difference may be considered)

20 def table (): ½ mark for 2


n=int (input ("Enter number which table U need: "))
each
for i in range (1,11):
print ("able of Enter no=",i* n) correction
table () made

[3]
21 ½ mark for 2
correct
SUBJECT={1:"Hindi",2:"Physics",3:"Chemistry",4:"CS",5:"MATH"}
function
def countMy (SUBJECT): header
for S in SUBJECT.values():
½ mark for
if len(S)>5:
correct loop
print(S.upper())
½ mark for
countMy()
correct if
statement

½ mark for
displaying
the output

OR
½ mark for
correct
def lenLines (STRING):
function
t=()
header
L=STRING.split()
for line in L: ½ mark for
using split()
length=len(line)
½ mark for
t=t+(length,)
adding to
return t
tuple

½ mark for
return
statement

Note: Any other correct logic may be marked


22 1½ mark for 2
(22, 44, 66)
each correct
digit
½ mark for
parenthesis

[4]
23 (i) L1.insert(1,100) 1 mark for 1+1=2
each correct
(ii) S1.isdigit() statement

OR
pop() function removes the last value and returns the same.

>>>L=[10,20,30,20] 1 mark for


correct
>>> L.pop () difference
and 1 mark
20 for suitable
The remove() method removes the first matching value from the list. example

>>>L.remove (20)

[10, 30, 20]

24 SQL Command to add primary key: 2 mark for 2


correct
select * from student where fee IS NULL Command

OR
1 mark for
DDL : CREATE, ALTER DROP each correct
DDL & DML
DML: INSERT UPDATE DELETE Categorized
commands

25 ½ mark for 2
-22 # 756 # -9 # 230 #
each correct
number and ½
mark for each
correct #
symbol
SECTION C
26 ['DelhiDelhi', 'JaipurJaipur', 'AgraAgra', 'SuratSurat', 'MumbaiMumbai', ½ mark for 3
'BhopalBhopal'] each correct
output

[5]
27 1*3=3
1 mark for
each
(a) (b) (c) correct
Item Name Dateofstock Type Sum(Price)
White lotus 13/12/2001 Double Bed 80000 output.
Comfort Zone 22/02/2002 Baby Cot 30500
Wood Comfort 20/02/2003 Office Table 43000
Sofa 57500
Dining Table 11500
28 def SHOWWORD () : (½ Mark for 3
c=0 opening the file)
file=open(‘STORY.TXT,'r') (½ Mark for
line = file.read() reading line
and/or splitting)
word = line.split()
(½ Mark for
for w in word: checking
if len(w)<5: condition)
print( w) (½ Mark for
file.close() printing word)

OR
def count H( ):
f = open (“para.txt” , “r” )
lines =0
L=f. readlines ()
for i in L:
if i [0]== ‘H’:
lines +=1
print (“No. of lines are: “ , lines)
29 (i) 1 mark for 1*3=3
each correct
UPDATE EMP
query
SET Salary=Salary + Salary*0.10
WHERE Allowance IS NOT NULL;

(ii) SELECT Name, Salary + Allowance AS


"Total Salary" FROM EMP;

(iii)
DELETE FROM EMP
WHERE Salary>40000;
[6]
30 N=[12, 13, 34, 56, 21, 79, 98, 22, 35, 38] 1½ marks for 3
def PUSHEl(S,N):
S.append(N)
each Push
def POPEl(S): and Pop
if S!=[]: operation
return S.pop()
else:
return None
ST=[]
for k in N:
if k%4==0:
PUSHEl(ST,k)
while True:
if ST!=[]:
print(POPEl(ST),end=" ")
else:
break

SECTION D
31 (i) 1 mark for 1*4=4
each correct
3
output

(ii)
1
1
2
(iii)
Dname Pname
PARESH Lal singh
MANISH Arjun
AKASH Narender
KUMAR Mehul
PARESH Naveen
MANISH Amit

(iv)
Manish

[7]
32 ½ mark for 4
import csv accepting
def createcsv(): data
f=open("result.csv","w", newline="")
correctly
w=csv.writer(f)
w.writerow([1,'Anil',40,34,90,""])
½ mark for
w.writerow([2,'Sohan',78,34,90,""])
w.writerow([3,'Kamal',40,45,9,""]) opening and
f.close() closing file

import csv ½ mark for


def copycsv(): writing
f=open("result.csv","r") headings
f1=open("final.csv","w",newline="")
w1=csv.writer(f1) ½ mark for
r=csv.reader(f)
for x in r: writing row
x[5]=int(x[2])+int(x[3])+int(x[4])
w1.writerow(x) ½ mark for
f.close() opening and
f1.close() closing file

½ mark for
reader object

½ mark for
print heading

½ mark for
printing data

SECTION E
33 (i) M/s Computer Solutions should install its server in finance block as it 1 Mark of 1*5=5
each correct
is having maximum number of computers. answer
(ii) Any suitable layout

(iii) Satellite Link.

(iv) Switch.

(v) LAN

[8]
34 (i) 1 mark for 2+3=5
rb+ Opens a file for both reading and writing in binary format. (+) the file each correct
pointer will be at the beginning of the file.
difference
wb+ Opens a file for both reading and writing in binary format. Overwrites ½ mark for
the existing file If the file exists. If the file does not exist, creates a new
file for reading or writing. correctly
opening and
(ii) def Readfile(): closing files
s=open( “Employee.dat” , “rb+”)
try:
while True:
r=pickle.load(s)
if r[2]>=20000 and r[2]<=30000:
print(r)
except: ½ mark for
print(“end of file”) correct loop

OR ½ mark for
correct split

1 mark for
correctly
(i) reading /
In pickle module, dump () method is used to convert (pickling) writing data
Python objects for writing data in a binary file
½ mark for
Whereas the load () function is used to read data from a binary printing
file or file object.
data
(ii)
import pickle as p
L=[]
with open(‘emp.dat’,’rb’) as f:
L=p.load(f)
for r in L:
if r[2]>5000:
print(“name=”,r[0])
print(“designation=”,r[1])
print(“salary=”,r[2])

Note: Any other correct logic may be marked

[9]
35 (i) A table can only have one primary key, but it can have multiple ½ mark for 1+4=5
candidate key in a database. (any suitable example) correct
definition

(ii) ½ mark for


import mysql.connector correct
mydb=mysql.connector.connect(host="localhost",user="root",passwd="admin",dat example
abase="SCHOOL")
mycursor=mydb.cursor()
while 1:
ch=int(input("enter -1 to exit / any other no to insert record into student table")) ½ mark for
if ch==-1: importing
break
correct
eno=int(input("Enter Employee no"))
ename=input("Enter Employee Name") module
edept=input("Enter dept name")
sal=int(input("Enter salary"))
mycursor.execute("insert into EMP values ('"+str(eno)+"','"+ ename+"','" +edept +
"','"+str(sal)+"')") 1 mark for
mydb.commit() correct
for x in mycursor:
print(x) connect()

OR ½ mark for
correctly
(i)
accepting the
Degree: The total number of attributes which in the relation is called the input
degree of the relation.
Cardinality: Total number of rows present in the Table. 1 ½ mark for
(any suitable example) correctly
displaying
(ii)
data

import mysql.connector
mydb=mysql.connector.connect(host="localhost",user="root",passwd="admin",databas
e="SCHOOL")
mycursor=mydb.cursor()
mycursor.execute("alter table emp add (bonus int(3))")
mycursor.execute("desc emp")

for x in mycursor:
print(x)

Note: Any other correct logic may be marked

[10]
के न्द्रीय विद्यालय संगठन , कोलकाता संभाग
KENDRIYA VIDYALAYA SANGATHAN, KOLKATA REGION
प्री-बोर्ड परीक्षा / PRE-BOARD EXAM. – 2023-24

कक्षा / CLASS – XII अविकतम अकं /MAX. MARKS – 70


विषय/SUB. - Computer Science(083) समय/TIME – 03 घंटे/Hours
MARKING SCHEME
Q. Question Marks
No
SECTION A
1 True 1 mark for correct answer 1
2 (C) alter 1 mark for correct answer 1
3 False 1 mark for correct answer 1
4 c) 2 1 mark for correct answer 1
5 b. Degree=5 , Cardinality=6 1 mark for correct answer 1
6 (c ) smtp and pop 1
7 c) Since “susan” is not a key in the set, Python raises a KeyError exception 1
1 mark for correct answer
8 d) False 1 mark for correct answer 1
9 d) Statement 4 1 mark for correct answer 1
10 ii) 10#30# 1 mark for correct answer 1
11 c )WAN 1 mark for correct answer 1
12 a) Nonlocal 1 mark for correct answer 1
13 c. Code that is designed to handle exception is executed 1
1 mark for correct answer
14 c) Primary Key 1 mark for correct answer 1
15 Repeater 1
16 c. ab 1 mark for correct answer 1
17 (a) Both A and R are true and R is the correct explanation for A [1 mark for correct answer] 1
18 (a) Both A and R are true and R is the correct explanation for A [1 mark for correct answer] 1
SECTION B
19 secure transmission refers to the transfer of data such as confidential or proprietary information over a 1+1=2
secure channel. Many secure transmission methods require a type of encryption.
Technical ways:
E-mail encryption. A number of vendors offer products that encrypt e-mail messages, are easy to use
and provide the ability to send private data, including e-mail attachments, securely. ...
Web site encryption. ...
Application encryption. ...
Remote user communication. ...
Laptops and PDAs. ...
Wireless networks.
[1 mark for definition and 1 mark for technical ways]
OR
Web Browser : A web browser is a software application for accessing information on the World Wide
Web. When a user requests a web page from a particular website, the web browser retrieves the
necessary content from a web server and then displays the page on the user's device. Web Server : A
web server is a computer that runs websites. The basic objective of the web server is to store, process
and deliver web pages to the users. This intercommunication is done using Hypertext Transfer Protocol
(HTTP).
Popular web browsers : Google Chrome, Mozilla Firefox, Internet Explorer etc
[ 1 marks for difference ½ Marks for eachcorrect Web browser Name]
20 def fn(a): 2
b=len(a)-1
for x in range(b):
for y in range (x):
if a[y]>a[y+1]:
a[y],a[y+1]=a[y+1],a[y]
return a
a=[32,5,3,6,7,54,87]
print (fn(a))
[1/2 mark for each correct answer]
21 def duplicate(a): 2
b =[]
for x in a:
if x not in b:
b.append(x)
print(b)
a=[]
n= int(input("Enter the number of elements in list:"))
for x in range(0,n):
element=int(input("Enter element" + str(x+1) + ":"))
a.append(element)
duplicate(a)
[ 1 Marks for correct function definition , 1 Marks for any correct logic]
OR
The terms parameter and argument can be used for the same thing: information that are
passed into a function.
From a function's perspective:
•A parameter is the variable listed inside the parentheses in the function definition.
•An argument is the value that are sent to the function when it is called.
Arguments are often shortened to args in Python documentations.
By default, a function must be called with the correct number of arguments. Meaning that if
your function expects 2 arguments, you have to call the function with 2 arguments, not more,
and not less.

def my_function(fname, lname): # Parameters


print(fname + " " + lname)

my_function(“KVS RO", “KOLKATA") #Arguments


[1/2 Marks for correct explanation ½ Marks for correct example of each Parameter and Argument]
22 (i) <class 'tuple'> 2
(ii) None
[1 Mark for each correct answer]
23 (i) The remove() method removes the first occurrence of the element with the specified value. 1+1=2
L1.remove(value)
(ii) The count() method returns the number of elements with the specified value.
L1.count(value)
[1 marks for each correct answer]
OR
student_gender=['B','G','B','G','G','B']
if student_gender.count('B')>student_gender.count('G'):
print("Boys are more in the class")
else:
print("Girls are more in the class")
[1 marks for correct use of count function+1 marks for proper use of if ]
24 Create table Library (Bid varchar(4) PRIMARY KEY, Name varchar(20), Author 2
varchar(20), Price int, Mem_name varchar(20), Issue_Date date, Status varchar(10));

Alter table Library modify Author varchar(25);


[ 1 mark for each correct answer]
OR
DDL: DROP TABLE, ALTER TABLE
DML: INSERT INTO, UPDATE...SET
[ ½ mark for each correct answer]
25 [76,56,9,78,45,34,4,20] [1/2 Mark for every correct placement of 2 values] 2
SECTION C
26 pYtHONn#3#9#6#bIT 3
[1 Mark for partial correct output]
[2 Marks for correct output without considering case]
[3 Marks for correct output]
27 i) 5 1X3=3
(1 mark for correct output)
(ii)9
(1 mark for correct output)
(iii) Error –As where is used with Group by , where is used after group by
(1 mark for correct answer)
28 def vowels(): 3
f=open('story2.txt','r')
s1=f.read()
c=0
l=['a','e','i','o','u']
for x in s1:
if x in l:
print(x)
c=c+1
print('Count of vowels in file',c)
vowels()
[1 Mark for correct syntax + 1 mark for correct logic + 1 marks for proper utilization of loop
and function ] Note – Logic of the program can differ
OR
def remove_lowercase(infile, outfile):
output=file(outfile,”w”)
for line in file(infile):
if not line[0] in “abcdefghijklmnopqrstuvwxyz”:
output.write(line)
output.close()
[1 Mark for correct syntax + 1 mark for correct logic + 1 marks for proper definition of
function] Note – Logic of the program can differ
29 (i)ECode 1X3=3
(ii)Delete from HRDATA where EName = “Jeevan”;
(iii)Update HRDATA set Remn = Remn + (0.1*Remn) ;
[1 mark for each correct answer]
30 Book={‘CS’:450, ‘IP’:550,’PhEdu’:1070,’Account’:360,’Bst’:600,’Physics’:1200, 3
‘Chemistry’:1400, ‘Biology’:900}
stack_book=[]
stack_price=[]
defPush_book():
for x,y in d.items():
if y>1000:
stack_book.append(x)
stack_price.append(y)
def Pop_book():
if len(stack_book)==0:
print(“underflow”)
else:
print(stack_book.pop()) print(stack_price.pop())
[1 mark for push+1 mark for pop+1 mark for correct logic and syntax]
SECTION D
31 (i) select bname, auname, price from books where bid like “comp%”; 1X4=4
(ii) update books set price = price + 50 where bid like “hist%”;
(iii) select * from books order by price;
(iv) select bid, bname, qty_issued from books, issued where books.bid =
issued.bid;
[1 mark for each correct SQL query )
32 file=open(‘India1.txt’,’rb’) 4
file.seek(10)
print(‘Current Position of the Cursor’,file.tell())
lines=file.read(7)
print(lines.decode())
print(‘Current Position of the Cursor’,file.tell())
file.seek(2,1)
print(‘Current Position of the Cursor’,file.tell())
lines=file.read(7)
print(lines.decode())
print(‘Current Position of the Cursor’,file.tell())
file.seek(-5,2)
print(‘Current Position of the Cursor’,file.tell())
lines=file.read(7)
print(lines.decode())
file.close()
[1/2 marks for each correct answer]
SECTION E
33 (i) Admin Block 1X5=5
(1 mark for correct answer)
(ii)

(1 mark for correct answer)


(iii) Modem or Switch or Router
(1 mark for correct answer)
(iv)Ethernet Cable
(1 mark for correct answer)
(v) Admin block ,as server is fixed due to maximum number of computers.
34 (i)Difference between r+ and w+ 2+3=5
Let's now discuss the key differences between r+ and w+ modes in Python:
1. Opening a file: r+ mode opens the file if it exists, while w+ mode also opens the file, but it deletes
all the content present in the file. The pointer in both cases is present at the start of the file.

2. Making a new file: If the file does not exist, r+ throws an exception error of 'filenotfound' while w+
creates a new empty file. No error message is thrown in w+ mode.

3. Reading a file: r+ helps in the complete reading of the file, while w+ doesn't allow the same. As
opening a file in w+ erases all the contents of the file, one can not read the content present inside
the file.

4. Writing a file: r+ overwrites the file with the new content from the beginning of the document,
while w+ deletes all the old content and then adds the new text to the file.

5. Error Message: r+ throws an exception or an error message if the file does not exist, while w+ does
not throw any error message; instead, it creates a new file.
[1 Mark for each correct difference , any 2 difference]
(ii)
f=open(“say_an.txt”,”r”)
for line in f:
words=line.split()
for i in words:
for letter in i:
if(letter.isdigit()):
print(letter)
f.close()
[1 Mark for logic+1 mark for syntax+1 mark for using file operation]
OR
(i) In text mode, Python automatically handles the encoding and decoding of the data,
depending on the platform's default encoding scheme. Binary files, on the other hand, are
files that contain non-text data, such as images, audio files, and executable files.
[2 Marks for correct explanation]
def COUNTLINES():
file=open('STORY.TXT','r')
lines = file.readlines()
count=0
for w in lines:
if w[0]==’M’ or w[0]==’m’:
count=count+1
print(“Total lines “,count)
file.close()
[1 Mark for logic+1 mark for syntax+1 mark for using file operation]
35 (a)CHAR is a fixed length datatype. 2+3=5
VARCHAR is a variable length datatype.
[2 marks for correct difference]

(b)
mysql.connector
con.cursor()
mycursor.fetchall()
[1 mark each for correct answer]

OR
(a) UNIQUE:- Ensure that all values in a column are different.
DEFAULT:- Provides a default value for a column when none is specified.
[2 marks for correct difference]
(b)
import mysql.connector
def insertrecord():
ans='y'
mydb=mysql.connector.connect(host="localhost",user="root",
passwd="kvs",database="project")
mycursor=mydb.cursor()
while(ans=='y'):
a=int(input("Enter the Roll Number:"))
b=input("Enter the Name:")
c=input("Enter the City:")
query1="insert into student(Rollno,Name,City)values(%s,%s,%s)"
val=(a,b,c)
mycursor.execute(query1,val)
for i in mycursor:
print(i)
mydb.commit()
ans=input("Do you want to insert another record:")
[ 1 Mark for connectivity +1 mark for insert +1 mark for loop]

You might also like