CS-QP-2

Download as pdf or txt
Download as pdf or txt
You are on page 1of 10

केन्द्रीय विद्यालय सं गठन, कोलकाता सं भाग

KENDRIYA VIDYALAYA SANGATHAN, KOLKATA REGION


प्रथम प्री-बोर्ड परीक्षा / 1st PRE-BOARD EXAMINATION- 2024-25
कक्षा /CLASS- XII अविकतम अं क /MAX MARKS- 70
विषय /SUB- Computer Science (083) समय /TIME- 03 घं टे / Hours
General Instructions:
● This question paper contains 37 questions.
● All questions are compulsory. However, internal choices have been provided in some
questions. 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.

Q No. Section-A (21 x 1 = 21 Marks) Marks

1. State True or False:


(1)
The Python interpreter generates compile time error if only try block is written
without any catch or finally block.
2. Identify the output of the following code snippet:
text = "copyPYTHON"
text=text.replace('PY','#')
print(text)
(1)
(A) co##THON (B) Copy#THON (C) NOHT#ypoc (D) copy#THON

3. What will the output of the following expression? 15/4*8//6


(1)
(A) 4.0 (B) 5 (C) 5.0 (D) 3.0
4. What is the output of the expression?
text='inspirational idea'
print(text.split('i'))
(1)
(A) ('', 'nsp', 'rat', 'onal ', 'dea')
(B) ['', 'nsp', 'rat', 'onal ', 'dea']
(C) ['nsp', 'rat', 'onal ', 'dea']
(D) {'nsp', 'rat', 'onal ', 'dea'}
5. What will be the output of the following code snippet?
msg="Viksit BHARAT" (1)
print(msg[-2::-2].capitalize())
(A) Aabtsi (B) AABTSI (C ) Vkt Baa (D) Error

Page: 1/10
6. What will be the output of the following code?
tuple1 = (1, 2, 3) tuple2 = tuple1
tuple1 += (4,)
print(tuple1 == tuple2)
(A) True (B) False (C) tuple1 (D) Error (1)
7. If my_dict is a dictionary as defined below, then which of the following
statements will raise an exception?
my_dict = {'apple': 10, 'banana': 20, 'orange': 30}
(A) my_dict.get('orange') (1)
(B) print(my_dict['apple', 'banana'])
(C) my_dict['apple']=20
(D) print(str(my_dict))
The statement which is used to get the number of rows fetched by execute() method
8.
of cursor:
(A) cursor.rowcount (B) cursor.countrows() (1)
(C) cursor.allrows() (D) cursor.countrows()

9. If a table which has one Primary key and two alternate keys. How many Candidate
(1)
keys will this table have?
(A) 1 (B) 2 (C) 3 (D) 4

10. Write the missing statement to complete the following code:


file = open("example.txt", "r")
data = file.read(100)
___________________#Move the file pointer to the beginning of the file (1)
next_data = file.read(50)
file.close()

11. State whether the following statement is True or False:


(1)
A code can run without removing all the logical errors.

12. What will be the output of the following code?


c = 10
def add():
global c
c=c+2
print(c,end='#')
add() (1)
c=15
print(c,end='%')

(A) 12%15# (B) 15#12% (C ) 12#15% (D) 12%15#


13. All aggregate functions except _______ ignore null values in their input collection. (1)
(A) Count (attribute) (B) Count (*) (C) Avg (D) Sum

Page: 2/10
14. What will be the output of the query?
SELECT * FROM products WHERE product_name LIKE 'App%';
(A) Details of all products whose names start with 'App'
(B) Details of all products whose names end with 'App' (1)
(C) Names of all products whose names start with 'App'
(D) Names of all products whose names end with 'App'

15. In which datatype the value stored is padded with spaces to fit the specified length.
(1)
(A) DATE (B) VARCHAR (C ) FLOAT (D) CHAR
Which aggregate function can be used to find the cardinality of a table? (1)
16.
(A) sum() (B) count() (C ) avg() (D) max()

17. Which protocol is NOT used to transfer mails over the Internet?
(1)
(A) SMTP (B) IMAP (C) FTP (D) POP3
18. A _________ is a network device that amplifies and restores the signals for long
distance communications.
(1)
(A) Repeater (B) Hub (C) Switch (D) Router

19. ______is a method of implementing a telecommunications network in which two


network nodes establish a dedicated communications channel through the network (1)
before the nodes may communicate.
(A)circuit switching (B) message switching (C) packet switching (D) All of these
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

20. Assertion (A): If the arguments in the function call statement match the number
and order of arguments as defined in the function definition, such arguments are
(1)
called positional arguments.
Reasoning (R): During a function call, the argument list first contains default
argument(s) followed by the positional argument(s).

21. Assertion (A): A SELECT command in SQL can have both WHERE and HAVING clauses.
Reasoning (R): WHERE and HAVING clauses are used to check conditions,
(1)
therefore, these can be used interchangeably.
Q No Section-B ( 7 x 2=14 Marks) Marks

22. How is a mutable object different from an immutable object in Python?


