Location via proxy:   [ UP ]  
[Report a bug]   [Manage cookies]                

QP_CS_XII_Set2

Download as docx, pdf, or txt
Download as docx, pdf, or txt
You are on page 1of 9

कोड(Code)-KVS(DR)/2024/AN

KENDRIYA VIDYALAYA SANGATHAN, DELHI REGION


Pre- Board-I Examination -2024-25
Class -XII Subject: Computer Science
M.M. – 70 Time- 3hr .
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 SelecSat
 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)


A string is immutable in Python. Every time when we modify the string, Python
Always create a new String and assign a new string to that variable.

2. What is the output of the following code? (1)


listOne = [20, 40, 60, 80]
listTwo = [20, 40, 60, 80]
print(listOne == listTwo)
print(listOne is listTwo)

a) True b) True c) False d) False

True False True False

3. What is the output of the following code? (1)


var= "James Bond"
print(var[2::-1])

a) Jam b)dno c) maJ d) dnoB semaJ

4. What is the output of the following code? (1)


var = "James" * 2 * 3
print(var)

a) JamesJamesJamesJamesJamesJames
b) JamesJamesJamesJamesJames
c) Error: invalid syntax
d) None

5. Which of the following statement prints hello\example\test.txt? (1)


a) print(“hello\example\test.txt”)
b) print(“hello\\example\\test.txt”)
c) print(“hello\”example\”test.txt”)
d) print(“hello”\example”\test.txt”)

6. Is the following Python code valid? (1)


>>> a=(1,2,3)
>>> b=a.update(4,)
a) Yes, a=(1,2,3,4) and b=(1,2,3,4)
b) Yes, a=(1,2,3) and b=(1,2,3,4)
c) No because tuples are immutable
d) No because wrong syntax for update() method

7. What will be the output of the following Python code snippet? (1)
total={}
def insert(items):
if items in total:
total[items] += 1
else:
total[items] = 1
insert('Apple')
insert('Ball')
insert('Apple')
print (len(total))
a) 3 b) 1 c) 2 d) 0
8. What will be the output of the following Python code? (1)
s="a@b@c@d"
a=list(s.partition("@"))
print(a)
b=list(s.split("@",3))
print(b)
a) [‘a’,’b’,’c’,’d’] b)[‘a’,’@’,’b’,’@’,’c’,’@’,’d’]
[‘a’,’b’,’c’,’d’] [‘a’,’b’,’c’,’d’]

c) [‘a’,’@’,’b@c@d’] d) [‘a’,’@’,’b@c@d’]
[‘a’,’b’,’c’,’d’] [‘a’,’@’,’b’,’@’,’c’,’@’,’d’]

9. Which of the following functions ignore NULL values? (1)


a) MAX b) COUNT c) SUM d)All of the above

10. Which of the following is not an exception handling keyword in Python? (1)
a) try b) except c) accept d) finally
11. What will be the output of the following Python code? (1)
a=10
b=20
def change():
global b
a=45
b=56
change()
print(a)
print(b)
a) 10 b) 45 c) 10 d) Syntax Error
56 56 20

12. Which device connects an organization's network with the outside world of the (1)
Internet?
a) Hub b) Modem c) Gateway d) Repeater
13. Which data type has a fixed length in the database. (1)
a)Varchar(5) b) Char(n) c) Longchar(n) d) None of the above.

14. What will be the output of the following Python code? (1)
def display(b, n):
while n > 0:
print(b,end="")
n=n-1
display('z',3)
a) zzz b) zz c) An exception is executed d) Infinite loop

15. Which of the following allows you to connect and login to a remote computer? (1)
a) SMTP b) HTTP c) FTP d) Telnet

16. Consider the following query (1)


SELECT name FROM stu WHERE subject LIKE “ ------ Computer Science”;
Which of the following has to be added into the blank space to select the subject
which has computer Science as its ending string ?
a) $ b) _ c) II d) %

17. Which address is used by the router to forward packets? (1)


a) IP address b) MAC address c) Port address d) TCP header

18. Which of the following will you use in the following query to display the unique (1)
values of the column dept_name?
SELECT _________ dept_name FROM Company;

a)All b) Unique c) Distinct d) Name

19. A Database Administrator needs to display the average pay of workers from each (1)
departments with more than five employees. Which SQL query is correct for this
task?
a) SELECT DEPT, AVG(SAL) FROM EMP WHERE COUNT(*) > 5 GROUP BY DEPT;
b) SELECT DEPT, AVG(SAL) FROM EMP HAVING COUNT(*) > 5 GROUP BY DEPT;
c) SELECT DEPT, AVG(SAL) FROM EMP GROUP BY DEPT WHERE COUNT(*) >5;
d) SELECT DEPT, AVG(SAL) FROM EMP GROUP BY DEPT HAVING COUNT(*)> 5;

Q 20 and 21 are ASSERTION AND REASONING 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): Python overwrites an existing file or creates a non- existing file (1)
when we open a file with ‘w’ mode.
Reason(R): a+ mode is used only for writing operations

