G12CS-QP - PB2
G12CS-QP - PB2
SECTION A
(Q1-Q18) 18X1=18Marks
1. Which of the following are valid operator in Python? 1
a) */
b) is
c) ^
d) Like
4. Consider an object obj1 = (10, 15, 25, 30). Identify the statement that will result in an error. 1
a) print(obj1[3])
b) obj[2] = obj1[1]*10
c)print(min(obj1))
d) print(len(obj1))
P a g e 1 | 11
5. Which of the following is a Python tuple? 1
a) {2,’00’,’000’}
b) [2,00,000]
c) {2: ‘00’,3:‘000’]
d) 2,00,000
6. Find and write the output of the following python code: 1
def myfunc(a):
a=a+2
a=a*2
return a
print(myfunc(2))
7. Name the argument type that can be skipped from a function call.------------------- 1
8. Select the correct output of the following code - fp.seek(5, 1) 1
a) Move file pointer five characters ahead from the current position.
b) Move file pointer five characters ahead from the beginning of a file.
c) Move file pointer five characters behind from the current position.
d) Move file pointer five characters behind ahead from the end of a file.
9. Select true statement when a file is opened using the with statement 1
a) The with statement makes exception handling complex
b) The file is automatically closed after leaving the block, and all the resources that are
tied up with the file are released.
c) File reading and writing are faster using the with statement.
d) None of these
11. In specific, if systems use separate protocols, which one of the following devices is used to link 1
two systems?
a) Repeater
b) Gateway
c) Bridge
d) Hub
P a g e 2 | 11
13. Command to remove the row(s) from table student is 1
a)drop table student
b)drop from student;
c)remove from student
d)delete from student
16. In order to open a connection with MySQL database from within Python using 1
mysql.connector package, ________ function is used.
SECTION B
(Q19-Q25) 7X2=14 Marks
19. Rewrite the following Python program after removing all the syntactical errors (if any), 2
underlining each correction:
P a g e 3 | 11
21. Shristi has written a Python program to add all the numbers of the list. Her code is having errors. 2
Rewrite the correct code and underline the corrections made.
22. What is the similarity and difference between UNIQUE and PRIMARY KEY constraints? 2
23. Compare the following: 1
a. Hacker/Cracker 1
b. IP Address/MAC Address
24. Write the output of the given code: 2
[OR ]
25. Write any two aggregate functions in SQL with an appropriate example. 2
[OR ]
Write two commands each of DDL and DML commands in SQL
P a g e 4 | 11
SECTION C
(Q26-Q30) 5X3=15 marks
26. Consider the following tables FACULTY and COURSES and give outputs for SQL queries 3
(i) to (iii)
27. Write a method COUNTLINES() in Python to read lines from text file ‘TESTFILE.TXT’ 3
and count the number of lines which are starting with capital letter.
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.
The COUNTLINES() function should display the output as:
The number of lines starting with any vowel -1
[OR]
Write a function COUNTTEXT( ), which reads a text file Book.txt and displays all
the words of the file whose length is more than 3 or those which start with ‘A’ or ‘a’
in the form of a list.
For example, if the Book.txt file contains
India is my country. They are studying.
then the output should be:
[“India”, “country”, “They”, “are”, “studying”]
P a g e 5 | 11
28. Write output for (i) to (iii) based on the tables ‘Watches’ and ‘Sale’ given below. 3
Table : Watches
Table : Sale
30. Write a Python function CREATESTACK(L), which should create two lists SO and SE from the 3
list L containing integers. The stack SO should contain all the odd elements of the list L, and the
stack SE should contain all the even elements of the list L.
Also, write a function POPSTACK( ) which should pop and print all the elements of the stack SE,
and print stack empty at the end.
[OR]
P a g e 6 | 11
Write a Python function MYSTACK(d), which should accept a dictionary d of the form roll :
name as argument. The function should create a stack MYNAME having all the names
containing ‘s’ or ‘S’.
Also, write a function POPSTACK( ) which should pop and print all the elements of the stack
MYNAME, and print stack empty at the end.
SECTION D
Q31-Q33 3 X 5=15 marks
31. Ionex Private Ltd. Patna has different divisions Marketing (A1), Sales (A2), Finance 5
(A3) and Production (A4). The company has another branch in New Delhi. The
management wants to connect all the divisions as well as all the computers of each
division (A1, A2, A3, A4) of Patna branch.
A3 to A1: 20 m
A1 to A2: 35 m
A2 to A4: 20 m
A4 to A3: 130 m
A3 to A2: 1000 m
A1 to A4: 190 m
(ii) Suggest the placement of following devices (a) Switch (b) Repeater
(iii) Suggest the division which should be made server by quoting suitable reasons.
(iv) The company wants to conduct an online video conference between employees
of the Patna and New Delhi branches. Name the protocol which will be used to send
voice signals in this conference.
(v) Suggest the topology and draw the most suitable cable layout for connecting all
the divisions of the Patna branch.
P a g e 7 | 11
32. 5
[OR]
P a g e 8 | 11
33. Write one application of a csv file. A csv file Employee.csv has three columns [EmpID, Name, 5
Salary].
(i) Write a user defined function writecsv(L) which accepts a list L from the user
containing EmpID, Name, Salary and write it to the csv file Employee.csv.
[OR]
Write one advantage of binary file over csv file. A csv file Shop.csv has three columns [ItemID,
Item, Amount].
(i) Write a user defined function countcsv() which counts the number of items in the
csv file whose amount exceeds Rs 1000.
(ii) Write a function searchcsv(Item)which accepts the Item name as parameter and
prints the amount of that Item.
P a g e 9 | 11
SECTION E
Q34-Q35 2X4=8 Marks
34. 4
[OR]
(Option for part iii only)
P a g e 10 | 11
35. 4
P a g e 11 | 11