0% found this document useful (0 votes)
104 views10 pages

Computer Science - (A) - 1 / 1

This document contains a pre-board examination for computer science with 5 sections (A-E). Section A contains 18 multiple choice questions worth 1 mark each. Section B contains 7 very short answer questions worth 2 marks each. Section C contains 5 short answer 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 in question 34 part c. All programming questions must be answered using Python.

Uploaded by

Krishna
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)
104 views10 pages

Computer Science - (A) - 1 / 1

This document contains a pre-board examination for computer science with 5 sections (A-E). Section A contains 18 multiple choice questions worth 1 mark each. Section B contains 7 very short answer questions worth 2 marks each. Section C contains 5 short answer 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 in question 34 part c. All programming questions must be answered using Python.

Uploaded by

Krishna
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/ 10

COMPUTER SCIENCE-(A)- 1 \ 1

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

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 produces an error? (1)
(A) “Pre” + ‘Board’ (B) 1+ 2
(C) “Pre’+ “Board” (D) ‘1’+ “2”

2. What is the return type of function id? (1)


(A) int (B) float
(C) bool (D) dict

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


(A) An object needs to be declared explicitly
(B) Objects can be mutable or immutable
(C) Dynamic typing is applicable for every object
(D) Every object needs to have a datatype

4. Which of the following will NOT raise an error if the given key is not found in the dictionary (1)
(A) del statement (B) pop()
(C) get () (D) All of these

5. Which of the following is correctly evaluated for this function?


pow(x,y,z)
(A) (x**y) / z (B) (x / y) * z
(C) (x**y) % z (D) (x / y) / z

6. The readlines( ) method returns____________ (1)


(A) a string (B) list of strings
(C) list of single characters (D) a list of integers
COMPUTER SCIENCE-(A)- 1 \ 2
7. A Table in MySQL can have ________ foreign keys. (1)
a. Many b. 1
c. 2 d. depends on DBMS
8. A primary key of a table is a _______ key in another table (1)
a. Foreign Key b. Alternate Key
c. Secondary Key d. Composite Key
9. Which error will be resulted by the following statements (1)
>>> L1 = [“A”, “B”, “C”] # Statement 1
>>> L1.remove(“D”) # Statement 2
a. TypeError b. IndexError
c. ValueError d. NameError
10. Which RDBMS operation is depicted by the following statements. (1)
SELECT * FROM emp, dept WHERE emp.eid = dept.eid;

a. Cross Join b. Equi Join


c. Natural Join d. Inner Join
11. Yashi wants to check whether her name is listed in a binary Shortlisted.dat or not. Which command
she can write to open and check the file: (1)
a. a=open(“Shortlisted.dat”,”r+”) b. with open (“Shortlisted.dat’,’rb”) as a:
c. with open (“Shortlisted.dat’,’r”) as a: d. All of these

12. The SQL clause used to retrieve unique values in a field is __________ (1)
a. UNIQUE b. NOT NULL
c. DISTINCT d. IS NULL
13. ________protocol is used to download files. (1)
a. HTTP b. FTP
c. TCP/IP d. HTTPS
14. What will be the following expression evaluated to in Python? (1)
20*2 + (6 // 2) **2 ** 2
a. 41 b. 141
c. 121 d. 52
15. In MySQL, __________ keyword can be used to to put conditions on a group (1)

a. WHERE b. HAVING
c. ORDER BY d. GROUP BY
16. ______ method is used to make the changes permanent in a database through MySQL connec-
tivity. (1)
a. update( ) b. execute( )
c. commit( ) c. cursor( )
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:
COMPUTER SCIENCE-(A)- 1 \ 3
Assertion (A): Python Data types are used to identify the type of data.
Reasoning (R): All categories of operators can be used with objects of all datatypes.

(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): CSV is a file format for data storage which looks like a text file.
Reasoning (R): The information is organized with one record on each line and each field is
seperated by a comma.
(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.

SECTION - B
19. Rewrite the corrected code after removing the errors from the following code. Also underline the
corrections made: (2)
t1 = 10,20,30,40,50
def F1():
obj1=index(t1(40))
t1[4] = “change”
print(t1.max())
del t1[3]
return
print(F1())
20. What do you mean by protocol. Explain any 2 netwrok protocols. (2)
OR
Differentiate between guided and unguided media. Explain any one from both the categories.
21. Predict the output of the given code : (2)
(i) >>> L1, L2 = [10, 20, 30], [10, 20]
>>> L1 > L2
(ii) >>>str1 = "My School is DPS VK"
>>> str1. partition("DPS")
COMPUTER SCIENCE-(A)- 1 \ 4
(iii)
d = {“a”:1,”b”:2}
str=” ”
for k in d:
str1 += str(d[k])*2 + " "
print(str1[: :-1])
22. Define the following : (2)
(i) Column alias
(ii) Unique constraint
(iii) Relational operator
(iv) Between operator

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


(i) VOIP (ii) ARPANet
24. Predict the output : (2)
Attempt any one from (a) or (b)
(a) def f1():
stat = [3,6,4,-5]
avail = stat [-2]
stat [-4 ] = stat[-2] + stat[-4]
for k in range(4):
if k%2 == 0 and stat[k] > 0:
stat[k] += stat[3-k]
else:
stat[k] += 3*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 = [12,10,15,18,20,25]
L2 = [["Chemistry", "Physics", "English", "Computer"],[10,20,30]]
L1[2]=L1[3]
L1[0]=L1[1]
L2= [L2[0][2]]+[L2[-1][0]]+ L1[2:4]
print(L2)
COMPUTER SCIENCE-(A)- 1 \ 5
25. Attempt any one from (I) or (II) (2)
I)
a) Give any two features of MYSQL.
b) Kripa is using a table EMPLOYEE. It has the following columns: Code, Name, Salary,
Deptcode She wants to display maximum salary Department wise. She wrote the following
command:
SELECT Deptcode, Max(Salary) FROM EMPLOYEE;
But did not get the desired result. Rewrite the above query with necessary change to help
her get the desired output.
OR
II)
a) Explain the use of IN and NOT IN operators in MySQL with an example.