How is pop() function different from remove() function in Python Lists? (2)

23. (i) Which out of the following operators will NOT work with a string? + , -, *, not
(2)
(ii) What will be the output of the following expression?
myTuple = ("John", "Peter", "Vicky")
Page: 3/10
x = "#".join(myTuple)
print(x)

24. If L1=[1,2,3,2,1,2,4,2, . . . ], and L2=[10,20,30, . . .], then


(Answer using builtin functions only)
(I)
A) Write a statement to count the occurrences of 4 in L1. (1)
OR
B) Write a statement to sort the elements of list L1 in ascending order.

(II) (1)
A) Write a statement to insert all the elements of L2 at the end of L1.
OR
B) Write a statement to reverse the elements of list L2.

25. What possible outputs(s) will be obtained when the following code is executed? What
is the possible minimum and maximum value x can take?

import random

List = ['CTC', 'BBSR', 'KDML', 'PURI']

for y in range (4): (2)

x = random.randint (1,3)

print (List[x], end = '#')

Options are:

a) KDML#PURI#BBSR#CTC# b) KDML#KDML#PURI#PURI#
c) BBSR#KDML#BBSR#KDML# d) All of these 3 options are possible

The given Python code to print all Prime numbers in an interval (range) inclusively.
26.
The given code accepts 02 number (low & high) as arguments for the function (2)
Prime_Series() and return the list of prime numbers between those two numbers
inclusively. Observe the following code carefully and rewrite it after removing all
syntax and logical errors. Underline all the corrections made.
Def Prime_Series(low, high)
primes = [ ]
for i in range(low, high + 1):
flag = 0
if i < 2:
continue
if i == 2:
primes.append(2)
continue
for x in range(2, i):

Page: 4/10
if i % x == 0:
flag = 1
continue
if flag == 0:
primes.append(x)
returns prime
low=int(input("Lower range value: "))
high=int(input("High range value: ")
print(Prime_Series())

27. (I)
A) What constraint should be applied on a table column so that duplicate (2)
values are not allowed in that column, but NULL is allowed.
OR
B) What constraint should be applied on a table column so that NULL is not
allowed in that column, but duplicate values are allowed?

(II)
A) Write an SQL command to remove the Primary Key constraint from a
table, named MOBILE. M_ID is the primary key of the table.
OR
B) Write an SQL command to make the column M_ID the Primary Key of
an already existing table, named MOBILE.

28. A) List any two difference between Star topology and Bus topology.
OR (2)
B) Expand the term TCP/IP. What is the significance of a Gateway in a network with
traffic?

Q No. Section-C ( 3 x 3 = 9 Marks) Marks

29. A) Write a Python function that displays all the words containing “@gov”
from a text file "Email.txt".
OR (3)
B) Write a Python function that finds and displays all the words smaller than 6
characters from a text file "Friends.txt".

Page: 5/10
30. A) You have a stack named BooksStack that contains records of books. Each
book record is represented as a list containing book_title, author_name, and
publication_year.
Write the following user-defined functions in Python to perform the specified
operations on the stack BooksStack:
(I) push_book(BooksStack, new_book): This function takes the stack
BooksStack and a new book record new_book as arguments and pushes
the new book record onto the stack.
(II) pop_book(BooksStack): This function pops the topmost book record from
the stack and returns it. If the stack is already empty, the function should
display "Underflow".
(III) peep(BookStack): This function displays the topmost element of the (3)
stack without deleting it. If the stack is empty, the function should
display 'None'.
OR
(B) A dictionary, StudRec, contains the records of students in the following
pattern:
{admno: [m1, m2, m3, m4, m5]} , 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. Write the
following user-defined functions in the Python code to perform the specified
operations on the stack named BRIGHT.
(i) Push_Bright(StudRec): it takes the nested dictionary as an argument and
pushes a list of dictionary objects or elements containing data as {admno: total
(sum of 5 subject marks)} into the stack named BRIGHT of those students with a
total mark >350.
(ii) Pop_Bright(): It pops the dictionary objects from the stack and displays them.
Also, the function should display “Stack is Empty” when there are no elements in
the stack.
For Example: if the nested dictionary StudRec contains the following data:
StudRec={101:[80,90,80,70,90], 102:[50,60,45,50,40], 103:[90,90,99,98,90]}
Thes Stack BRIGHT Should contain: [{101: 410}, {103: 467}]
The Output Should be:
{103: 467}
{101: 410}
If the stack BRIGHT is empty then display: Stack is Empty

Page: 6/10
31. Predict the output of the following code:

d = {"apple": 15, "banana": 7, "cherry": 9}

str1 = ""
for key in d:
str1 = str1 + str(d[key]) + "@" + “\n”
str2 = str1[:-1]

print(str2) (3)

OR

Predict the output of the following code:

line=[4,9,12,6,20]
for I in line:
for j in range(1,I%5):
print(j,’#’,end=””)
print()
Q No. Section-D ( 4 x 4 = 16 Marks) Marks

32. Consider the table ORDERS as given below

O_Id C_Name Product Quantity Price


1001 Jitendra Laptop 1 12000
1002 Mustafa Smartphone 2 10000
1003 Dhwani Headphone 1 1500
Note: The table contains many more records than shown here.
(4)
A) Write the following queries:
(I) To display the total Quantity for each Product, excluding
Products with total Quantity less than 5.
(II) To display the orders table sorted by total price in descending order.
(III) To display the distinct customer names from the Orders table.
(IV) Display the sum of Price of all the orders for which the quantity is null
OR
B) Write the output of the following queries:
(I) Select c_name, sum(quantity) as total_quantity from orders group by c_name;
(II) Select * from orders where product like '%phone%';
(III) Select o_id, c_name, product, quantity, price from orders where price
between 1500 and 12000;
(IV) Select max(price) from orders;

Page: 7/10
33. Mr. Snehant is a software engineer working at TCS. He has been assigned to develop
code for stock management; he has to create a CSV file named stock.csv to store the
stock details of different products.The structure of stock.csv is : [stockno, sname,
price, qty], where stockno is the stock serial number (int), sname is the stock name
(string), price is stock price (float) and qty is quantity of stock(int).
Mr. Snehant wants to maintain the stock data properly, for which he wants to write
the following user-defined functions:
(4)
(I) 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’.
(II) 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.

Table Name: TRADERS


34.
TCODE TNAME CITY
T01 RELIANCE DIGITAL MUMBAI
T02 TATA DIGITAL BHUBANESHWAR
T03 BIRLA DIGITAL NEW DELHI

Table Name: STOCK


SCODE SNAME QTY PRICE BRAND TCODE (4)
1001 COMPUTER 90 45000 DELL T01
1006 LCD PROJECTOR 40 42000 NEC T02
1004 IPAD 100 55000 APPLE T01
1003 DIGITAL CAMERA 160 15000 SAMSUNG T02
1005 LAPTOP 600 35000 HP T03
Write SQL queries for the following:
(i) Display the SNAME, QTY, PRICE, TCODE, and TNAME of all the stocks in the STOCK
and TRADERS tables.
(ii) Display the details of all the stocks with a price >= 35000 and <=50000 (inclusive).
(iii) Display the SCODE, SNAME, QTY*PRICE as the “TOTAL PRICE” of BRAND “NEC” or
“HP” in ascending order of QTY*PRICE.
(iv) Display TCODE, TNAME, CITY and total QTY in STOCK and TRADERS in each TCODE.

Page: 8/10
35. A table, named STATIONERY, in ITEMDB database, has the following structure:

Field Type
itemNo int(11)
itemName Varchar(15)
Price Float
Qty Int(11)

(4)
Write the following Python function to perform the specified operation:
AddAndDisplay(): To input details of an item and store it in the table STATIONERY.
The function should then retrieve and display all records from the STATIONERY table
where the Price is greater than 120.

Assume the following for Python-Database connectivity: Host:


localhost, User: root, Password: Pencil

Q.No. SECTION E (2 X 5 = 10 Marks) Marks


a. Write one point of difference between CSV file and Binary file.
36.
Reshabh is a programmer, who has recently been given a task to write a python code to
perform the following binary file operations with the help of two user defined (1+2+2)
functions/modules:
b. AddStudents() to create a binary file called STUDENT.DAT containing student
information – roll number, name and marks (out of 100) of each student.
c. GetStudents() to display the name and percentage of those students who have a
percentage greater than 75. In case there is no student having percentage > 75 the
function displays an appropriate message. The function should also display the average
percent.

FutureTech Corporation, a Bihar based IT training and development company, is (5)


37.
planning to set up training centers in various cities in the coming year. Their first center
is coming up in Surajpur district. At Surajpur center, they are planning to have 3
different blocks - one for Admin, one for Training and one for Development. Each block
has number of computers, which are required to be connected in a network for
communication, data and resource sharing. As a network consultant of this company,
you have to suggest the best network related solutions for them for issues/problems
raised in question nos. (i) to (v), keeping in mind the distances between various
blocks/locations and other given parameters.

Page: 9/10
Distance between various block and locations:
BLOCK DISTANCE
Development to Admin 28 m
Development to Training 105 m
Admin to Training 32 m
Surajpur campus to Coimbatore campus 340 km

Number of Computers
BLOCK Number of Computers
Development 90
Admin 40
Training 50

(i) Suggest the most appropriate block/location to house the SERVER in the Surajpur
center (out of the 3 blocks) to get the best and effective connectivity. Justify your
answer.
(ii) Suggest why should a firewall be installed at the Surajpur Center?
(iii) Suggest the best wired medium and draw the cable layout (Block to Block) to
most efficiently connect various blocks within the Surajpur Center.
(iv) Suggest the placement of the following devices with appropriate reasons:
a) Switch/Hub b) Router

(v)
(A) Suggest the best possible way to provide wireless connectivity between Surajpur
Center and Raipur Center.
OR
(B) What type of network (PAN, LAN, MAN, or WAN) will be set up among the
computers connected in the SURAJPUR campus?

Page: 10/10

You might also like