PDF&Rendition 1 1
PDF&Rendition 1 1
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)
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
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)
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
(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.
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
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
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
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
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)
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
(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
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)
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
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
Arun has been assigned the task to complete the code and print details of Roll Number 7.
MBA ADMIN
MBBS BTECH
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.
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
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 ,
(ii) SEARCH()- To display the records of the employees whose salary is more than 50000.
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
Q11. Ans: (a) When you open a file for reading, if the file does not exist, an error occurs. (1)
Q15. Ans: (d) SELECT MAX(SALARY) AND MEAN(SALARY) FROM EMPLOYEE; (1)
Q17. Ans: (b) Both A and R are true and R is not the correct explanation for A (1)
1
Page 1 of 11| KVS – Lucknow Region | Session 2023-24
Section – B
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:
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
Ans:
2
Page 2 of 11| KVS – Lucknow Region | Session 2023-24
Q21. Ans: Output will be as follows (1)
Q22. Degree: The number of attributes or columns in a relation is called the Degree of the relation. (2)
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)
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.
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.
Section – C
3
Page 3 of 11| KVS – Lucknow Region | Session 2023-24
Q26. (1)
(b) (2)
(i) Manager
Director
Clerk
Mumbai 175000
Kolkata 85000
Jack 85000
Harry 90000
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
for i in L:
if len(i) == 6:
count += 1
COUNT_W5()
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
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
REPALI 3000
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)
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
OR
(1 mark)
Section - E
(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..
Q34. (a) Ans: Comp.Sc.- 083#083 (1 mark for comp.sc. and 1 marks for rest) (5)
Statement2: mycursor.execute(query)
Statement3: con1.commit()
OR
(a) Ans: 9$8$25$27$ (1 mark for first 5 characters and 1 mark for next 5 characters)
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)
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()
Object=csv.reader(“filehandle”) ( ½ mark)
Object=csv.writer(“filehandle”)( ½ mark)
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()
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)
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
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)
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
(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.
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
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
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
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
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)
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
(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
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&LITUTE’
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
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
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).
ENT Unit 50
Radiology Unit 70
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.
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
(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
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)
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
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
Arun has been assigned the task to complete the code and print details of Roll Number 7.
MBA ADMIN
MBBS BTECH
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.
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
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 ,
(ii) SEARCH()- To display the records of the employees whose salary is more than 50000.
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
Q11. Ans: (a) When you open a file for reading, if the file does not exist, an error occurs. (1)
Q15. Ans: (d) SELECT MAX(SALARY) AND MEAN(SALARY) FROM EMPLOYEE; (1)
Q17. Ans: (b) Both A and R are true and R is not the correct explanation for A (1)
1
Page 1 of 11| KVS – Lucknow Region | Session 2023-24
Section – B
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:
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
Ans:
2
Page 2 of 11| KVS – Lucknow Region | Session 2023-24
Q21. Ans: Output will be as follows (1)
Q22. Degree: The number of attributes or columns in a relation is called the Degree of the relation. (2)
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)
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.
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.
Section – C
3
Page 3 of 11| KVS – Lucknow Region | Session 2023-24
Q26. (1)
(b) (2)
(i) Manager
Director
Clerk
Mumbai 175000
Kolkata 85000
Jack 85000
Harry 90000
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
for i in L:
if len(i) == 6:
count += 1
COUNT_W5()
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
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
REPALI 3000
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)
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
OR
(1 mark)
Section - E
(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..
Q34. (a) Ans: Comp.Sc.- 083#083 (1 mark for comp.sc. and 1 marks for rest) (5)
Statement2: mycursor.execute(query)
Statement3: con1.commit()
OR
(a) Ans: 9$8$25$27$ (1 mark for first 5 characters and 1 mark for next 5 characters)
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)
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()
Object=csv.reader(“filehandle”) ( ½ mark)
Object=csv.writer(“filehandle”)( ½ mark)
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()
11
Page 11 of 11| KVS – Lucknow Region | Session 2023-24
PB23CS01
SECTION - A
1 Which of the following is a keyword in Python?
a) true b) For c) pre-board d) False 1
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
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.
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 :
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”
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:
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
************************************
8
PB23CS01
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
print(20//3*2+(35//7.0))
1
a) 17.0 b) 17 c) 8.5 d) 8
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
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
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])
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
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 :
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
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()
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:
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 ;
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
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:
SENIOR 130
1 mark
JUNIOR 80 each
ADMIN 160
HOSTEL 50
ADMIN
SENIOR
JUNIOR HOSTEL
ii) Suggest the most suitable place (i.e., building) to house the server of
this college , provide a suitable reason.
10
iii) Is there a requirement of a repeater in the given cable layout? Why/
Why not?
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
12
ii) Maya has created a table named BOOKt in MYSQL database,
LIBRARY
MySQL:
Username - root
Password - writer
Host – localhost
13
KENDRIYA VIDYALAYA SANGTHAN, CHANDIGARH REGION
PRE-BOARD EXAMINATION - 2023-24
Class: XII
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.
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
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
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
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
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
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.
[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.
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
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:
(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.
[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.
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))
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.
Ans:
f=open(“abc.txt”,‟r‟)
s=f.read()
print(s.count(“are”))
f.close()
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
3 If Statement in Python is __ 1
(a) looping statement (b) selection statement (c) iterative (d) sequential
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]
if not False:
print(10)
else:
print(20)
Page 1 of 9
(a) 10 (b) 20 (c) True (d) False
(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
10 Identify the device on the network which is responsible for forwarding data from one device to 1
another
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?
14 Which of the following clause is used to remove the duplicating rows from a select statement? 1
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;‐
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:
21 What do you mean by Foreign key? How it is related with Referential Integrity? 2
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?
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
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.
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.
FINANCE BLOCK
(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?
The Following program code is used to increase the salary of Trainer SUNAINA by 2000.
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)
The Following program code is used to view the details of the graduate whose subject is
PHYSICS.
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()
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) <>
(a) state [-5:] (b) state [4:] (c) state [:4] (d) state [:-4]
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
Ans: d) d=f.readlines()
10 Identify the device on the network which is responsible for forwarding data from one device to 1
another
16 Which of the following method is used to create a connection between the MySQL database and 1
Python?
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;‐
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:
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
OR
Page 4 of 13
What do you mean by Guided Media? Name any three guided media?
Ans –
Guided media – Physical Connection – ½ mark
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)
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)
Ans:
(a) (b) (c)
Itemane MONTHNAME(Dateofstock) Price*DIscount
White lotus February 625000
Comfort Zone December 340000
Wood Comfort February 112500
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.
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.
FINANCE BLOCK
(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
The Following program code is used to increase the salary of Trainer SUNAINA by 2000.
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)
The Following program code is used to view the details of the graduate whose subject is
PHYSICS.
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:
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()
Ans:
(i) r
(ii) read()
(iii) line.split()
(iv) len(c)<4
Page 13 of 13
Class XII
Marking Scheme
SECTION A
1 True 1 mark for 1
correct
answer
[1]
9 Option b 1 mark for 1
correct
Statement 4 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
(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)
[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
[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.remove (20)
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;
(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
½ 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
(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])
[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
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)
[10]
के न्द्रीय विद्यालय संगठन , कोलकाता संभाग
KENDRIYA VIDYALAYA SANGATHAN, KOLKATA REGION
प्री-बोर्ड परीक्षा / PRE-BOARD EXAM. – 2023-24
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]