0% found this document useful (0 votes)
31 views11 pages

Pre-Board Examination - II Computer Science PB-2-2022-23-12 - (B) Time: 3 Hrs. M. Marks: 70

This document contains instructions and questions for a Computer Science pre-board examination. It has 5 sections (A-E) with multiple choice and programming questions. Section A has 18 one-mark questions. Section B has 7 two-mark questions. Section C has 5 three-mark questions. Section D has 3 five-mark questions. Section E has 2 four-mark questions with one internal choice in part c. All programming questions must be answered in Python. The document provides sample questions on topics like operators, functions, data structures, SQL, networks etc.

Uploaded by

Krishna
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
Download as pdf or txt
0% found this document useful (0 votes)
31 views11 pages

Pre-Board Examination - II Computer Science PB-2-2022-23-12 - (B) Time: 3 Hrs. M. Marks: 70

This document contains instructions and questions for a Computer Science pre-board examination. It has 5 sections (A-E) with multiple choice and programming questions. Section A has 18 one-mark questions. Section B has 7 two-mark questions. Section C has 5 three-mark questions. Section D has 3 five-mark questions. Section E has 2 four-mark questions with one internal choice in part c. All programming questions must be answered in Python. The document provides sample questions on topics like operators, functions, data structures, SQL, networks etc.

Uploaded by

Krishna
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
Download as pdf or txt
Download as pdf or txt
You are on page 1/ 11

COMPUTER SCIENCE-(B)- 1 / 1

Pre-Board Examination - II
COMPUTER SCIENCE
PB-2-2022-23-12-(B)

Time : 3 hrs. M. Marks : 70

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 Q34 against part c only.
8. All programming questions are to be answered using Python Language only.

SECTION - A
1. Which line of code will not produce an error? (1)
(A) “Pre” * ‘2’ (B) 2 * “Pre”
(C) “Pre’* 2 (D) “Pre” * “2”

2. Given a function that does not return any value________ data item is returned by default in
Python (1)
(A) int (B) float
(C) bool (D) None

3. Which option is True for a Python object? (1)


(A) An object needs to be declared explicitly
(B) All Objects can be reassigned at the same memory location
(C) Dynamic typing is applicable for every object
(D) An object need not have a datatype

4. What will be the output of the following Python code snippet?


>>>a={1:”A”,2:”B”,3:”C”}
>>>print(a.get(5,4)) (1)
(A) Error (B) 4
(C) no output (D) 5

5. Predict the output :


>>>”PB2”*2**2

(A) error (B) PB2PB2


(C) PB2PB2PB2PB2 (D) None of the above (1)
COMPUTER SCIENCE-(B)- 1 / 2
6. The readline( ) method returns____________ (1)
a. a string b. a list of lines
c. list of single characters present in a line d. a tuple of strings

7. A Table in MySQL can have ________ primary keys. (1)


a. Many b. 1
c. 2 d. depends on DBMS
8. All alternate keys of a table are also _______ keys (1)
a. Foreign Key b. Alternate Key
c. Candidate Key d. Composite Key
9. Which error will be resulted by the following statements (1)
>>> L1 = “A”, “B”, “C” # Statement 1
>>> del(L1[0]) # Statement 2
a. TypeError b. IndexError
c. ValueError d. NameError
10. Refer the student and fee table specifications - student (admno, name, address, class, section).
fee (admno, month_no, dueamt). A student’s details with admno K9999 is appearing in fee table,
but does not exist in student’s table. Which issue is discussed here (1)
a. Cross Join b. Equi Join
c. Natural Join d. Referential integrity
11. _________ is used to 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 the mentioned