21. Assertion ( A): In SQL, the aggregate function Avg() calculates the average value (1)
on a set of values and produces a single result.
Reason ( R): The aggregate functions are used to perform some fundamental
arithmetic tasks such as Min(), Max(), Sum() etc
Q No Section-B ( 7 x 2=14 Marks) Marks

22. What will be the output of the following code: (2)


i=1
while True:
if i%7 == 0:
break
print(i)
i += 1

23. Predict the output of the Python code given below: (2)
a=tuple()
a=a + tuple(“Python”)
print(a)
print(len(a))
b=(10,20,30)
print(len(b))

24. A) Consider the following list of elements and write Python statement to print (2)
the
output of each question.
elements=['apple',200,300,'red','blue','grapes']
i) print(elements[3:5])
ii) print(elements[::-1])
OR
B) Consider the following list exam and write Python statement for the following
questions:
exam=[‘english’,’physics’,’chemistry’,’cs’,’biology’]
i) To insert subject “maths” as last element
ii) To display the list in reverse alphabetical order

25. Predict the output of the following: (2)


def Display(str):
m=""
for i in range(0,len(str)):
if(str[i].isupper()):
m=m+str[i].lower()
elif str[i].islower():
m=m+str[i].upper()
else:
if i%3==0:
m=m+str[i-1]
else:
m=m+"$"
print(m)
Display('HarryPotter@9.0')

26. Rewrite the following code in python after removing all syntax error(s). (2)
Underline each correction done in the code.
25 = Num
WHILE Num<=100:
if Num=>50:
print(Num)
Num=Num+10
else
print(Num*2)
Num=Num+5

27. A) Identify the type of topology from the following: (2)


(i) Each node is connected with the help of a single cable.
(ii) Each node is connected with central switching through independent
cables.
OR
B) Write one advantage and one disadvantage of bus topology.

28. A) A table Employee has 8 columns but no row. Later, 8 new rows are inserted (2)
and 2 rows are deleted in the table. And another table Dept has 5 rows and 4
columns. What is the degree and cardinality of the Cartesian Product of tables
Employee & Dept? (Employee X Dept)
OR
B) Consider the following two commands with reference to a table, named
Employee, having a column named D_name:
(a) Select count(D_Name)from Students;
(b) Select count(*)from Students;
If these two commands are producing different results,
(i) What may be the possible reason?
(ii) Which command,(a)or(b),might be giving higher value?

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

29. A) The file “City.txt” stores the name of few selected cities with the Pincode. (3)
Write a function Display() to read data and display only those city with the
Pincode whose first letter is not a vowels.
Sample Output:
New Delhi 110005
Mumbai 400001
OR
B) The file “Name.txt” stores the name of all the students of Class XII. Write a
function “Count()” to read the records from the file. Count and display all the
uppercase and lowercase letters separately available in file.

30. A) Each node of a stack named CITY contained the following information: (3)
 Pin code of a city
 Name of city
Write the following user-defined functions in Python to perform the specified
operations on the stack CITY:
i) PUSH_CITY(CITY, new_city): This function takes the stack CITY and a
new city record new_city as arguments and pushes the new city
record onto the stack.
ii) POP_CITY(CITY): This function pops the topmost city record from the
stack and returns it. If the stack is already empty, the function should
display "Underflow".
iii) DISPLAY(CITY): This function takes the stack CITY and display all its
elements If the stack is empty, the function should display 'None'.

OR
B) Write the definition of a user-defined function `PUSH_NUM(L)` which accepts
a list of integers in a parameter `L` and pushes all those integers which are either
multiple of 3 or 5 from the list `L` into a Stack named `NUMBERS`. Write function
POP_NUM() to pop the topmost number from the stack and returns it. If the stack
is already empty, the function should display "Empty". Write function
DISP_NUM() to display all element of the stack without deleting them. If the stack
is empty, the function should display 'None'.

For example:
If the integers input into the list `L` are:
[4,10, 15, 8, 14, 12]
Then the stack `NUMBERS` should store:
[10, 15, 12]

31. Predict the output of the Python code given below: (3)
def product(L1,L2):
p=0
for i in L1:
for j in L2:
p=p+i*j
return p
LIST=[1,2,3,4,5,6]
l1=[]
l2=[]
for i in LIST:
if(i%2!=0):
l1.append(i)
else:
l2.append(i)
print(product(l1,l2))
OR
Predict the output of the Python code given below:
tuple1 = (31, 22, 43, 54 ,65)
list1 =list(tuple1)
for i in list1:
new_list = []
for j in range(i%10):
new_list.append(i%10)
new_tuple = tuple(new_list)
print(new_tuple, end="@")
print("")

Section-D ( 4 x 4 = 16 Marks)
Q No. Marks
32. Consider a Table LOANS: (4)

Acc Cust_Name Amount Install Int_Rate Start_Date Interest


