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

XII - CS SET-B - MS - CbeSSC - DEC 1984

This document contains the details of a pre-board examination for grade 12 computer science students. It includes 5 sections (A-E) with a total of 70 marks. Section A contains 18 multiple choice questions worth 1 mark each. Section B contains 7 short answer questions worth 2 marks each. Section C contains 5 questions worth 3 marks each. Section D contains 3 long answer questions worth 5 marks each. Section E contains 2 questions worth 4 marks each, with 1 internal choice given. All programming questions must be answered using Python. The document provides sample questions from various sections to illustrate the format and topics covered in the exam.
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
100% found this document useful (1 vote)
1K views

XII - CS SET-B - MS - CbeSSC - DEC 1984

This document contains the details of a pre-board examination for grade 12 computer science students. It includes 5 sections (A-E) with a total of 70 marks. Section A contains 18 multiple choice questions worth 1 mark each. Section B contains 7 short answer questions worth 2 marks each. Section C contains 5 questions worth 3 marks each. Section D contains 3 long answer questions worth 5 marks each. Section E contains 2 questions worth 4 marks each, with 1 internal choice given. All programming questions must be answered using Python. The document provides sample questions from various sections to illustrate the format and topics covered in the exam.
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/ 14

B

PRE – BOARD EXAMINATION (DEC–2022)


GRADE: 12 MARKS: 70
DATE : COMPUTER SCIENCE ANSWER KEY TIME : 3 HRS

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 Q35
against Part-C only
8. All programming questions are to be answered using Python Language only.

S.NO SECTION-A MARKS


