0% found this document useful (0 votes)
197 views13 pages

Set 2 Preboard 2022 Answer Key

Uploaded by

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

Set 2 Preboard 2022 Answer Key

Uploaded by

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

PREBOARD2 PAPER(2022-23)

CLASS-XII
SUBJECT: COMPUTER SCIENCE
TIME: 3 HOURS M.M.: 70

General Instructions:
1. This question paper contains five sections, Section A to E.
2. All questions are compulsory.
3. Section A has 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 Q34 against
part c only.
8. All programming questions are to be answered using Python Language only.
--------------------------------------------------------------------------------------------------------
SECTION A
Q01. State True or False [1]

“Tuple is datatype in Python which contain data in key-value pair”

Ans False

Q02. Which of the following is not a keyword? [1]

(a) eval (b) type (c) local (d)pass


and (c)
Q03. Given the following dictionaries [1]
dict_student={“rno”: ”53”, “name” : “rajveer singh”}
dict_marks={“accts” :87 , “English” : 65}
which statement will merge the contents of both dictionaries?
(a) dict_student + dict_marks (c) dict_student. add(dict_marks)
(b) dict_student. merge(dict_marks) (d) dict_student. update(dict_marks)
Ans (d)
Q04. Consider the given expression : [1]
not (( True and False ) or True)
which of the following will be correct output if the given expression is evaluated?
(a) True (b) False (c) None (d) NULL
Ans (b)
Q05. Select the correct output of the code: [1]
>>> s=’[email protected]
>>>s=s.split(‘ap’)
>>>op = s[0] + ‘@ap’ +s[2]
>>>print(op)
(a) mail2@apsdk (b) mail2@dk (c) [email protected] (d) mail2apsdk.co.in
ans (c)
Q06. Which function is used to close a file in Python? [1]
(a) close() (b) cloose() (c) Close() (d) close
Ans (a)
Q07. Fill in the blank: ____________command is used to change the table structure in SQL. [1]
(a) update (b) change (c) alter (d) modify
Ans (c)
Q08.Which of the following commands will remove the entire database from MYSQL. [1]
(a) Delete database (b) drop database (c) remove database (d) alter database
Ans (b)
Q09.Which of the following statement(s) would give an error after executing the following code. [1]
D={ “rno” :32 , “name” : “Ms Archana “ , “subject” : [‘chem”,”English” ,”cs”] , “marks”: (85,75,89) } #s1
print(D) #s2
D[‘subject’][2]= ‘maths’ #s3
D[“marks”][2]=80 #s4
print(D) #s5
(a) s1 (b) s3 (c) s4 (d) s3 and s4
Ans (c)
Q10. Fill in the blank: _________is a non key attribute whose values are derived from the primary key
of some other table. [1]
(a) Primary key (b) candidate key (c) alternate key (d) foreign key
Ans (d)
Q11 The correct syntax of seek is : [1]
(a) seek(offset [,reference_point]) (c) seek(offset, file_object)
(b) seek.file_object(offset) (d) file_object.seek(offset [,reference_point])
Ans (d)
Q12 Fill in the blank: [1]
The select statement when combined with ____clause ,returns records without repetition.
(a) DISTINCT (b) DESCRIBE (c) UNIQUE (d) NULL
Ans (a)
Q13 Fill in the blank: ________ is a communication methodology designed to deliver both voice and
multimedia communications over internet protocol. [1]
(a) SMTP (b) VoIP (c) PPP (d) HTTP Ans (b)
Q14 What will the following expression be evaluated to in Python? [1]
print( round(100.0 /4 + (3+2.55),1 ))
(a) 30.0 (b) 30.55 (c) 30.6 (d) 31
Ans (c)

Q15. Which function is used to display the total number of records from a table in a database.
a. total() (b) total(*) (c)return(*) (d) count(*) [1]
Ans (d)
Q16.In order to open a connection with MySQL database from within Python using
mysql.connector package, _______function is used. [1]
a. open() (b) connect (c) database() (d) connectdb()
Ans (b)
Q17and Q18 are assertion and reasoning based questions. Mark the correct choice as
a. Both A and B 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 and R is False.
d. A is false and R is true.
Q17 str1=”class”+”work” [1]
Assertion(A) : value of str1 will be “classwork”
Reasoning(R) : operator ‘+’ adds the operands,if both are numbers & concatenates the string if
both operands are strings.
Ans (a)
Q18. Assertion(A) : CSV (comma separated values) is a file format for data storage which looks
like a text file.
Reason (R) :The information is organized with one record on each line and each field is
separated by semicolon. [1]
Ans (c)
SECTION B
Q19. Vivek has written a code to input a number and check whether it is even or odd number.
His code is having errors. Rewrite the correct code and underline the corrections made [2]
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”)
Q20. Write two points of difference Bus topology and Star topology. [2]
OR
Write two points of difference between XML and HTML.
Ans The star topology utilises the switch or central hub for broadcasting data and info to all the
devices present in a network. On the other hand, the bus topology utilises just a single cable
that connects all the peripheral devices