No ment
1 R.K. Gupta 300000 36 12.00 19-07-2009 1200
2 S.P. Sharma 500000 48 10.00 22-03-2008 1800
3 K.P. jain 300000 36 Null 08-03-2009 1600
4 M.P. Yadav 800000 60 10.00 06-12-2008 2250
5 S.P. Sinha 200000 36 12.50 03-01-2010 4500
6 P. Sharma 700000 60 12.50 05-06-2008 3500
7 K.S. Dhall 500000 48 Null 05-03-2008 3800

A) Write the following queries:


(i) Display the sum of all Loan Amounts whose Interest rate is greater than
10.
(ii) Display the Maximum Interest from Loans table.
(iii) Display the count of all loan holders whose name ends with ‘Sharma’.
(iv) Display the count of all loan holders whose Interest rate is Null.

OR

B) Write the Output of the following:


i) Select Avg(Interest) from Loans group by Installment;
ii) Select * from Loans where amount between 200000 and 500000 order by
Start_date desc;
iii) Select count (Int_rate)from Loans where installment <60;
iv) Select min(Amount) from Loans;
33. A CSV file with the name “Countery.csv” is already available in the system that (4)
contains two fields Country and Capital. A function Capital() is defined to access
information from the field and display all the country names along with their
capitals where country name is more than five characters long. In the code, there
are some places left blank to be filled with expression/function.
The code is written below as:
# A Python Code to read data from a csv file
import ____________ # Line 1
def Capital():
fr = open(“Country.csv”,”r”)
reader = _______________ # Line2
next(______________) # Line 3
print(“Country Name which contains more than five characters: ”)
for a in reader:
if(____________): #Line 4
print(a)
fr.close()
With reference to the given code, answer the following questions:
a) What module/function will be filled in the blank marked with Line 1?
b) What function will be filled in blank marked with Line 2?
c) What variable will be filled in the blank marked with Line 3?
d) What condition will be filled in the blank marked with Line 4?

34. Consider the following tables Stationary and Consumer. Write SQL commands for (4)
the statement (i) to (iv):
Table: Stationary
S_ID StationaryName Company Price
DP01 Dot Pen ABC 10
PL02 Pencil XYZ 6
ER05 Eraser XYZ 7
PL01 Pencil CAM 5
GP02 Gel Pen ABC 15

Table: Consumer
C_ID ConsumerName Address S_ID
01 Good Learner Delhi PL01
06 Write Well Mumbai GP02
12 Topper Delhi DP01
15 Write & Draw Delhi PL02
16 Motivation Banglore PL01

(i) To display the details of those consumers whose Address is Delhi.


(ii) To display the details of Stationary whose Price is in the range of 8 to
15. (Both Value included)
(iii) To display the ConsumerName, Address from Table Consumer, and
Company and Price from table Stationary, with their corresponding
matching S_ID.

(iv) To increase the Price of all stationary by 2.


OR
To display the details of those stationary whose customer address is
delhi.
35. A table BOOK in LIBRARY database, has the following structure: (4)
Field Type
Book_id Int(7)
B_Nmae Varchar(35)
Price Float
Type Varchar(20)

Write the following Python function to perform the specified operations:


ADD_BOOK() : To input the details of Book and store ot in the BOOK table.
FIND_BOOK() : The function should find and display details all those books
whose type is literature from table BOOK.
Assume the following for Python-Database connectivity:
Host: localhost, User: root, Password: Lib@123

SECTION E (2 X 5 = 10 Marks)
Q No. Marks
36. A file “Grade.dat” has already been created with the record containing index (5)
number, name, marks and grade as sub-lists of the list. Later on, the user realised
that he has made wrong entry of the grades in all the records.
i) Define a function Update() to open the file in “rb+” mode to read and
update the grades in all the records as per the criteria mentioned
below:
Marks Grade
90 and above A
>=80 and <90 B
Else C

ii) Write a function to read the data from the binary file and display the data of
all those candidates who grade id ‘A’.
37. A company in Mega Enterprises has 4 wings of buildings in Mumbai Campus as (5)
shown in the diagram :

Centre to centre distances between various Buildings:

Number of computers in each of the wing:


Computers in each wing are networked but wings are not networked. The
company has now decided to connect the wings also.
(i) Suggest a most suitable cable layout for the above connections and
specify the topology.
(ii) Suggest the most suitable wing to place the server by giving suitable
reason.
(iii) Suggest the placement of the following devices with justification if the
company wants minimized network traffic : (a) Repeater (b) Hub /
switch
(iv) The organization is planning to link its sale counter situated in various
part of the same city. Which type of network out of LAN, WAN, MAN
will be formed? Justify.
(v) The company is planning to link its head office situated in New Delhi
with the offices in hilly areas. Suggest a way to connect it economically.
OR
What would be your recommendation for enabling live visual
communication between the Office at the Mumbai campus and the
DELHI Head Office.

You might also like