CS_QP_SET-4
CS_QP_SET-4
CS (SET-4)
GENERAL INSTRUCTIONS
Q
Section-A (21x1=21 Marks) Marks
No
State True or False
1 ‘In Python delimiters and operators are the same’ (1)
(A) ‘I could eat all day’ (B) [‘I could eat ‘,’ all day’]
(C) (‘I could eat ‘, ‘ all day’) (D) (‘I could eat ‘, ‘bananas’, ‘ all day’)
What will be the output of the following code?
5 message=’I Love Python’ (1)
print(message[-1::-2]
True or False?
6 ‘The ‘else’ block in “try: except: else:” always executes.” (1)
What possible output(s) is expected from the following code?
import random
count=[‘ONE’, ’TWO’, ’THREE’, ‘FOUR’]
for k in range(3):
7 r=random.randint(k+1,3) (1)
print(count[r],end=’#’)
Q20 and Q21 are Assertion (A) and Reason(R) 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
Assertion (A): The PRIMARY KEY constraint ensures that each value in
20 a column is unique and not null. (1)
Reasoning (R): The PRIMARY KEY constraint allows duplicate values in
the column.
Explain the concept of a 'loop' in programming. How does a 'for loop' differ
22 (2)
from a 'while loop'?
(A) Define and differentiate between URL and domain name with the
help of an appropriate example
23 (2)
OR
(B) Differentiate between Switch and Gateway.
Write an SQL query to retrieve all columns from a table named Students
where the Grade is 'A'.
25 (2)
OR
What is the purpose of the JOIN clause in SQL? Explain with a brief
example.
The following Python code is intended to calculate the sum of all even
numbers in a given list. Identify and correct the errors in the program.
Rewrite the correct program underlining all the corrections.
numbers = [1, 2, 3, 4, 5, 6, 7, 8]
sum even = 0
26 (2)
for num in numbers
if num % 2 = 0:
sum even += num
Identify the correct output(s) of the following code. Also write the minimum
and the maximum possible values of the variable b.
import random
Q
Section-C (3 x 3 = 9 Marks) Marks
No
i.e., Admission No. (admno) as the key and 5 subject marks in the list as
the value.
Each of these records is nested together to form a nested dictionary.
30 Write a Python function that displays all the lines containing the word (3)
“excellent” from a text file “Myfile.txt”
OR
Write a Python function that find and displays all the words beginning with
‘w’ or ‘W’ from a text file “Paragraphs.txt”.
def fun_para(x=5,y=10,z=1005):
z=x/2
res=y//x+z
31 return res (3)
a,b,c=20,10,1509
print(fun_para(),fun_para(b),sep='#')
res=fun_para(10,20,6015)
print(res, "@")
print(fun_para(z=999,y=b,x=5), end="#@")
Q
Section-D (4 x 4 = 16 Marks) Marks
No
Consider the following table FACULTY.
OR
B) Write the output of:
(i) Select * from FACULTY where salary > 12000;
(ii) Select Fname from FACULTY WHERE Hire_date between 01-01-
2000 and 31-12-2006;
(iii) Select AVG(SALARY) from FACULTY;
(iv) Select * from FACULTY where Fname like “R%”;
i) Write the header row and records of five employees into the file.
ii) Appends a new record in the CSV file.
34 (4)
Law Block 15
Technology Block 40
HR Center 115
Business Block 25