12. The SQL clause used to restrict non empty values in a field is __________ (1)
a. UNIQUE b. NOT NULL
c. DISTINCT d. IS NULL
13. HTTP stands for . (1)
a. Hyper Text Transfer Protocol b. Hyper Text Technology Protocol
c. Hyper Transfer Text Protocol d. Hyper Tech Textual Protocol
14. What will be the following expression evaluated to in Python? (1)
60*2 - (7 // 2) ** 2 ** 2
a. 39 b. 244
c. 141 d. 32
15. In MySQL, __________ keyword can be used to to put conditions on each tuple of a table (1)
a. WHERE b. HAVING
c. ORDER BY d. GROUP BY
16. Object created by ______ method is used to execute fetchone( ) (1)
a. cursor( ) b. execute( )
c. connection( ) c. connector( )
COMPUTER SCIENCE-(B)- 1 / 3
17. Assertion (A) (1)
In the following question a statement of Assertion (A) is followed by a statement of Reason (R).
Mark the correct choice as:
Assertion (A): Type Conversion is used to convert one datatype to another. It has two types.
Reasoning (R): Dynamic Typing is one of the typeconverions given by the user.
(a) Both Assertion (A) and reason (R) are true and reason (R) is the correct explanation of
Assertion (A).
(b) Assertion (A) and reason (R) are true and reason (R) is not the correct explanation of
Assertion (A).
(c) Assertion (A) is true but reason (R) is false.
(d) Assertion(A) is false but reason (R) is true.

18. In the following question a statement of Assertion (A) is followed by a statement of Reason (R).
Mark the correct choice as:
Assertion (A): Binary is a file format for data storage which looks like a text file.
Reasoning (R): The information present in a binary fileis organized in the form of UNICODE
characters and file can be manipulated by any text editor.
(a) Both Assertion (A) and reason (R) are true and reason (R) is the correct explanation of
Assertion (A).
(b) Assertion (A) and reason (R) are true and reason (R) is not the correct explanation of
Assertion (A).
(c) Assertion (A) is true but reason (R) is false.
(d) Assertion(A) is false and reason (R) is false.

SECTION - B
19. Rewrite the corrected code after removing the errors from the following code. Also underline the
corrections made: (2)
D1 = {[1,2,3]:”A”, 2:”B”, 3:”C”}
def F1():
print(D1[4])
D1.append({4:”D”})
print(D1*4)
return
print(F1())

20. What is meant by topology. Explain any one with one advantage and one disadvantage. (2)
OR
What do you mean by transmission media. Explain any three guided transmission medias.
21. Predict the output of the given code : (2)
(i) >>>print( "PREBoard2" > "PREboard2")
(ii) >>> str1 = "Pre Board2-DPS VK"
>>> str1. partition("2")
COMPUTER SCIENCE-(B)- 1 / 4

(iii) >>> D1 = {1:”A”, 2:”B”, 3:”C”}


>>> D1.items()

22. Define the following : (2)


(i) Table alias
(ii) Constraint
(iii) Logical operator in MySQL
(iv) Like operator

23. (a) Expand and explain the following: (2)


(i) HTTPS (ii) NSFNet

24. Predict the output : (2)


Attempt any one from (a) or (b)
(a) def f1():
stat = [4,8,2,-6]
avail = stat [-3]
stat [-3 ] = stat[-3] + stat[-2]
for k in range(4):
if k%2 != 0 and stat[k] > 0:
stat[k] -= stat[2-k]
else:
stat[k] += 2*k
if k%2 ==0:
avail += stat[-k]
h=3
for k in stat:
k += avail
stat[h] += k
h -= 1
print(stat)
f1()
OR
(b) L1 = [22,20,35,28,30,45]
L2 = [["Accounts", "Economics", "English", "History"],[30,15,20]]
L1[1]=L1[2]
L1[2]=L1[1]
L2= [L2[1][1]]+L1[:-3:-1]+[L2[-2][1]]
print(L2)
COMPUTER SCIENCE-(B)- 1 / 5
25. Attempt any one from (I) or (II) (2)
I)
a) Explain any one functions of Alter Table with example.
b) Shivam is using a table EMPLOYEE. It has the following columns: Code, Name, Salary,
Deptcode. He wants to display average salary Department wise. He wrote the following
command:
SELECT Deptcode, AVG(Salary) FROM EMPLOYEE ;
But did not get the desired result. Rewrite the above query with necessary change to help
him get the desired output.
OR
II)
a) Explain the use of wildcard characters in MySQL with example.
SECTION - C
26. (a) Consider the following tables - (1)