XML (Extensible Markup Language) is a markup language similar to HTML, but without
predefined tags to use. Instead, you define your own tags designed specifically for your
needs.

Q21.(A) Given is a Python string declaration: [1]


message = ‘ firstPreBoardExam@2022-23 ‘
Write the output of : print(message [ : : -3].upper())
Ans '322ADORSF'
(B) Write the output of the code given below: [1]
d1={ ‘rno’ : 25 , ‘name’ : ‘dipanshu’ }
d2={ ‘name’ : ‘himanshu ‘ , ‘age’ : 30 , ‘dept’ : ‘mechanical’ }
d2.update(d1)
print(d2.keys())
Ans dict_keys(['name', 'age', 'dept', 'rno'])

Q22.Explain the use of ‘ Foreign Key ‘ in a Relational Database Management System. Give
example to support your answer. [2]
Ans foreign key is a primary key but in another table.
Emp (empno, ename,job,deptno) dept (deptno dname loc)
In emp table deptno is foreign key

Q23. (A) Write the full forms of the following: [1]


(i) HTTP (ii) FTP

(B) What is the use of TELNET ? [1]


Ans (A) HTTP- hyper text markup language
FTP-file transfer protocol
(B) it is used to connect remote located system

Q24. Predict the output of the Python code given below: [2]
data = [ “L”, 20 , “M”, 40 , “N” , 60 ]
times=0
alpha=” “
add=0
for c in range(1,6,2):
times= times+c
alpha =alpha + data [c-1] + ‘@’
add= add + data [c]
print(times, add , alpha)
Ans 9 120 L@M@N@
OR
Predict the output of the Python code given below:
a=[1,2,3,4,5]
dst=[ ]
for j in range( len(a)):
if j % 2==1:
t=( a[ j ] , a [ j ] **2 )
dst.append(t)
print(dst)
Ans [(2, 4), (4, 16)]

Q25 Differentiate between order by and group by clause in SQL with appropriate example.[2]
Ans The Group By clause is used to group data based on the same value in a specific
column. The ORDER BY clause, on the other hand, sorts the result and shows it in ascending
or descending order.
OR

Categorize the following commands as DDL and DML.


INSERT , UPDATE , ALTER, DROP
Ans DDL- alter , drop. DML- insert,update

SECTION C

Q26 Write the output of the queries (i) to (vI) based on the table given below: [3]
TABLE : CHIPS

BRAND_NAME FLAVOUR PRICE QUANTITY

LAYS ONION 10 5

LAYS TOMATO 20 12

UNCLE CHIPS SPICY 12 10


UNCLE CHIPS PUDINA 10 12

HALDIRAM SALTY 10 20

HALDIRAM TOMATO 25 30

(i) Select BRAND_NAME, FLAVOUR from CHIPS where PRICE <> 10;
Ans(i) Brand_name flavor
Lays Onion
Lays tomato
Uncle chips pudina
Haldiram salty
Haldiram tomato

(ii) Select * from chips where flavour = “tomato” and price >20;
Ans(ii) brand_name flavor price quantity
Haldiram tomato 25 30
(iii) select brand_name from chips where price > 15 and quantity <15;
Ans (iii) brand_name
lays
(iv) select count( distinct brand_name) from chips;
Ans(iv) 3
(v) select price, price*1.5 from chips where flavour=”pudina”
Ans (v) price price*1.5
10 15
(vi) select distinct (brand_name) from chips order by brand_name desc;
Ans (vi) distinct (brand_name)
Lays
Uncle chips
haldiram
Q27 Write a function countINDIA() which read a text file ‘myfile.txt’ and print the frequency of the
words ‘India’ in it(ignore case of the word). [3]
Example `; if the file content is as follows:
INDIA is my country. I live in India. India has many states.
The countIndia() function should display the output as : frequency of India is 3
Ans def countINDIA():
F=open(‘myfile.txt’)
G=F.read()
for I in G.lower():
if I ==’india’:
c=c+1
print(‘frequency of India is”,c)
F.close()
OR
Write a function countVowel() in python which read each character of a text file ‘myfile.txt’ and
then count and display the count of occurrence of vowels (including small cases and upper
case)
Example `; if the file content is as follows:
INDIA is my country. I live in India. India has many states.
The countVowel() function should display the output as :Total number of vowels are: 20
Ans
def countVowel():
F=open(‘myfile.txt’)
G=F.read()
for I in G:
if I in ‘aeiouAEIOU’:
c=c+1
print(‘total number of vowels are”,c)
F.close()
Q28 (A) Consider the following tables BOOKS and ISSUED in a database named ‘LIBRARY’.
Write SQL commands for the statements (i) to (iv). [2]
TABLE : BOOKS