SECTION - C
26. (a) Consider the following tables - (1)

What will be the output of the following statements :


(i) SELECT CUSTOMERS.CNO, CNAME, QTY FROM CUSTOMERS, PUR-
CHASES WHERE CUSTOMERS.CNO = PURCHASES.CNO AND
CITY='DELHI';
(ii) SELECT CITIES, QTY FROM CUSTOMER, PURCHASES WHERE
CUSTOMERS.CNO = PURCHASES.CNO AND QTY IN (7, 10, 15);
(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 7500 CLERK DELHI
109 28000 7500 CLERK DELHI
(i) SELECT MIN(PERKS) FROM EMPLOYEE WHERE CITY NOT IN
(‘DELHI’,’CHENNAI’ )
COMPUTER SCIENCE-(A)- 1 \ 6
(ii)
SELECT AVG(SALARY) FROM EMPLOYEE WHERE DESIG =”SALESMAN”;
(iii)
SELECT EID, PERKS FROM EMPLOYEE WHERE PERKS > 10000 ORDER BY
DESIG, PERKS;
(iv) SELECT CITY, AVG(PERKS) FROM EMPLOYEE GROUP BY CITY HAVING
COUNT(*)>2;
27. Attempt any one from (a) or (b)
a) Write a method COUNT( ) to read a text file "PRE1.txt" and display the lines
in which the word "EXAM" appears more than once.
OR
b) Write a method SERACH( ) to read a text file "PRE1.txt" and count the
number of lines in which there are more than 5 vowels.
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 Bnagkok 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 Aid, COUNT(*) FROM BOOKING GROUP BY Aid ;


(ii)SELECT MIN(Bdate), MAX(Bdate) FROM BOOKING ;
(iii)
SELECT Agency, Bdate FROM BOOKING, AGENCY WHERE BOOKING.Aid
= AGENCY.Aid AND Bdate >=”2021-01-01”;
(iv) SELECT Aid, MAX(Bamt) FROM BOOKING WHERE Bdate>=”2019-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 Place in BOOKING table.
(ii) To remove the primary key constarint from booking 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 more than once in L1. (3)
For example:
L1= [10, 20, 30, 10, 20, 40]
Then L2 should be
L2=[10, 20]
COMPUTER SCIENCE-(A)- 1 \ 7
30. Attempt any one from (a) and (b) (3)
(a) Consider a nested tuple Movie to store details of the movies. Each element of the tuple stores
following information -(mno, name, category, yearofrelease, costing). Write user defined
functions to perform the following-
(i) Push(Movie, stack) -the function should accept the nested tuple Movie and list stack
implemented as stack as parameters and push all movies released in the year 2020 from
the tuple Movie 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 Complab where each element of the dictionary consist of Compno as
key and model, processor, RAM, HD as values. The values are stored in a list. Write user
defined functions to perform the following-
(i) Push(Complab, stack) -the function should accept the dictionary Complab and a list
stack implemented as a stack as parameters and push all elements from Complab with
HD-256GB in the stack.
(ii) Disp(stack)-The function should accept list stack implemented as a stack and display
the total number of computers with P5 processor.
SECTION - D
31. Bright Study University is setting up its academic centres in Gurugram and planning to set up a
network. The university has 3 academic centres and one administration centre. (5)
Number of computers per block

