Chennai region QP with MS
Chennai region QP with MS
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
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=” #“ )
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)
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.
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
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}
(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.
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.
(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****