BID BNAME AUNAME PRICE TYPE QTY

COMP11 LET US C YASHWANT 350 COMPUTER 15

GEOG33 INDIA MAP RANJEET P 150 GEOGRAPHY 20

HIST66 HISTORY R BALA 210 HISTORY 25

COMP12 MY FIRST C VINOD DUA 330 COMPUTER 18

LITR88 MY DREAMS AVIND AD 470 NOBEL 24

TABLE:ISSUED

BID QTY_ISSUED

HIST66 10

COMP11 5

LITR88 15

(i) Display book name and author name and price of computer type books.
Ans(i) select bname,auname,price from books where type=’computer’;
(ii) To increase the price of all history books by Rs 50.
Ans(ii) update books set price=price+50 where type=’history’;
(iii) Show the details of all books in ascending order of their prices.
Ans(iii) select * from books order by price;
(iv) to display book id, book name and quantity issued for all books which have been issued.
Ans(iv)select bid,bname,qty_issued from books,issued where books.bid=issued.bid;
(B)Write the command to view all tables in a database. [1]
Ans (B) show tables;

Q29. Write a function lenFOURword(L), where L is the list of elements (list of words) passed as
argument to the function. The function returns another list named ‘indexList’ that stores the
indices of all four lettered of L. [3]
For example if L contains [‘dinesh’ , ‘ramesh’ , ‘aman’ ,’suresh’, ‘karn’]
The indexList will have [2,4]
Ans
indexList=[]
def lenFOURword(L):
for I in range(len(L)):
if len(L[I])==4:
indexList.append(I)
return indexList
L=['dinesh' , 'ramesh' , 'aman' ,'suresh', 'karn']
print(lenFOURword(L))

Q30. A list contains following record of student: [3]


[studentName, Class, Section, MobileNumber ]
Write the following user defined functions to perform given operations on the stack named ‘xiia’:
(i) pushElement() - to push an object containing name and mobile number of students
who belong to class XII and section ‘a’ to the stack.
(ii) popElement()- to Pop the objects from the stack and display them . Also, display ‘Stack
Empty ‘ when there are no elements in the stack.
For example
If the lists of student details are:
['rajveer' , '999999999', 'xi' ,'b']
['swatantra' , '888888888', 'xii' ,'a']
['sajal' ,'7777777777', 'vii' ,'a']
['yash' , '101010101010','xii' ,'a']
The stack ‘xiia’ should contain
[‘swatantra , ‘888888888’, ‘xii ‘ ,’a’]
[‘yash’ , ‘101010101010’, ‘xii ‘ ,’a’]
The output should be
[‘yash’ , ‘101010101010’, ‘xii ‘ ,’a’]
[‘swatantra , ‘888888888’, ‘xii ‘ ,’a’]
Stack empty
Ans
L=[['rajveer' , '999999999', 'xi' ,'b'],
['swatantra' , '888888888', 'xii' ,'a'],
['sajal' ,'7777777777', 'vii' ,'a'],
['yash' , '101010101010','xii' ,'a']]

xiia=[]
def pushElement():
for i in L:
if i[2]=='xii' and i[3]=='a':
xiia.append([i[0],i[1]])

def popElement():
if xiia==[]:
print("stack empty")
else:
print(xiia.pop())

pushElement()
popElement()
popElement()
popElement()

OR
Write a function in Python, Push(SItem) where , Sitem is a dictionary containing the details of
stationary items-{sname:price}
The function should push the names of those items in the stack who have price greater than 25.
Also display the count of elements pushed into the stack.
For example:
If the dictionary contains the following data
ditem={‘rubber ‘ : 5 , “pencil “ : 5, ‘pen’ : 30 , ‘ notebook’ : 60 ,’eraser’ : 5 ,’watch’ : 250 }
The stack should contain
pen
notebook
watch
The output should be
The count of elements in the stack is 3
Ans
ditem={'rubber' : 5 , 'pencil' : 5, 'pen' : 30 , 'notebook' : 60 ,'eraser' : 5 ,'watch' : 250 }
st=[]
def Push(Sitem):
c=0
for i in Sitem:
if Sitem[i]>25:
st.append(i)
c=c+1
print(st)
print('count of element in the stack are',c)

