ComputerScience-SQP Set2
ComputerScience-SQP Set2
SAMPLE PAPER - II
Maximum Marks: 70 Time Allowed: 3 hours
General Instructions:
● This question paper contains 37 questions.
● All questions are compulsory. However, internal choices have been provided in somequestions.
Attempt only one of the choices in such questions
● The paper is divided into 5 Sections- A, B, C, D and E.
● Section A consists of 21 questions (1 to 21). Each question carries 1 Mark.
● Section B consists of 7 questions (22 to 28). Each question carries 2 Marks.
● Section C consists of 3 questions (29 to 31). Each question carries 3 Marks.
● Section D consists of 4 questions (32 to 35). Each question carries 4 Marks.
● Section E consists of 2 questions (36 to 37). Each question carries 5 Marks.
● All programming questions are to be answered using Python Language only.
● In case of MCQ, text of the correct answer should also be written.
SECTION - A
1. The statement is an empty statement in Python. 1
2. Which of the following is not a keyword? 1
(a) eval (b) assert (c) nonlocal (d) pass
3. What will be the output for the following Python statements? 1
D= {“Amit”:90, “Reshma”:96, “Suhail”:92, “John”:95}
print(“John” in D, 90 in D, sep= “#”)
(a) True#False (b)True#True (c) False#True (d)
False#False
4. What will the following Python statement evaluate to? 1
print (5 + 3 ** 2 / 2)
(a) 32 (b) 8.0 (c) 9.5 (d) 32.0
5. Consider the list aList=[ “SIPO”, [1,3,5,7]]. What would the following code print? 1
(a) S, 3 (b) S, 1 (c) I, 3 (d) I, 1
6. Which of the following mode in the file opening statement creates a new file if the file does not exist? 1
(a) r+ (b) w+ (c) a+ (d) Both (b) and (c)
7. Which of the following is not an integrity constraint? 1
(a) Not null (b) Composite key (c) Primary key (d) Check
8. Choose the correct command to delete an attribute A from a relation R. 1
(a) ALTER TABLE R DELETE A (b) ALTER TABLE R DROP A
(c) ALTER TABLE DROP A FROM R (d) DELETE A FROM R
9. Identify the errors in the following code: 1
MyTuple1=(1, 2, 3) #Statement1
MyTuple2=(4) #Statement2
MyTuple1.append(4) #Statement3
print(MyTuple1, MyTuple2) #Statement4
(a) Statement 1 (b) Statement 2 (c) Statement 3 (d) Statement 2 &3
10. In the relational model, relationships among relations/table are created by using keys. 1
(a) composite (b) alternate (c) candidate (d) foreign
11. The correct statement to place the file handle fp1 to the 10th byte from the current position is: 1
(a) fp1.seek(10) (b) fp1.seek(10, 0) (c) fp1.seek(10, 1) (d) fp1.seek(10, 2)
12. Which of the following aggregate functions ignore NULL values? 1
(a) COUNT (b) MAX (c) AVERAGE (d) All of these
13. is a device that forwards data packets along networks. 1
(a) Gateway (b) Modem (c) Router (d) Switch
Page 1 of 7
14. Suppose str1= ‘welcome’. All the following expression produce the same result except one. Which one? 1
(a) str[ : : -6] (b) str[ : : -1][ : : -6] (c) str[ : :6] (d) str[0] + str[-1]
15. Which of the following is a DML command? 1
(a) SELECT (b) ALTER (c) CREATE (d) DROP
16. Mandatory arguments required to connect any database from Python are: 1
(a) Username, Password, Hostname, Database name, Port
(b) Username, Password, Hostname
(c) Username, Password, Hostname, Database Name
(d) Username, Password, Hostname, Port
17 What is the output of the below program? 1
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(3, 4)
a) 3 b) 4 c) 4 is maximum d) None of the mentioned
18 What is the use of tell() method in Python? 1
(a) returns the current position of record pointer within the file
(b) returns the end position of record pointer within the file
(c) returns the current position of record pointer within the line
(d) none of the above
19 Ms. Suman is working on a binary file and wants to write data from a list to a binary file. Consider list 1
object as L1, binary file sum_list.dat, and file object as f. Which of the following can be the correct
statement for her?
a) f = open(‘sum_list.dat’,’wb’); b) f = open(‘sum_list.dat’,’rb’);
pickle. dump(L1,f) L1=pickle.dump(f)
c) f = open(‘sum_list.dat’,’wb’); d) f = open(‘sum_list.dat’,’rb’);
pickle.load(L1,f) L1=pickle.load(f)
Q20 and 21 are ASSERTION and REASONING based questions. Mark the correctchoice as: 1
(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
20 Assertion (A): Keyword arguments are related to the function calls 1
Reason (R): When you use keyword arguments in a function call, the caller identifies the arguments by
the parameter name.
21 Assertion (A): Text file stores information in ASCII or unicode characters. 1
Reason (R): In text file, there is no delimiter for a line.
SECTION-B
22 Identify the errors in the program segment given below. Rewrite the corrected codeand underline each 2
correction.
Page 2 of 7
23 Write two points of difference between HTTP and FTP. 2
OR
State the advantages and disadvantages of star topology over bus topology?
24 Consider the code given below and fill in the blanks. 2
print("Learning Exceptions...")
try:
num1 = int(input("Enter the first number"))
num2 = int(input("Enter the second number"))
quotient = (num1/num2)
print("Both the numbers entered were correct")
except ...............: # to enter only integers
print("Please enter only numbers")
else:
print("Great .. you are a good programmer")
...............: # to be executed at the end
print("JOB OVER... GO GET SOME REST")
25 What do you understand by Candidate keys in a table? Give a suitable example of candidate keys from a 2
table containing some meaningful data.
26 (i) Write the full forms of the following: 2
(a) SMTP (b) IPR
(ii) Which protocol is used in creating a connection with a remote machine?
27 What possible output(s) are expected to be displayed on screen at the time of executionof the following 2
code? Also specify the maximum and minimum value that can be assigned to variable X.
import random
L=[10,7,21]
X=random.randint(1,2)
for i in range(X):
Y=random.randint(1,X)
print(L[Y],”$”,end=” ”)
(a) 10 $ 7 $ (b) 21 $ 7 $ (c) 21 $ 10 $ (d) 7 $
OR
def changer(p, q=10):
p=p/q
q=p%q
print(p,’#’,q)
return p
a=200
b=20
a=changer(a,b)
print(a,’$’,b)
a=changer(a)
print(a,’$’,b)
28 Differentiate between Drop and Delete commands of MYSQL. Write its syntax. 2
OR
For a table “Company” having column cno, cname, department and salary, write the SQL statement to
display average salary of each department.
SECTION – C
29 A text file “Quotes .Txt” has the following data written in it: 3
Living a life you can be proud of Doing your best Spending your time with people and activities that are
important to youStanding up for things that are right even when it’s hard Becoming the best version of
Page 3 of 7
you.
Write a user defined function to display the total number of words present in the file.
OR
Write a function in Python to count the number of lines in a text file ‘STORY.TXT’ which is starting
with an alphabet ‘A’.
30 A list contains following record of course details for a University: 3
[Course_name, Fees, Duration]
Write the following user defined functions to perform given operations on the stack named 'Univ':
(a) Push_element(CourseStack,newCourse): To push an object containing the Course_name, Fees, and
Duration of a course, which has fee greater than 100000 to the stack.
(b) Pop_element(CourseStack): To pop the object from the stack and display it. Also, display
"Underflow" when there is no element in the stack.
(c) Peek_element(CourseStack): This function displays the topmost course record from the stack without
delete it. If the stack is empty display message “Empty Stack”
For Example:
If the lists of courses details are:
["MCA", 200000, 3]
["MBA", 500000, 2]
["BA", 100000, 3]
The stack should contain:
["MCA", 200000, 3]
["MBA", 500000, 2]
OR
Write separate user defined functions for the following:
(a) PUSH(N) : This function accepts a list of names, N as parameter. It then pushes only those names in
the stack named OnlyA which contain the letter 'A'
(b) POPA(OnlyA) : This function pops each name from the stack OnlyA and displays it. When the stack
is empty, the message "EMPTY" is displayed.
(c) Traverse(OnmyA) : Display all elements. If the stack is empty display message “Empty Stack”
For Example:
If the names in the list N are
['ANKITA','NITISH','ANWAR','DIPLE','HARKIRAT']
Then the stack OnlyA should store
['ANKITA','ANWAR','HARKIRAT']
And the output should be displayed as
HARKIRAT ANWAR ANKITA EMPTY
31.Predict the output of the following code snippets:
d1={1:5, 2:8, 3:12, 4:3, 5:6}
x=y=d1[1]
for k in d1:
if(d1[k] > x):
x= d1[k]
else:
if(d1[k] < y):
y = d1[k]
print(x)
print(y)
Page 4 of 7
OR
str = “Computer Science”
length = len(str)
for a in range(0, length, 2):
print(str[a:a+2]
SECTION D
32 Consider the table MobileMaster 4
M_Id M_Company M_Name M_Price M_Mf_Date
MB001 Samsung Galaxy 13000 2014-02-12
MB002 Nokia N1100 7500 2011-04-15
MB003 Realme C35 12000 2021-11-20
MB004 Oppo SelfieEx 12500 2015-08-21
Based on the data given above answer the following questions:
(i) Identify the most appropriate column, which can be considered as Primarykey.
(ii) If two columns are added and 2 rows are deleted from the table result, whatwill be the new degree
and cardinality of the above table?
(iii) Write the statements to:
a. To display details of those mobiles whose price isgreater than 8000.
b. Increase the M_Price of all mobiles manufactured after 2015 01-01 by 500.
OR
Write the output for SQL queries (i) to (iv), which are based on the table: STUDENT given below:
Page 5 of 7
AcceptStock() – to accept a record from the user and append it to the file stock.csv. The column headings
should also be added on top of the csv file. The number of records to be entered until the
user chooses ‘Y’ / ‘Yes’.
StockReport() – to read and display the stockno, stock name, price, qty and value of each stock as
price*qty. As a Python expert, help him complete the task.
34 4
Page 6 of 7
Distance between various blocks are as given below:
Page 7 of 7