What will be the output of the following statements :


(i) SELECT CUSTOMERS.CNO, CITIES, PUR_DATE FROM PURCHASES,
CUSTOMERS WHERE CUSTOMERS.CNO = PURCHASES.CNO AND QTY
IN (6, 8);
(ii) SELECT CNO, CNAME, QTY FROM CUSTOMERS, PURCHASES WHERE
CUSTOMERS.CNO = PURCHASES.CNO AND CITY='CHENNAI';
(b) Write the outputs of the given quesries (i) to (iv) based on the table DESIG (2)
TABLE -EMPLOYEE
EID SALARY PERKS DESIG CITY
101 75000 15000 MANAGER DELHI
102 85000 25000 DIRECTOR CHENNAI
103 70000 15000 MANAGER JAIPUR
104 75000 12000 MANAGER MUMBAI
105 SALESMAN MUMBAI
106 45000 10000 SALESMAN CHENNAI
107 40000 10000 SALESMAN MUMBAI
108 32000 6500 CLERK DELHI
109 28000 7500 CLERK MUMBAI
(i) SELECT MAX(SALARY) FROM EMPLOYEE WHERE CITY IN
(‘DELHI’,’CHENNAI’ )
COMPUTER SCIENCE-(B)- 1 / 6
(ii) SELECT MIN(SALARY) FROM EMPLOYEE WHERE DESIG LIKE ”M%”;
(iii)SELECT EID, PERKS, CITY FROM EMPLOYEE WHERE PERKS < 10000 OR-
DER BY CITY DESC, PERKS ;
(iv) SELECT DESIG, MIN(SALARY) FROM EMPLOYEE GROUP BY DESIG HAV-
ING COUNT(*)>2;
27. Attempt any one from (a) or (b) (3)

a) Write a method Search( ) to read a text file "lib.txt" and display all lines having “horror” word
in it.
OR
b) Write a method Count( ) to read a text file "lib.txt" and count the lines in which there are more
than three words.
28. a) Consider the following tables TOURIST and PLACE. Write outputs for SQL queries (i) to
(iv). (2)
Table : Booking
Aid Place Bamt Bdate
P2 Paris 200000 2020-05-10
P3 Andaman 150000 2021-12-25
P1 Singapore 300000 2022-11-10
P3 Phuket 200000 2018-10-09
P2 Paris 250000 2019-10-10
P1 Bangkok 400000 2020-07-12
P2 Phuket 150000 2022-11-12
P1 Canada 200000 2018-08-03
Table : Agency
Aid Agency Pincode
P1 Maketrip 110070
P2 Travelgo 110033
P3 Kings 110009

(i) SELECT Place, COUNT(*) FROM BOOKING GROUP BY Place ;


