0% found this document useful (0 votes)
391 views

Chennai region QP with MS

Uploaded by

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

Chennai region QP with MS

Uploaded by

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

KENDRIYA VIDYALAYA SANGATHAN , CHENNAI REGION ANSWER KEY

PRE-BOARD-I EXAMINATION 2023-2024


CLASS XII-COMPUTER SCIENCE (083)
12COM03QP
Time Allowed: 3 Hours Maximum Marks: 70
General Instructions:
1. The Question paper contain 35 questions.
2. The paper is divided into 5 sections – A, B, C, D and E.
3. Section A – 18 Questions (1-18), Each question of 1 mark.
4. Section B – 7 Questions (19-25), Each question of 2 marks.
5. Section C – 5 Questions (26-30), Each question of 3 marks.
6. Section D – 2 Questions (31-32), Each question of 5 marks.
7. Section E – 3 Questions (33-35), Each question of 4 marks.
8. All programming questions are to be answered using Python language only.
9. There is no internal choice in this question paper. However internal choices are given in
four questions in SECTION-B (Q22, Q23, Q24 and Q25), one question in SECTION-C (Q27)
and two questions in SECTION-E (Q34 and Q35). A student has to attempt only one of the
alternatives in such questions.

SECTION A
1. Assign a tuple containing an Integer? (1)
2. Which of the following data type in Python supports concatenation? (1)
a) int (b) float (c) bool (d) str
3. What will be output of the following code: (1)
d1={1:2,3:4,5:6}
d2=d1.popitem()
print(d2)
(a) {1:2} (b) {5:6} (c) (1,2) (d) (5,6)
4. The correct output of the given expression is: (1)
True and not False or False
(a) False (b) True (c) None (d) Null
5. Fill in the blank: (1)
Command is used to add a new column in a table in SQL.
(a) update (b) remove (c) alter (d) drop
6. Consider the Python statement: f.seek(10, 1) Choose the correct statement from (1)
the following:
(a) File pointer will move10 bytes in forward direction from beginning of the file.
(b) File pointer will move 10 bytes in forward direction from end of the file.
(c) File pointer will move 10 bytes in forward direction from current location.
(d) File pointer will move 10 bytes in backward direction from current location.
7. Choose the appropriate SQL Query that will delete a table (1)
emp without deleting its structure?
(a) DELETE TABLE;
(b) DROP TABLE emp;
(c) REMOVE TABL emp;
(d) DELETE FROM emp;
8. Which of the following is NOT a DML Command? (1)
(a)Insert (b)Update (c)Drop (d)Delete
9. Select the correct output to the code: a="Year2022atallthe best" a=a.split('a') (1)
b=a[0]+"-"+a[1]+"-"+a[3] print (b)
Year–0-atAllthebest
Ye-r2022-llthe best
Year–022-at Allthebest
Year–0-atallthebest
10. Which of the following statement(s) would give an error during execution?
S="Lucknow is the Capital of UP " #Statement1
print(S) #Statement2
S[4]='$’ #Statement3
S="Thankyou" #Statement4
S=S+"Thankyou" #Statement5
(a) Statement3 (b) Statement4 (c) Statement5 (d) Statement 4 and 5

11. Which of the following function returns a list datatype? (1)


a) d=f.read() b) d=f.read(10) c) d=f.readline() d) d=f.readlines()
12. 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.
13. Fill in the blank: (1)
The is a mail protocol used to retrieve mail from a remote server to a
local email client.
(a) VoIP (b) FTP (c) POP3 (d) HTTP
14. What will be the value of y when following expression be evaluated in Python? (1)
x=10.0
y=(x<100.0) and x>=10
print(y)
(a) 110 (b) False (c) Error (d) True
15. All aggregate functions except ignore null values in their input collection. (1)
(a) Count(attribute)
(b) Count(*)
(c) Avg()
(d) Sum()
16. Which of the following method is used to create a connection between the MySQL (1)
database and Python?
(a) connector() (b) connect() (c) con() (d) cont()

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
(c) A is True but R is False
(d) A is false but R is True
17. Assertion (A):-The default arguments can be skipped in the function call. (1)
Reason (R):-The function argument will take the default values even if the values
are supplied in the function call

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

SECTION B
19. Ravi has written a function to print Fibonacci series for first 10 element. His code is
having errors. Rewrite the correct code and underline the corrections made. Some (2)
initial elements of Fibonacci series are:

def fibonacci()
first=0
second=1
print((“first no. is “, first)
print(“secondno.is, second)
for a in range (1,9):
third=first+second
print(third)
first, second=second, third
fibonacci()

20. What possible output(s) are expected to be displayed on screen at the time of (2)
execution of the program from the following code? Also specify the maximum
values that can be assigned to each of the variables FROM and TO.

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

(i) 10#40#70# (ii) 30#40#50#60 (iii) 50#60#70# (iv) 40#50#70#


21. Given is a Python string declaration: (1)
myexam="RussiaUkrain"
Write the output of :
print(myexam[-2:2:-2])

Write the output of the code given below: (1)


D1={"sname":"Aman","age":26}
D1['age']=27
D1['address']="Delhi"
print(D1.items())
22. (a) Explain the use of ‘Foreign Key’ in a Relational Database. Give an example to (2)
support your answer.
OR
(b) Define Constrains in a relational database and give any two examples.
23. (a) Write the full forms of the following: (1)
(i) POP (ii)HTTPS (1)
OR
(b) Write two points of difference between Circuit Switching and Packet Switching
24. Predict the output of the Python code given below: (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
def Display(str):
m=""
for i in range(0,len(str)):
if(str[i].isupper()):
m=m+str[i].lower()
elif str[i].islower():
m=m+str[i].upper()
else:
if i%2==0:
m=m+str[i-1]
else:
m=m+"#"
print(m)
Display('[email protected]')

25. Consider the following two commands with reference to a table, named (2)
Students, having a column named Section:
Select count(Section)from Students;
Select count(*)from Students;
If these two commands are producing different results,
(i) What may be the possible reason?
(ii) Which command,(a)or(b),might be giving higher value?
OR
Name the aggregate functions which work only with numeric data, and those
that work with any type of data.
SECTION C
26. (a) Consider the following tables– EMPLOYEES AND DEPARTMENT (1)

What will be the output of the following statement?


SELECT ENAME, DNAME FROM EMPLOYEES,DEPARTMENT WHERE
EMPLOYEE.DNO=DEPARTMENT.DNO;
(b) Write the output of the queries: (i) to (iv) based on the tables given below:
(2)

(i) SELECT ITEM_NAME, MAX(PRICE), COUNT(*) FROM ITEM GROUP BY


ITEM_NAME;
(ii) SELECT CNAME,MANUFACTURER FROM ITEM,CUSTOMER WHERE
ITEM.ID=CUSTOMER.ID;
(iii) SELECT ITEM_NAME, PRICE*100 FROM ITEM WHERE
MANUFACTURER="ABC";
(iv) SELECT DISTINCT CITY FROM CUSTOMER;
27. Write a method SHOWLINES() in Python to read lines from text file
‘TESTFILE.TXT’ and display the lines which do not contain 'ke'.

Example: If the file content is as follows: An apple a day keeps the doctor
away. We all pray for everyone’s safety.
A marked difference will come in our country.

The SHOWLINES() function should display the output as:


We all pray for everyone’s safety. (3)
OR
Write a function in python to count the number of lines in a text file
‘Country.txt’ which are starting with an alphabet ‘W’ or ‘H’.
For example, If the file contents are as follows:
Whose woods these are I think I know.
His house is in the village though; He will not see me stopping here To
watch his woods fill up with snow.
The output of the function should be: W or w:1 H or h : 2

28. (a) Consider the following tables GAMES. Give outputs for SQL queries: (i) (2+
to (iv). 1)
Table: GAMES
GCode GameName Number PrizeMoney ScheduleDate
101 CaromBoard 2 5000 23-Jan-2004
102 Badminton 2 12000 12-Dec-2003
103 TableTennis 4 8000 14-Feb-2004
105 Chess 2 9000 01-Jan-2004
108 LawnTennis 4 25000 19-Mar-2004

(i) SELECT COUNT(DISTINCT Number) FROM GAMES;


(ii) SELECT MAX(ScheduleDate),MIN(ScheduleDate) FROM GAMES;
(iii) SELECT SUM(PrizeMoney) FROM GAMES;
(iv) SELECT * FROM GAMES WHERE PrizeMoney>12000;

(b)Write the command to view all the databases in an RDBMS.


29. Write a function in PythonConvert() to replaces elements having even (3)
values with its half and elements having odd values with twice its value in
a list.
eg: if the list contains [3,4,5,16,9] then rearrange the list as [6,2,10,8,18]
30. Write a function in Python, Push(KItem),where KItem is a dictionary (3)
containing the details of Kitchen items– {Item:price}.

The function should push the names of those items in a stack which have
price less than 100. Also display the count of elements pushed into the
stack.
For example: If the dictionary contains the following data:
{"Spoons":116,"Knife":50,"Plates":180,"Glass":60}

The stack should contain:


[Glass, Knife]
The output should be:
The count of item is 2.
SECTION D
31. Radha Shah is a programmer, who has recently been given a task to write 4
a python code to perform the following CSV file operations with the help
of two user defined functions/modules:
a. CSVOpen() : to create a CSV file called BOOKS.CSV in append mode
containing information of books – Title, Author and Price.
b. CSVRead() : to display the records from the CSV file called BOOKS.CSV
where the field title starts with 'R'.
She has succeeded in writing partial code and has missed out certain
statements, so she has left certain queries in comment lines.

You as an expert of Python have to provide the missing statements and


other related queries based on the following code of Radha.

(i) Write the appropriate mode in which the file is to be opened in append
mode (Statement 1)
(ii) Write the statement will be used to create a csv writer object in
Statement 2.
(iii) Fill the blank space of Statement 3 to write the names of the column
headings in the CSV file, BOOKS.CSV.
(iv) Which statement will be used to read a csv file in Statement 4?
OR (only for option (iv))
(iv) Fill in the appropriate statement to check the field Title starting with
‘R’ for Statement 5 in the above program.

32. A departmental store MyStore is considering maintaining their inventory 4


using SQL to store the data. As a database Administrator, Abhay has
decided that:
Name of the database–mystore
Name of the table –STORE
The attributes of STORE are as follows.
ItemNo –numeric
ItemName–character of size 20
Scode – numeric
Quantity– numeric
Table : STORE

ItemNo ItemName Scode Quantity


2005 SharpnerClassic 23 60
2003 BallPen0.25 22 50
2002 GelPenPremium 21` 150
2006 GelPenClassic 21 250
2001 Erasersmall 22 110
2004 EraserBig 22 220
2009 BallPen0.5 21 180

(a) Identify the attributes suitable to be declared as primary key


(b) Write the query to add the row with following details
(2010,”Notebook”,23,155)
(c) Abhay wants to remove the table STORE from the database MyStore,
Help Abhay in writing the command for removing the table STORE from
the database MyStore.
(d) Now Abhay wants to display the structure of the table STOREi.e.name
of the attributes and their respective data types that he has used in the
table. Write the query to display the same.
OR (Only for Option (d))
(d) (i) Abhay wants to ADD a new column price with data type as decimal.
Write the query to add the column.
(ii) Now Abhay wants to remove a column price from the table STORE.
Write the query.
SECTION E
33 A company ABC Enterprises has four blocks of buildings as shown:

Distance between various blocks/locations:


B3---B1 50M
B1---B2 60M
B2---B4 25M
B4---B3 170M
B3---B2 125M
B3---B4 90M

Number of computers:
BLOCK B1 150
BLOCK B2 15
BLOCK B3 15
BLOCK B4 25

(i) Suggest the most appropriate topology for the connection between
the blocks.
(ii) The company wants internet accessibility in all the blocks. The (1)
suitable and cost effective technology for that would be?
(iii) Which devices will you suggest for connecting all the computers with (1)
in each of the blocks.
(iv) The company is planning to link its head office situated in New Delhi (1)
with the offices in hilly areas. Suggest a way to connect it economically.
(v) Suggest the most appropriate location of the server, to get the best
connectivity for maximum number of computers. (1)

(1)
34 (a) (i) Define the term Primary Key with respect to RDBMS. Give one example (2)
to support your answer.
(ii) The code given below reads records from the table named student and
displays only those records who have marks greater than 75.The structure of (3)
a record of table Student is:
Roll No–integer; Name –string; Class –integer; Marks– integer.
Note the following to establish connectivity between Python and MYSQL:
(i) Username is root.
(ii) Password is abc.
(iii) The table exists in a MYSQL database named school.
(iv) The details (Roll No, Name ,Class and Marks) are to be accepted from the
user.
Write the following missing statements to complete the code:
Statement 1 – to create the cursor object.
Statement 2 – to execute the query that extracts records of those students
whose marks are greater than 75.
Statement 3 – to read the complete result of the query(records whose marks
are greater than 75) into the object named data, from the table student in
the database.

OR
(b) (i) MySQL supports different character sets, which command is used to
display all the character stes?
(ii) Consider the tables Product and Client with structures as follows:
Product Client
P_ID C_ID
ProductName CName
Manufacturer CCity
Price CProd
Write Python codes to display the details of products whose price is in the
range 50 to 100 (Both included). Use the following information for
connection.
Host: localhost
Database: cosmetics
Password: admin@123
Table name: Product
35. (a) (i) Write one similarity and one difference between a+ and w+ access (2+
modes? 3)
(ii) A binary file “emp.dat” has structure (EID, Ename, designation, salary)
Write a function Show() in Python that would read the details of employees
from the file “emp.dat” and display the details of those employees whose
designation is
“Manager”
OR
(b) (i) What is the difference between readline() and readlines() ?
(ii) A binary file “Book.dat” has structure [BookNo, Book_Name, Author,
Price]. Write a function CountRec(Author) in Python which accepts the
Author name as parameter and count and return number of books written by
the given Author?

****END****
KENDRIYA VIDYALAYA SANGATHAN , CHENNAI REGION ANSWER KEY
PRE-BOARD-I EXAMINATION 2023-2024
CLASS XII-COMPUTER SCIENCE (083) 12COM03MS
Time Allowed: 3 Hours Maximum Marks: 70
General Instructions:
1. The Question paper contain 35 questions.
2. The paper is divided into 5 sections – A, B, C, D and E.
3. Section A – 18 Questions (1-18), Each question of 1 mark.
4. Section B – 7 Questions (19-25), Each question of 2 marks.
5. Section C – 5 Questions (26-30), Each question of 3 marks.
6. Section D – 2 Questions (31-32), Each question of 5 marks.
7. Section E – 3 Questions (33-35), Each question of 4 marks.
8. All programming questions are to be answered using Python language only.
9. There is no internal choice in this question paper. However internal choices are
given in four questions in SECTION-B (Q22, Q23, Q24 and Q25), one question in
SECTION-C (Q27) and two questions in SECTION-E (Q34 and Q35). A student has to
attempt only one of the alternatives in such questions.

Q.No. Expected Answers/Outcomes from Student Marks


SECTION-A
1 (10,) or any other relevant example 1
2 d) str 1
3 d) (5,6) 1
4 b) True 1
5 c) alter 1
6 c) File pointer will move 10 bytes in forward direction from 1
current location
7 d) DELETE FROM emp; 1
8 c) Drop 1
9 d) Year–0-atallthebest 1
10 a) Statement3 1
11 d) d=f.readlines() 1
12 a) Aggregate functions ignore NULL 1
13 c) POP3 1
14 d) True 1
15 b) Count(*) 1
16 a) connector() 1
Q17 and 18 are ASSERTION AND REASONING based Questions.
Read the following statements carefully and mark the correct
choice as per the codes (a), (b), (c) or (d) given below:

(a) Both (A) and (R) are True and (R) is the correct explanation of
(A).
(b) Both (A) and (R) are True, but (R) in not the correct
explanation of (A).
(c) (A) is True, but (R) is False.
(d) (A) is False, but (R) is True.
17 (a) Both (A) and (R) are True and (R) is the correct explanation of 1
(A).
18 (d) (A) is False, but (R) is True. 1
SECTION-B
19 Corrected Code with reasons: 2
def fibonacci(): #Missing Colon
first=0
second=1
print("first no. is", first)
print("second no. is", second)
for a in range (1,9):
third=first+second
print(third) #Intendation Error
first,second=second,third #Indentation Error
fibonacci() #Wrong calling of function
20 (ii) 30#40#50#60# only 2
21 (a) irUi (With Proper box drawing and showing the string 2
slicing method to get the desired output)
(b) dict_items([('sname', 'Aman'), ('age', 27), ('address', 'Delhi')])
22 (a) Use of foreign key: it is a non-key attribute whose value is 2
derived from the primary key of another table.
Example: Refer textbook page no.7.11
OR
(b) Constrains are some set of rules created to apply data
validations. Examples: Primary key and NOT NULL.
23 (a) (i) Post Office Protocol
(ii) Hyper Text Markup Language
OR
(b) Refer textbook for proper differences (page no.6.51)
24 50#5 2
OR
fUN#wORLD#2#
25 (i) (a) count(Section) means that count() is only counting records 2
from the column Section whereas count(*) means that count() is
counting all records from the table Students.
(ii) (b) will give higher value as count(*) counts all records.
OR
Sum(), Min(), Max() and Avg() (Any two)
SECTION-C
26 a)Empty Set 3

b) (i)

(ii)

(iii)

(iv)
27 (a) Expected code: 3
def showlines():
f=open("Testfile.txt","r")
lines=f.readlines()
for l in lines:
if l.lower() not in "ke":
print(l)
f.close()
showlines()
OR
(b) Expected code:
def count_H_W():
f=open("Country.txt","r")
s=f.read()
c=0
for ch in s:
if (ch[0]).upper()=="W" or (ch[0]).upper()=="H":
c+=1
print("The lnes starting with an alphabet "W" or "H" is:", c)
f.close()
count_H_W()
28 (i) 3
COUNT(DISTINCT Number)
2
(ii)
MAX(ScheduleDate) MIN(ScheduleDate)
19-Mar-2004 12-Dec-2003
(iii)
SUM(PrizeMoney)
59000
(iv)
GCode GameName Number PrizeMoney ScheduleDate
108 LawnsTennis 4 25000 19-Mar-2004
29 def odd_even(): 3
for element in num_list:
if element == 0:
break
elif element % 2 == 0:
num_list[num_list.index(element)] = element/2
elif element % 2 != 0:
num_list[num_list.index(element)] = 1
print("\nModified list:", num_list)
odd_even()
30 StackItem=[] 3
def Push(KItem):
c=0
for k in KItem:
if (KItem[k])<100:
StackItem.append(k)
c+=1
print(c)
print(StackItem)
KItem = {"Spoons": 116, "Knife": 50, "Plates": 180, "Glass": 60}

Push(KItem)
SECTION-D
31 (i) a 4
(ii) csv.writer(csvf)
(iii) cw.writerow(['Title', 'Author', 'Price'])
(iv) csv.reader(csvf)
OR (only for option (iv))
(iv) r[0][0]==”R”
32 (a) ItemNo 4
(b) Insert inti STORE values(2010, ”Notebook”, 23, 155);
(c) Drop Table STORE;
(d) Desc STORE;
OR
(d) (i) ALTER Table STORE ADD Price Decimal;
(ii) ALTER Table STORE REMOVE Price;
SECTION-E
33 (i) Best Topology-Star 5
(ii) Broadband
(iii) Switch
(iv) To Connect the head office in Hilly Region, the company can
use Radio waves
(v) BLOCK B1- as there are maximum number of computers in that
particular block
34 (a) (i) A primary key is a set of one or more attributes/fields which 5
uniquely identifies arow in a table. For Example: Refer Textbook
page.no: 7.10.
(ii) #Staement1- con1.cursor()
#Statement2- con1.execute(“Select Marks from Student where
Marks>75;”)
#Statement3- con1.fetchall()
OR
(b) (i) SHOW CHARACTER SET;
35 (a) (i) Similarity b/w a+ and w+ access modes: 5
If the file does not exist it creates a new file for reading and
writing.
Difference b/w a+ and w+ access modes:
w+ - Opens a file for both writing and reading.
a+ - Opens the file for both appending and reading.
(ii) Expected code: (Note: All 4 and 5 Mark Programs should be
Menu-Driven)
import pickle
def Show():
f=open("emp.dat","rb")
while True:
try:
erec=pickle.load(f)
print(erec)
except EOFError:
f.close()
break
def display_desig():
f=open("emp.dat","rb")
rec=[]
sdept=input("Enter department of record to search for:")
found=0
while True:
try:
rec=pickle.load(f)
if rec[2].lower()==sdept.lower() and rec[2]=='Manager':
print(rec)
print()
found=1
except EOFError:
f.close()
if found==0:
print("Record not found")
print()
break
#Main
while True:
ch=int(input("Enter choice:"))
if ch==1:
Show()
elif ch==2:
display_desig()
elif ch==3:
break
OR
(b) (i) Readline()- Reads only one line from a file and returns a list.
Readlines()- Reads all the lines from a file and returns a list of
substrings.
(ii) Expected Code:
import pickle
def countrec(Aurthor):
f=open("Book.dat","rb")
saurthor=input("Enter aurthor you want to find:")
c=0
while True:
try:
rec=pickle.load(f)
if rec[2].lower()==saurthor.lower():
c+=1
found=1
except EOFError:
f.close()
if found==0:
print("There is no aurthor")
elif found==0:
return c
break
countrec(Aurthor)

****END****

You might also like