QP-1PB-CS-2024 Set 2
QP-1PB-CS-2024 Set 2
CLASS-XII
COMPUTER SCIENCE(083)
TIME: 03:00 HOURS MM: 70
GENERAL INSTRUCTIONS
(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
20 in a column is unique and not null. (1)
Reasoning (R): The PRIMARY KEY constraint allows duplicate values
in the column.
(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
import random
i.e., Admission No. (admno) as the key and 5 subject marks in the list
29 (3)
as the value.
Each of these records is nested together to form a nested dictionary.
Write a Python function that displays all the lines containing the word
“excellent” from a text file “Myfile.txt”
30 OR (3)
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 No Section-D (4 x 4 = 16 Marks) Marks
Consider the following table FACULTY.
32 (4)
A) Write the following queries:
(i) To display the Salary of each Faculty, excluding those with salary
less than 12000.
(ii) To display all of the records sorted by Hire_date in descending
order.
(iii) To display all the Fname from the table without repetition.
(iv) Write a query to increase the salary of all the employees by 10%.
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)
Write SQL queries for the following-
(i) Display product name and brand name from the tables PRODUCT
and BRAND.
(ii) Display the structure of the table PRODUCT.
(iii) Display the average rating of Medimix and Dove brands
(iv) Display the name, price, and rating of products in descending
order of rating.
Kabir wants to write a program in Python to insert the following record in
the table named „Student‟ in MYSQL database, „SCHOOL‟ -
rno(Roll number )- integer
name(Name) - string
DOB (Date of birth) – Date
Fee – float
35 Note the following to establish connectivity between Python and MySQL: (4)
Username - root
Password - tiger
Host - localhost
The values of fields rno, name, DOB and fee has to be accepted from
the user. Help Kabir to write the program in Python.
Q No Section-E ( 5 x 2 = 10 Marks) Marks
Manoj is working in a sports college. He needs to manage the records of
the teams in each Sport. For this, he wants the following information of
the students to be stored in the binary file SPORT.DAT-
SportName
TeamName
No_Players
You, as a programmer of the company, have been assigned to do this
36 job for the college. (5)
i) Create the binary file SPORT.DAT
ii) Write a function AddTeam to input the details and add a record to
the file.
iii) Write a function, copyData(), that reads contents from the file
SPORT.DAT and copies the records with Sport name as “Basket
Ball” to the file named BASKET.DAT. The function should also
return the total number of records copied to the file BASKET.DAT.
MyPace University is setting up its academic blocks at Naya Raipur and
is planning to set up a network. The University has 3 academic blocks
and one Human Resource Centre as shown in the diagram below.
37 (5)
Distances between various blocks/centre are as follows-
Law Block 15
Technology Block 40
HR Center 115
Business Block 25