(ii)SELECT MAX(Bamt), Min(Bamt) FROM BOOKING WHERE PLACE LIKE
“%A%” ;
(iii) SELECT Agency, Place FROM BOOKING, AGENCY WHERE BOOKING.Aid
= AGENCY.Aid AND Bamt>300000 ;
(iv) SELECT Aid, MIN(Bamt) FROM BOOKING WHERE Bdate>=”2020-01-01”
GROUP BY Aid HAVING COUNT(*) > 1;
(b) Give SQL command for the following : (1)
(i) To see how many tuples are there in each Agency in BOOKING table.
(ii) To add primary key constraint to Aid column in Agency table.
29. Write a user defined function change(L1) which accepts a list L1 to create a new list L2. The list L2
should include only those elements of L1 which appear only once in L1. (3)
COMPUTER SCIENCE-(B)- 1 / 7
For example:
L1= [10, 20, 30, 10, 20, 40]
Then L2 should be
L2 = [30, 40]
30. Attempt any one from (a) and (b) (3)
(a) Consider a nested list Grocery to store details of the articles in a grocery shop. Each element
of the list stores following information -[ino, iname, category, qoh, unitprice]. Write user
defined functions to perform the following-
(i) Push(Grocery, stack) -the function should accept the nested list Grocery and another
list stack implemented as stack as parameters and push all articles with qoh<10 from the
Grocery list in stack.
(ii) Pop(stack ) -The function accepts the list "stack" implemented as a stack as parameter
and pops an element from the stack. It also displays the deleted element and should
check for Underflow situation in the stack.
OR
(b) Consider a dictionary Cafe where each element of the dictionary consist of tableno as key
and occupancy, totbill as values where values are represented in a list. Write user defined
functions to perform the following-
(i) Push(Cafe, cafest) -the function should accept the dictionary Cafe and a list cafest imple-
mented as a stack as parameters and push all those elements of dictionary Cafe in stack
cafest whose occupancy has the value ‘No’ stored in it.
(ii) Disp(cafest)-The function should accept the list cafest implemented as a stack and dis-
play those elements for which the bill is greater than 5000.
SECTION - D
31. RIT University has to set up its new campus at Chennai. It has four department
blocks named block A, B, C and D for different functionalities. The Administrative
Office is currently located at New Delhi. (5)
Number of computers per block
BLOCK A 135

BLOCK B 15

BLOCK C 50

BLOCK D 20
Distance between various blocks:
Block A to Block B - 50 m
Block B to Block C - 115 m
Block C to Block D - 1.5 km
Block A to Block D - 270 m
Block B to Block D - 225 m
Block A to Block C - 1 km
Based on the above information, answer the following questions.
i Name the block where the server is to be installed. Justify your answer.
ii Suggest suitable topology and draw the cable layout to connect all blocks in Chennai.
iii Name the blocks where a switch should be installed.
iv What is the network type formed (out of LAN, MAN, WAN) between Block A To C.
v Suggest a protocol that shall be required to send email.
COMPUTER SCIENCE-(B)- 1 / 8
32. Attempt any one from I or II. Each Question has (a) and (b) parts
I(a) Write the output: (2)
def F1(x,y = 5):
global a
a += x+2
x -= 20//y-2
y += a // 2
print(a, x, y,sep="@")
return x
a=3
b,c = a**2, a*2
b = F1(b)
c = F1(b,c)
print(a,b,c,sep='@')
(b) The given code is written using MYSQL and Python connectivity which displays number of
articles based on qoh entered by the user from a table Grocery [ino, iname, category, qoh,
unitprice]. Write the missing statements to perform the given task- (3)
import mysql.connector
mydb = mysql.connector.connect (host = “localhost”, user =”root”, passwd=”student”)
mycur = mydb.cursor()
Qoh1 = input(“Enter Quantity on hand to be searched -”)
Q1 =”SELECT * FROM GROCERY WHERE QOH=”+Qoh1+” ”
_________________ # Statement 1 to execute the statement
rec = ____________ #Statement 2 to Retrieve the records
C = _____________ #Statement 3 to count the rows retrieved
if C == 0:
print(“No such record”)
else:
print(“Articles with QOH”, C)
OR
II
a) Write the output :

string1 = "Pre Board-2-2023"