1 The continue statement is used:
(a) to pass the control to the next iterative statement 1
(b) to come out from the iteration
(c) to break the execution and passes the control to else statement
(d) to terminate the loop
Ans. (a) to pass the control to the next iterative statement
2 Common types of exception in python are:
(a) Syntax Error (b) Zero division error (c) (a) and (b) (d) None of these 1
Ans. (c) (a) and (b)
3 Which of the following is an incorrect logical operator in python? 1
(a)not (b) in (c) or (d) and
Ans. (b) in
4 Which of the following is not a function/method of the random module in
python? 1
(a) randfloat( ) (b) randint( ) (c) random( ) (d) randrange( )
Ans. (a) randfloat( )
5 Which of the following is not a tuple in Python? 1
(a) (1,2,3) (b) (“One”,”Two”,”Three”) (c) (10,) (d) (“One”)
Ans. (d) (“One”)
6 Built-in functions are also known as ________ 1
Ans. Library functions
7 For a function header as follows:
def calc(x,y=20): 1
Which of the following function calls will give an error?
(a) calc(15,25) (b) calc(x=15,y=25) (c) calc(y=25) (d) calc(x=25)
Ans. (d) calc(x=25)
8 If the following statement is used to read the contents of a text file object F:
x=F.readlines( )
Which of the following is the correct data type of x?
(a) string (b) list (c) tuple (d) dictionary 1
Ans. (b) list
9 Which of the following command is used to open a file “c:\pat.dat” for writing 1
as well as reading in binary format only?
(a) fout=open(“c:\pat.dat”,”w”) (b) fout=open(“c:\\pat.dat”,”wb”)
(c) fout=open(“c:\pat.dat”,”w+”) (d) fout=open(“c:\pat.dat”,”wb+”)
Ans. (d) fout=open(“c:\pat.dat”,”wb+”)
10 Which one is the correct output for the following code?
a=[1,2,3,4]
b=[sum(a[0:x+1]) for x in range(0,len(a))] 1
print (b)
(a) 10 (b) [1,3,5,7] (c) 4 (d) [1,3,6,10]
Ans. (d) [1,3,6,10]
11 Which SQL function is used to count all records of a table? 1
Ans. count(*)
12 _____ key is used to uniquely identify row in a table and also does not accept 1
NULL values.
Ans. Primary key
13 State True or False: Delete command is used to remove table. 1
Ans. False
14 What does the following query do? 1
UPDATE employee
SET salary=salary * 1.10;
(a) It increases the salary of all the employees by 10%
(b) It decreases the salary of all the employees by 10%
(c) It increases the salary of all the employees by 110%
(d) It is syntactically correct
Ans. (a) It increases the salary of all the employees by 10%
15 The SQL _____ clause contains the condition that specifies which rows are to 1
be selected.
Ans. Where
16 Which of the following is /are email protocols? 1
(a) TCP (b) IP (c) SMTP (d) POP
Ans. (c) SMTP & (d) POP
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): Stack is a linear data structure that works on the principle of 1
FIFO(First In First OUT)
Reason(R): The stack is created with the help of a list with some restrictions.
It manages a pointer called stack pointer(SP) that will increase or decrease by
1, if an element is entered or removed from the stack respectively.
Ans. (d) A is false but R is true
18 Assertion(A): The file access mode ‘a’ is used to append the data in the file. 1
Reason(R): In the access mode ‘a’ the text will be appended at the end of the
existing file. If the file does not exist, Python will create a new file and write
data into it.
Ans. (a) Both A and R are true and R is the correct explanation for A
S.NO SECTION-B MARKS
19 Find the output for the following code: 1
(a) def display (num) :
num.append ([27])
return (num[1], num[2], num[3])
list1= [6, 12, 27]
n1, n2, n3 = display (list1)
print (list1)
Ans. [6,12,27,[27]] 1
(b) x = ['ab', 'cd']
for i in x:
i.upper()
print(x)
Ans. [‘ab’,’cd’]
20 Write two advantages of using an optical fibre cable over an Ethernet cable to
connect two service stations, which are 190m away from each other. 2
Ans. Optical fibre provides high speed; electrical and magnetic interference
does not affect the transmission
(OR)
What is the purpose of using router?
Ans. A router can work like a bridge and can also handle different protocols.
can locate the destination required by sending the traffic to another router
21 Reena has written a code to check the maximum of given numbers. Her code
is having errors. Rewrite the correct code with output and underline the
correction made.
def printMax(a, b)
if a> b:
print(a, 'is maximum')
elif a = b: 2
print(a, 'is equal to', b)
else;
print(b, 'is maximum')
printMax(33,94):
Ans. O/P: 94 is maximum
error: def printMax(a, b);
if a> b:
print(a, 'is maximum')
elif a == b:
print(a, 'is equal to', b)
else:
print(b, 'is maximum')
printMax(33,94)
22 What will be the output of the following queries on the basis of 2
EMPLOYEE table?
Table: Employee
Emp_Id Name Salary
E01 Siya 54000
E02 Joy NULL
E03 Allen 32000
E04 Neev 42000
(i) SELECT Salary + 100 FROM Employee WHERE Emp_Id= ‘E02’;
(ii) SELECT Name FROM Employee WHERE Emp_Id= ‘E04’;
Ans. (i) salary +100 (ii) Name
NULL Neev
23 (a) What is VoIP? 2
Ans. Communication protocol and transmission technologies for delivery of
voice communications and multimedia sessions over IP networks such as
internet. They are IP telephony, internet telephony and broadband telephony
(b) Briefly explain the following terms: (i) HTML (ii) XML
Ans. HTML-Hypertext markup language (ii) extensible markup language
24 Predict the output of the Python code given below:
z= 100
def f( ):
global z
print('z is:', z)
z=50 2
print('New value of global z is:', z)
f( )
print('Value of z is:', z)
Ans. z is: 100
New value of global z is: 50
Value of z is: 50
(OR)
Predict the output of the Python code given below:
def COUNT ( ):
s=open ("Quotes.txt", "r")
f=s.read( )
z=f.split( )
count=0
for i in z:
count=count+1
print (count)
COUNT( )
Ans. 16
25 Differentiate between ALTER and UPDATE commands in SQL. 2
Ans. Alter: DDL category,changes the structure of the table; columns
can be added or modified
Update: DML category; modifies table data; data can be changed,
updated with values
(OR)
In the following query how many rows will be deleted?
DELETE Student
WHERE StudentID=105;
(Assuming a Student table with primary key StudentID)
Ans. From keyword missing
S.NO SECTION-C MARKS
26 Give output for following SQL queries as per given tables: 3
TABLE: CLUB
COACH_I COACHNAM AGE SPORTS DOJ PAY SEX
D E
1 ARUN 35 KARATE 27/03/1996 1000 M
2 RAVINA 34 KARATE 20/01/1998 1200 F
3 KARAN 34 SQUASH 19/02/1998 2000 M
4 TARUN 33 BASKETBALL 01/01/1998 1500 M
5 ANKITA 36 SWIMMING 12/01/1998 750 F
TABLE: COACHES
SPORTSPERSON SEX COACH_NO
AJAY M 1
SHAILYA F 2
VINOD M 1
TANEJA F 3
(i) SELECT AVG(PAY) FROM CLUB WHERE SPORTS=”KARATE”;
(ii) (a) SELECT MIN(AGE) FROM CLUB WHERE SEX=”F”;
(b) SELECT COUNT(DISTINCT SPORTS) FROM CLUB;
(iii) SELECT SPORTSPERSON, COACHNAME
FROM CLUB, COACHES
WHERE CLUB.COACH_ID=COACHES.COACH_NO;
Ans. (i) 1100 (ii) (a) 34 (b) 4 (iii) Ajay Arun, Shailya Ravina, Vinod Arun,
Taneja Karan
27 Write a function/method DISPLAYWORDS( ) in python to read lines from a 3
text file STORY.TXT and display those words, which are less than 4
characters.
Ans. def showdata( ):
try:
with open(“story.txt”,’r’) as f:
c=f.read( )
s=c.split( )
for i in s:
if len(i) <=4:
print(i,end=’ ‘)
except FileNotFoundError:
print(“File Not Found”)
showdata( )
(OR)
Write a function to count the words He/She in a file.
Ans. def heshe( ):
try:
with open(“sms.txt”,’r’) as f:
c=f.read( )
s=c.split( )
print(‘Total words in a file’,s.count(“He”))
print(“Total words in a file’, s.count(“She”))
except FileNotFoundError:
print(“File Not Found”)
heshe( )
28 (a) Consider the following tables DOCTOR and SALARY. Write SQL commands for the 2+1
following statements.
Table: DOCTOR
ID NAME DEPT SEX EXPERIENCE
101 John ENT M 12
104 Smith ORTHOPEDIC M 5
107 George CARDIOLOGY M 10
114 Lara SKIN F 3
109 K George MEDICINE F 9
105 Johnson ORTHOPEDIC M 10
117 Lucy ENT F 3
111 Bill MEDICINE F 12
130 Morphy ORTHOPEDIC M 15
Table: SALARY
ID BASIC ALLOWANCE CONSULTATION
101 12000 1000 300
104 23000 2300 500
107 32000 4000 500
114 12000 5200 100
109 42000 1700 200
105 18900 1690 300
117 11000 1000 300
111 41000 1600 200
130 21700 2600 300
(a) (i) Display NAME of all doctors who are in “ORTHOPEDIC” having more
than 10 years’ experience from the table DOCTOR.
(ii) Display the average salary of all doctors working in “ENT” department
using the DOCTOR and SALARY. (Salary= Basic + Allowance)
(iii) Display the minimum ALLOWANCE of female doctors.
(iv) Display the highest consultation fee amount for all male doctors.
Ans. (i) SELECT NAME FROM DOCTOR WHERE
DEPT=”ORTHOPEDIC” AND EXPERIENCE>10;
(ii) SELECT AVG(BASIC + ALLOWANCE) FROM DOCTOR, SALARY
WHERE DOCTOR.ID=SALARY.ID AND DEPT=”ENT”;
(iii) SELECT MIN(ALLOWANCE) FROM DOCTOR, SALARY WHERE
DOCTOR.ID=SALARY.ID AND SEX=”F”;
(iv) SELECT MAX(CONSULTATION) FROM DOCTOR, SALARY
WHERE DOCTOR.ID=SALARY.ID AND SEX=”M”;
(b) Write the command to view all tables in a database.
Ans. Show tables;
29 Write a function in python POP(Arr), where Arr is a stack implemented by a 3
list of numbers. The function returns the value deleted from the stack.
Ans. def popstack( st):
if len(st)==0:
print(“Underflow”)
else:
L=len(st)
val =st[L-1]
print(val)
st.pop(L-1)
30 Write a function called rem_keys( D,keylist) that accepts two parameters: a 3
dictionary called D and a list called keylist. Function rem_keys(D,keylist)
should remove all the keys contained in the passed keylist from the dictionary
D and return the dictionary.
Ans. def rem_keys(D, keylist):
for k in keylist:
if k in D:
del D[k]
return D
D={“k1”:101,”k2”:202,”k3”: 303,”k4”: 404}
keys=[“k1”,”k3”,”k5”]
print(“Original dictionary:”,D)
print(“The keylist:”,keys)
print(“Dictionary after removing keys:”,rem_keys(D,keys))
(OR)
Write a function addrecord( ) to add new record to the binary file “student”
using list. The list should consist of student number, student name and marks
of the student.
Ans. import pickle
def addrecord( )
student=[]
ch=’y’
while ch==’y’:
stno=int(input(“Enter student number”))
sname=input(“Enter Name:”)
marks= int(input(“Enter marks:”)
s=[stno,sname,marks]
student.append(s)
ch=input(“Want to add more(y/n)?”)
f=open(“student.dat”,”wb”)
pickle.dump(student,f)
f.close( )
S.NO SECTION-D MARKS
31 Bias Methodologies is planning to expand their network in India, starting with 5
three cities in India to build infrastructure for research and development of
their chemical products. The company has planned to set up their main office
in Pondicherry at three different locations and have named their offices as
Back Office, Research Lab and Development Unit. The company has one
more research office namely Corporate Unit in Mumbai. A rough layout of the
same is as follows:
Approximate distance between these offices are as follows:
FROM TO DISTANCE
Research Lab Back Office 110 m
Research Lab Development Unit 16 km
Research Lab Corporate Unit 1800 km
Back Office Development Unit 13 km
In continuation of the above, the company experts have planned to install the
following number of computers in each of their offices.
Research Lab 158
Back office 79
Development Unit 90
Corporate Unit 51
(i) Suggest the type of network required (out of LAN, MAN, WAN) for
connecting each of the following office units.
 Research Lab and Back Office
 Research Lab and Development Unit.
(ii) Which one of the following device, will you suggest for connecting all the
computers with in each of their office units?
 Switch/Hub
 Modem
 Telephone
(iii)Which of the following communication medium will you suggest to be
procured by the company for connecting their local office units in Pondicherry
for very effective (high speed) communication?
 Telephone cable
 Ethernet cable
 Optical fibre
(iv) Which building is suitable to install the server with suitable reason?
(v) Suggest a cable/wiring layout for connecting the company’s local office
units located in Pondicherry. Also, suggest an effective method/technology for
connecting the company’s office unit located in Mumbai.
Ans. (i) LAN and MAN
(ii) Switch/Hub
(iii) Optical fibre
(iv) Research lab

(v)
32 (a) Predict the output for the following code: 2+3
num=123
f=0
s=0
while(num > 3):
rem = num % 100
if(rem % 2 != 0):
f += rem
else:
s+=rem
num /=100
print(f-s)
Ans. 23
(b) A library uses a database management system (DBMS) to store the details
of the books that it stocks, its registered members and the book-loans that the
library has made. These details are stored in a database using the following
three relations. Name of the Database: KVS Library. (NOTE: The library
does not stock more than one copy of the same book)
 Book(BookID: Char(5), Title: Varchar(25), Author: Varchar(25),
Publisher: Varchar(100))
 Member(MemberID: Char(5), FirstName: Varchar(25), LastName:
Varchar(25), Correspondance-Address: Varchar(100), Pincode: Char(6),
DateofBirth: Date, EmailID:Varchar(50))
 Loan(MemberId: Char(5), BookID: Char(5), LoanDate: Date,
DueBackDate: Date, Returned: Boolean)
(i) Identify following types of keys from all the relations of the given
database: Foreign keys along with parent relations
(ii) Can a relation have multiple foreign keys? Give example.
(iii) Write a SQL query to retrieve the names and email addresses of the
members belonging to KVS (they have email ids as [email protected]) and who
have not returned their books.
Ans. (i) Foreign keys in relation loan: Member ID(Parent table Member)
Book ID(Parent table Book)
(ii) Yes, a relation can have multiple foreign keys. Eg., loan relation given
above has 2 foreign keys-MemberID and BookID
(iii) SELECT FIRSTNAME,LASTNAME,EMAILID FROM
MEMBER,LOAN WHER MEMNER.MEMBERID=LOAN.MEMBERID
AND EMAILID LIKE %@kvs.in AND RETURNED=”F”;
(OR)
(a) Predict the output for the following code:
def test(i, a =[]):
a.append(i)
return a
test(25)
test(32)
s = test(17)
print(s)
Ans. [25,32,17]
(b) The given program is used to connect with MYSQL and show the name of
all tables available in MySQL server ”TEST” database. You are required to
complete the statements so that the code can be executed properly.
import _______ (i)
# complete the statement with appropriate library name
db=mysql.connector. __________(ii)
(host=”localhost”, user=”root”, password=”smsmb”)
# fill the statement with appropriate method
cur=db._________( ) (iii)
# method to open the cursor object
data= ”______” (iv)
#complete the statement with the appropriate database name
cur.execute(“________”+data) (v)
# command to open the database
cur.execute(“______________________”) (vi)
#command to display name of all the tables
Ans. (i) mysql.connector (ii) connect (iii) cursor() (iv) “test” (v) use (vi) show
tables
33 What is stack type of data structure? List out its applications. 5
Write a function called authenticate(users,loginid,password) which takes
following three parameters:
users: a dictionary storing login ids and corresponding password values
loginid: a string for a login name
password: a string for a password
The function should do the following:
(i) if the user exists and the password is correct for the given loginid, it should
print “Access granted”
(ii) if the user exists and the password is incorrect for the given loginid, it
should print “Incorrect password”
(iii) if the user does not exist for the given loginid, it should print “Wrong
credentials”
Ans. Stack is a linear type of data structure which stores the data in LIFO
order. Applications: Reverse a string, polish strings.
def authenticate(users,loginid,password):
if loginid in users:
if users[loginid]==password:
res=”Access granted”
else:
res=”Incorrect password”
return res
users={‘j123:”12%%34”,”xyz1”:”aa@@123”,”kbc2020”:”kyc&12@20”}
uid=input(“Enter loginid:”)
pwd=input(“Enter password:”)
r=authenticate(users,uid,pwd)
print(r,”for”,uid)
(OR)
What is a file? How a text file is different from binary file?
A binary file “BOOK.dat” has structure [BookNo, Book_Name, Author,
Price]
(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”
Ans. import pickle
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
S.NO SECTION-E MARKS
34 Database name: Shop 1+1+2
Table name: Infant
Itemcode Item Datepurchase Unitprice Discount
101 Frock 2016-01-23 700 10
102 Cot 2015-09-23 5000 25
103 Soft Toy 2016-06-17 800 10
104 Baby Socks 2014-10-16 100 7
105 Baby Suit 2015-09-20 500 5
(i) Write a query to make Item code as primary key in the above existing table.
(ii) Write the command to remove the column Discount.
(iii) (a) Write the command to display the structure of the table infants which
is Shop database.
(b) Write the degree and cardinality of the table.
(OR) (Option given for part (iii) only)
(iii) (a) Add a new row with the following values in respective attributes.
Itemcode=106, Item=Bath Tub, Datepurchase=2015-10-22, Unitprice=1500
(b) Write the command to display Item, Unitprice in descending order.
Ans. (i) ALTER TABLE INFANT ADD PRIMARY KEY(ITEMCODE);
(ii) ALTER TABLE INFANT DROP DISCOUNT;
(iii)(a) DESC INFANTS; (b) Degree=5, Cardinality=5 (OR)
(iii) (a) INSERT INTO INFANTS(ITEMCODE,
ITEM,DATEPURCHASE,UNITPRICE) VALUES(106, ‘BATH TUB’, 2015-
10-22’,1500);
(b) SELECT ITEM ,UNITPRICE FROM INFANTS ORDER BY
UNITPRICE DESC;
35 Ariba Malik has been following incomplete code, which takes a student’s 4
details (rollnumber, name and marks) and writes into a binary file stu.dat using
pickling.
import pickle
sturno=int(input(“Enter roll number:”))
stuname=input(“Enter name:”)
stumarks=float(input(“Enter marks:”))
stu1={“RollNo.”:sturno,”Name”:stuname,”Marks”:stumarks}
with __________ as fh: # Fill_Line1
________________ # Fill_Line2
______________ as fin: # Fill_Line3
________________ # Fill_Line4
print(Rstu)
if Rstu[“Marks”]>=85:
print(“Eligible for merit certificate”)
else:
print(“Not eligible for merit certificate”)
(a) Complete Fill_Line1 so that the mentioned binary file is opened for writing
in fh object using a with statement.
(b) Complete Fill_Line2 so that the dictionary stu1’s contents are written on
the file opened in step(a)
(c) Complete Fill_line3 so that the earlier created binary file is opened for
reading in a file object namely fin, using a with statement.
(d) Complete Fill_line4 so that the contents of open file in fin are read into a
dictionary namely Rstu.
Ans. (a) with open(“Stu.dat”,”wb”) as fh:
(b) pickle.dump(Stu1,fh)
(c) with open(“Stu.dat”,”rb”) as fin:
(d) Rstu=pickle.load(fin)

You might also like