Business Centre 25
Technology Centre 55
Admin Centre 130
Law Centre 35
Distance between various blocks:

Business Centre Law Centre 60 m


Law Centre Technology Centre 90 m
Law Centre Admin Centre 115
Business Centre Technology Centre 40 m
Business Centre Admin Centre 45 m
Technology Centre Admin Centre 25 m
Based on the above information, answer the following questions.
(i) Name the centre where the server is to be installed. Justify your answer.
(ii) Suggest and draw a cable layout to efficiently connect various centres within the university.
(iii) Which device will you suggest to be placed/ installed in each of these centres to efficiently
connect all the computers within the university?
(iv) The university is planning to connect its admin office in the closest big city, which is more than
350 km from the university. Which type of network out of LAN, MAN or WAN will be
formed? Justify your answer.
(v) Suggest a protocol that shall be required to receive email.
32. Attempt any one from I or II. Each Question has (a) and (b) parts
COMPUTER SCIENCE-(A)- 1 \ 8
I(a) Write the output: (2)
x=5
y = 10
def func():
global x
y=x*3
x = y + 20
print("x = ",x,"y = ",y)
return x + y
x += func()
print("x = ",x,"y = ",y)
(b) The given code is written using MYSQL and Python connectivity which displays number of
movies based on a category entered by the user from a table Movie (mno, name, category,
yearofrelease, costing). 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()
cat = input(“Enter category to be searched -”)
Q1 =”SELECT * FROM MOVIE WHERE category=’”+cat+”’’ ”
_________________ # Statement 1 to execute the statement
rec = ____________ #Statement 2 to Retrieve the records
Count = _____________ #Statement 3 to count the rows retrieved
if Count == 0:
print(“No such record”)
else:
print(“Total number of movies”, Count)
OR
II
a) Write the output :
string1 = "PB-Exam 2023"
def F1(string1):
string2=''
for i in range(len(string1)):
if string1[i].isupper():
string2+=string1[i].lower()
elif string1[i].isdigit():
d=int(string1[i])+2
string2+=str(d)
elif string1[i].isspace():
string2+=string1[i+1]
else:
COMPUTER SCIENCE-(A)- 1 \ 9
string2+=string1[i-1]
print(string2)
F1(string1)
b) The given code is written using MYSQL and Python connectivity which displays all records
and total amount of all record of an agency based in a city 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()
City1 = input(“Enter city 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:
print(“Total amount”, sum)
33. Attempt any one from I) or II) (5)
I) Explain any two methods to read data from a csv file. Write a menu driven program to
perform the following -
(i) Create() - to create a csv file "movie.csv" to store n records of movies. Input n from the
user. Each record stores a list containing Movie (mno, name, category, yearofrelease,
costing).
(ii) Count() - to count all records with release year as 2020.
OR
II) Explain any two methods to write data in a text file. Consider a file "lib.csv" which stores
records of books in the form of a list. Each record stores [bookid, bname, category, price]
i) Write a method Search( ) to read file "lib.csv" and display all books of horror category with
price more than 500.
ii) Write a method Count( ) to read a csv file "lib.csv" and count the books whose name contains
more than 2 vowels and are priced more than 500.
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
COMPUTER SCIENCE-(A)- 1 \ 10
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 candidate keys. After creating the table the data-
base manager realised that he has not given 2 digits after decimal in Bamt field. Digits before
decimal are 6. Give command to change implement the same.
(ii) In the above table 1 more tuple is added and one attribute rdate is added. and two tuples are
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 add column rdate in above given table.
(B) Give command to assign rdate of all Paris fligts with “2023-01-30”.
OR
(iii-b) (A) Give command to increase the bamt of all Singapore flights by 10000.
(B) Give command to delete column place from above given table.
35. Mr "ABC" is a python programmer. He has written the following code to store 5 records of books
in a binary file "movie.dat". The file contains following information of books. Where each record is
represented as a dictionary {"Mno": mno, "Mname": mname, "category":cat, “Ratings”:ratings}. He
has to now update ratings of all movies of a given mno entered by the user to 9. 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(“movie.dat”,”rb”)
temp = open(“temp.dat”,”wb”)
Flag, C = “n”,0
mno1= input(“Enter movie number - “))
try:
while True:
rec=__________ # Statement-1 to read record from movie.dat
C +=1
if rec[“mno”] == mno1:
___________ # Statement- 2 to assign category to 9
Flag = “y”
________________ #Statement-3 to write edited data
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(‘book.dat’)
rename('temp.dat’,’book.dat’)

You might also like