def F1(string1):
string2=“ ”
for i in range(len(string1)):
if string1[i].islower():
string2+=string1[i].upper()
elif string1[i].isdigit():
d=int(string1[i])+1
COMPUTER SCIENCE-(B)- 1 / 9
string2+=str(d)
elif string1[i].isspace():
string2+=string1[i+1]
else:
string2+=string1[i-1]
print(string2)
F1(string1)
b) The given code is written using MYSQL and Python connectivity which displays all records
and average amount of all record of an agency based on agency number entered by the
user from a table Agency (Ano, Aname, City, Amt). Write the missing statements to perform
the given task-
import mysql.connector
mydb = mysql.connector.connect (host = “localhost”, user =”root”, passwd=”student”)
mycur = mydb.cursor()
No = input(“Enter Agency Number to be searched -”)
Q1 = ________________ # Statement 1 to assign SQL query to Q1
sum = 0
________________ # Statement 2 to execute the statement
recs = ____________ #Statement 3 to Retrieve the records
Count = mycur.rowcount
for r in recs:
print(“Record ..Details -”)
print( “No”, r[0])
print(“Name - “,r[1])
print(“Amt - “,r[3])
sum += r[3]
if Count == 0:
print(“No such Record”)
else:
avg=sum / Count
print(“Total amount”, sum)
print(“Average ”, avg)
33. Attempt any one from I) or II) (5)
I) Explain any two methods used to read data from a text file. Write a menu driven program to
perform the following -
(i) Create() - to create a csv file "Grocery.csv" to store n records of articles. Input n from
the user. Each record stores a list containing Grocery (ino, iname, category, qoh,
unitprice).
(ii) Count() - to count all records with unitprice >100.
OR
II) Explain any two methods used to write data in a csv file. Consider a file "complab.csv" to
store (Cid, yearofM, processor, RAM, HD)
COMPUTER SCIENCE-(B)- 1 / 10
i) Write a method Search( ) to read file "complab.csv" and display all computers with HD264GB
and yearofM is 2023
ii) Write a method Count( ) to read a csv file "complab.csv" and count the computers whose
processor is P5 and RAM > 64GB.
SECTION-E
34. Attempt any one from part (iii - a) or (iii - b) (1+1+2)
Consider the following table -
Table : Booking
Aid Bid Place Bamt Bdate
P1 B1 Paris 200000 2020-05-10
P2 B2 Andaman 150000 2021-12-25
P3 B3 Singapore 300000 2022-11-10
P4 B4 Phuket 200000 2018-10-09
P5 B5 Paris 250000 2019-10-10
Based on the above table answer the following -
(i) Identify which fields can be considered as alternate keys. After creating the table the database
manager realised that he has assigned 20 spaces to place instead of 30. Give command to
implement the same.
(ii) In the above table 2 more tuples are added and two attributes rdate and phno are added. and
1 tuple is removed. Give the new cardinality and degree of the above table. Note - Attempt
any one from (iii-a) or (iii-b). Each question has two parts.
(iii - a)(A) Give command to insert column phno in above given table.
(B) Give command to assign phno to all records whose Aid is P2 with “2222222222”.
OR
(iii-b) (A) Give command to decrease the bamt of all Phuket flights by 5000.
(B) Give command to delete column phno from above given table.
35. Mr "ABC" is a python programmer. He has written the following code to store 5 records of grocrey
in a binary file "grocery.dat". The file contains following information of groceries, where each record
is represented as a dictionary{"Gid": gno, "Gname": name, "category":cat, “unitprice”:unit}. He has
to now update unitprice of all articles of a category entered by the user to 50. To do the same he is
using a temporary file "temp.dat". As a python expert, help him to complete the following code.(4)
from os import remove,rename
import pickle
file = open(“grocery.dat”,”rb”)
temp = open(“temp.dat”,”wb”)
Flag, C = “n”,0
cat = input(“Enter category - “))
try:
while True:
rec=__________ # Statement - 1 to read record from grocery.dat
C +=1
if rec[“category”] == cat:
___________ # Statement - 2 to assign unitprice to 50
Flag = “y”
________________ #Statement - 3 to write edited data
COMPUTER SCIENCE-(B)- 1 / 11
else:
________________ #Statement - 4 to write unedited data
except EOFError:
file.close()
temp.close()
if flag==”n”:
print(“No such record”)
remove(“temp.dat”)
else:
remove(‘grocery.dat’)
rename('temp.dat’,’grocery.dat’)

You might also like