Push(ditem)

SECTION D
Q31 Aryan infotech solutions has set up its new center at kamla Nagar for its office and web
based activities . The company compound has 4 buildings as shown in the diagram below:[5]

Orbit
building Sunrise
Jupiter building
building

Oracle
Building

Distance between various buildings


Jupiter building to orbit building 50 mtrs

Orbit building to oracle building 85 mtrs

Oracle building to sunrise building 25 mtrs

Sunrise building to jupiter building 170 mtrs


Jupiter building to oracle building 125 mtrs

Orbit building to sunrise building 45 mtrs

Number of computers in each of the buildings is follows:

Jupiter building 30

Orbit building 150

Oracle building 15

Sunrise building 35

(i) suggest a cable layout of connections between the buildings.


(ii) suggest the most suitable place(i.e. building) to house the server of this organisaton with a
suitable reason. Ans Orbit building –becoz it supports max no of computers
(iii) suggest the placement of the following devices with justification.
a. Internet connecting device/modem (b) switch
(iv) The organisation is planning to link its sale counter situated in various parts of the same city,
which type of network out of LAN,MAN or WAN will be formed? Justify your answer. Ans MAN
(v) what do you mean by PAN? Explain giving example. Ans PAN-personal area network. Home
office

Q32 (A) Write the output of the code given below: [5]
def printMe(q,r=2):
p=r+q**3
print(p)
#main code
a=10
b=5
printMe(a,b)
printMe(r=4,q=2)
Ans
1005
12
(B) The code given below inserts the following record in the table student
Rollno name clas marks
Integer string integer integer
Note the following to establish connectivity between python and MySQL
Username is root
Password is toor@123
The table exists in a “stud” database
The details (Rollno, Name, Clas and Marks) are to be accepted from the user.
Write the following missing statements to complete the code:
Statement 1 - to form the cursor object
Statement 2- to execute the command that insert the record in the table student.
Statement 3- to add the record permanently in the database
import mysql.connector as mysql
def sqldata():
con=mysql.connect(host=”localhost”, user=”root”,passwd=”toor@123”,database=”stud”)
mycursor=________________ #statement 1 Ans statement 1 con.cursor()
rno=int(input(“enter roll number”))
name=input(“enter name”))
clas=int(input(“enter class”))
marks=int(input(“enter marks”))
querry=”insert into student values ( {}, ‘{}’,{},{} )”.format(rno,name,clas,marks)
____________ # statement 2 Ans statement 2: mycursor.execute(querry)
____________ # statement 3 Ans statement 3: con.commit()
print(“data added successfully”)
OR

A. Write the output of the code given below:


s=”C++VsPy”
m=” “
for i in range(0,len(s)):
if s[i] >=’a’ and s[i]<=m :
m=m+s[i].upper()
elif s[i]>=’n’ and s[i] <=’z’:
m=m+s[i-1]
elif s[i].isupper() :
m=m+s[i].lower()
else:
m=m+’&’
print(m) Ans c&&vVpP
(B)
The code given below inserts the following record in the table student
Rollno name clas marks
Integer string integer integer
Note the following to establish connectivity between python and MySQL
Username is root
Password is toor@123
The table exists in a “stud” database
The details (Rollno, Name, Clas and Marks) are to be accepted from the user.
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 students whose marks
are greater than 90.
Statement 3- to read the complete result of the query (records whose marks are greater
than 90) in to the object named data, from the table student in the database.
import mysql.connector as mysql
def sqldata():
con=mysql.connect(host=”localhost”, user=”root”,passwd=”toor@123”,database=”stud”)
mycursor=________________ #statement 1 Ans statement 1: con.cursor()
print(“students with marks greater than 90 are “)
______________________ #statement 2 Ans statement 2 :
mycursor.execute(‘select * from student where marks>90’)
data=_____________________ #statement 3 Ans statement 3: mycursor.fetchall()
for i in data:
print(i)
print()
Q33 What is the advantage of using a csv file for permanent storage? Write a program in
Python that defines and calls the following user defined functions: [5]
(i) ADD()- to accept and add data of a teacher to a CSV file ‘ teacher.csv’ . Each record
consists of a list with field elements as tid, name , mobile to store teacher id, teacher name and
teacher mobile number respectively.
(ii) COUNTRECORD()- to count the number of records present in the CSV file named
‘teacher.csv’ .
Ans
import csv
def add():
f=open('teacher.csv','a')
d=csv.writer(f,lineterminator='\n')
tid=input('teacher id')
name=input('teacher name')
mobile=input('teacher mobile')
d.writerow([tid,name,mobile])
f.close()
def COUNTRECORD():
f=open('teacher.csv')
d=csv.reader(f)
c=0
for i in d:
print(i)
c=c+1
print(c)

add()
COUNTRECORD()
OR
Give any one point of difference between a binary file and 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 ‘ employee.csv’. Each record
consists of a list with field elements as eid, name and salary to store employee id, employee
name and employee salary respectively.
(ii) search()- to display the records of the employee whose salary is more than 40000.
Ans
import csv
def add():
f=open('employee.csv','a')
d=csv.writer(f,lineterminator='\n')
tid=input('employee id')
name=input('employee name')
salary=input('employee salary')
d.writerow([tid,name,salary])
f.close()
def search():
f=open('employee.csv')
d=csv.reader(f)
c=0
for i in d:
if int(i[2])>40000:
print(i)
add()
add()
search()
SECTION E
Q34. Layna creates a table STOCK to maintain computer stock in vidyalaya. After creation of
the table, she has entered data of 8 items in the table : [1+1+2]

stockid dopurchase Name make price

101 2020-07-06 CPU ACER 12000

102 2020-09-01 CPU ACER 12750

103 2020-09-01 MONITOR ACER 7500

104 2016-08-03 PROJECTOR GLOBUS 37250

105 2016-05-26 VISUALIZER GLOBUS 17500

106 2020-07-23 WIFI RECEIVER ZEBION 450

107 2015-02-18 PRINTER LEXMARK 38000

108 2020-07-23 HEADPHONE BOAT 750

Based on the data given above answer the following questions:


(i) identify the most appropriate column, which can be considered as Primary Key. ans stockid
(ii) If three columns are added and 5 rows are deleted from the table stock , what will be the new
degree and cardinality of the above fields?Ans degree-8, cardinality-3
(iii) write the statements to
a. Insert the following records into the table
stockid=201, dateofpurchase- 18 oct 2022 , name - neckphone , make - BOAT , price –
500
Ans insert into stock values(201,’2022-10-18’,’neckphone’,’BOAT’,500);
b. Decrease the price of stock by 5% whose date of purchased year is 2020
ANs update stock where price=price-0.05 where dopurchase like ‘2020%’;
OR ( option for part (iii) only)
(iii) write the statement to:
a. Delete the record of stock which were purchased before year 2015.
Ans delete from stock where dopurchase < ‘2015’;
b. Add a column STATUS in the table with datatype as char with 1 character.
Ans alter table stock add (status char);

Q35. Vishnu is a Python programmer. He has written a code and created a binary file recrod.dat
with studentid, subjectcode and marks. The file contains 10 records. He now has to update a
record to based on the studentid entered by the user and update the marks. The updated record
is then to be written in the file temp.dat. The records which are not to be updated also have to
be written to the file temp.dat. If the student id is not found , an appropriate message should be
displayed. As a Python expert, help him to complete the following code based on the
requirement given below: [1+1+2]
import ____________ #statement 1 Ans pickle
def update _data():
rec={ }
fin=open(‘record.dat’, ‘rb’)
fout=open(‘ ___________’) #statement 2 Ans ‘temp.dat’,’ab’
found=False
sid=int(input(‘enter student id to update the marks ‘))
While True:
try:
rec=_________#statement 3 Ans pickle.load(fin)
if rec[‘studentid’]==sid:
found=True
rec[‘marks’]=int(input(‘enter new marks’))
pickle. _________ #statement 4 Ans dump(rec,fout)
else:
pickle.dump(rec,fout)
except:
break
if found==True:
print(‘the marks of studentid’ ,sid, ‘has been updated’)
else:
print(‘ no student with such id is not found’)
fin.close()
fout.close()
(i) which module should be imported in the program?(statement 1)
(ii) write the correct statement required to open a temporary file named
temp.dat(statement 2)
(iii) Which statement should Aryan fill in statement 3 to read the data from the
binary file, record.dat and in statement 4 to write the updated data in the file,
temp.dat?

You might also like