0% found this document useful (0 votes)
260 views

XII CS Practice Papers

Computer science

Uploaded by

sahayamaryd
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
260 views

XII CS Practice Papers

Computer science

Uploaded by

sahayamaryd
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 42

Series HEFG/C Set-4

Q.P. Code 91

Roll No.

COMPUTER SCIENCE (NEW)


Time allowed : 3 hours Maximum Marks : 70

Please check that this question paper contains 19 printed pages.


Q.P. Code given on the right hand side of the question paper should be
written on the title page of the answer-book by the candidate.
Please check that this question paper contains 35 questions.
Please write down the serial number of the question in the
answer-book before attempting it.
15 minute time has been allotted to read this question paper. The
question paper will be distributed at 10.15 a.m. From 10.15 a.m. to
10.30 a.m., the students will read the question paper only and will not
write any answer on the answer-book during this period.

$*
General Instructions :
This question paper contains five sections, Section A to E.
All questions are compulsory.
Section A has 18 questions carrying 1 mark each.
Section B has 7 Very Short Answer (VSA) type questions carrying 2 marks each.
Section C has 5 Short Answer (SA) type questions carrying 3 marks each.
Section D has 3 Long Answer (LA) type question carrying 5 marks each.
Section E has 2 questions carrying 4 marks each. One internal choice is given
in Q 35 against part C only.
All programming questions are to be answered using Python Language only.
91 ^ Page 1 of 19 P.T.O.
SECTION A

All questions carrying 1 mark each. 18 1=18

1. State True or False.

2. Which of the following is not a sequential datatype in Python ?

(a) Dictionary
(b) String

(c) List

(d) Tuple

3. Given the following dictionary


Day={1:"Monday", 2: "Tuesday", 3: "Wednesday"}
Which statement will return "Tuesday".

(a) Day.pop()
(b) Day.pop(2)

(c) Day.pop(1)
(d) Day.pop("Tuesday")

4. Consider the given expression :


7<4 or 6>3 and not 10==10 or 17>4
Which of the following will be the correct output if the given expression is
evaluated ?
(a) True
(b) False

(c) NONE
(d) NULL

91 Page 2 of 19
5. Select the correct output of the code :
S="Amrit Mahotsav @ 75"
A=S.split(" ",2)
print(A)
(a) ('Amrit', 'Mahotsav', '@', '75')
(b) ['Amrit', 'Mahotsav', '@ 75']
(c) ('Amrit', 'Mahotsav', '@ 75')
(d) ['Amrit', 'Mahotsav', '@', '75']

6. Which of the following modes in Python creates a new file, if file does not
exist and overwrites the content, if the file exists ?
(a) r+ (b) r
(c) w (d) a

7. Fill in the blank :


___________ is not a valid built-in function for list manipulations.
(a) count()
(b) length()
(c) append()
(d) extend()

8. Which of the following is an example of identity operators of Python ?


(a) is (b) on
(c) in (d) not in

9. Which of the following statement(s) would give an error after executing


the following code ?
S="Happy" # Statement 1
print(S*2) # Statement 2
S+="Independence" # Statement 3
S.append("Day") # Statement 4
print(S) # Statement 5
(a) Statement 2 (b) Statement 3
(c) Statement 4 (d) Statement 3 and 4
91 Page 3 of 19 P.T.O.
10. Fill in the blank :
In a relational model, tables are called _________, that store data for
different columns.
(a) Attributes
(b) Degrees
(c) Relations
(d) Tuples

11. The correct syntax of tell() is :


(a) tell.file_object()
(b) file_object.tell()
(c) tell.file_object(1)
(d) file_object.tell(1)

12. Fill in the blank :


_________ statement of SQL is used to insert new records in a table.
(a) ALTER
(b) UPDATE
(c) INSERT
(d) CREATE

13. Fill in the blank :


In _________ switching, before a communication starts, a dedicated path
is identified between the sender and the receiver.
(a) Packet
(b) Graph
(c) Circuit
(d) Plot

91 Page 4 of 19
14. What will the following expression be evaluated to in Python ?
print(6/3 + 4**3//8 4)
(a) 6.5
(b) 4.0
(c) 6.0
(d) 4

15. Which of the following functions is a valid built-in function for both list
and dictionary datatype ?
(a) items()
(b) len()
(c) update()
(d) values()

16. fetchone() method fetches only one row in a ResultSet and returns a
__________.
(a) Tuple
(b) List
(c) Dictionary
(d) String

Q. 17 and 18 are Assertion (A) and Reasoning (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.


91 Page 5 of 19 P.T.O.
17. Assertion (A) : In Python, a stack can be implemented using a list.
Reasoning (R) : A stack is an ordered linear list of elements that works
on the principle of First In First Out (FIFO).

18. Assertion (A) : readlines() reads all the lines from a text file and
returns the lines along with newline as a list of strings.
Reasoning (R) : readline() can read the entire text file line by line
without using any looping statements.

SECTION B

19. Ravi, a Python programmer, is working on a project in which he wants to


write a function to count the number of even and odd values in the list.
He has written the following code but his code is having errors. Rewrite
the correct code and underline the corrections made. 2
define EOCOUNT(L):
even_no=odd_no=0
for i in range(0,len(L))
if L[i]%2=0:
even_no+=1
Else:
odd_no+=1
print(even_no, odd_no)

20. (a) Write any two differences between Fiber-optic cable and Coaxial
cable. 2

OR

(b) Write one advantage and one disadvantage of wired over wireless
communication. 2

91 Page 6 of 19
21. (a) Given is a Python string declaration : 1
NAME = "Learning Python is Fun"
Write the output of : print(NAME[-5:-10:-1])

(b) Write the output of the code given below : 1


dict1={1:["Rohit",20], 2:["Siya",90]}
dict2={1:["Rahul",95], 5:["Rajan",80]}
dict1.update(dict2)
print(dict1.values())

22. Explain the usage of HAVING clause in GROUP BY command in RDBMS


with the help of an example. 2

23. (a) Write the full forms of the following : 1


(i) XML
(ii) HTTPS

(b) What is the use of FTP ? 1

24. (a) Write the output of the Python code given below : 2
g=0
def fun1(x,y):
global g
g=x+y
return g
def fun2(m,n):
global g
g=m-n
return g
k=fun1(2,3)
fun2(k,7)
print(g)

OR

91 Page 7 of 19 P.T.O.
(b) Write the output of the Python code given below : 2
a=15
def update(x):
global a
a+=2
if x%2==0:
a*=x
else:
a//=x
a=a+5
print(a,end="$")
update(5)
print(a)

25. (a) Differentiate between IN and BETWEEN operators in SQL with


appropriate examples. 2
OR
(b) Which of the following is NOT a DML command. 2
DELETE, DROP, INSERT, UPDATE

SECTION C

26. (a) Consider the following tables Student and Sport :


Table : Student
ADMNO NAME CLASS
1100 MEENA X
1101 VANI XI

Table : Sport
ADMNO GAME
1100 CRICKET
1103 FOOTBALL

What will be the output of the following statement ? 1


SELECT * FROM Student, Sport;

91 Page 8 of 19
(b) Write the output of the queries (i) to (iv) based on the table,
GARMENT given below : 2

TABLE : GARMENT
GCODE TYPE PRICE FCODE ODR_DATE
G101 EVENING GOWN 850 F03 2008-12-19
G102 SLACKS 750 F02 2020-10-20
G103 FROCK 1000 F01 2021-09-09
G104 TULIP SKIRT 1550 F01 2021-08-10
G105 BABY TOP 1500 F02 2020-03-31
G106 FORMAL PANT 1250 F01 2019-01-06

(i) SELECT DISTINCT(COUNT(FCODE))FROM GARMENT;

(ii) SELECT FCODE, COUNT(*), MIN(PRICE) FROM


GARMENT GROUP BY FCODE HAVING COUNT(*)>1;

(iii) SELECT TYPE FROM GARMENT WHERE ODR_DATE


>'2021-02-01' AND PRICE <1500;

(iv) SELECT * FROM GARMENT WHERE TYPE LIKE 'F%';

27. (a) Write a function in Python that displays the book names having
y in their name from a text file Bookname.t 3
Example :
s the names of following books :

One Hundred Years of Solitude


The Diary of a Young Girl
On the Road

After execution, the output will be :

One Hundred Years of Solitude


The Diary of a Young Girl

OR

91 Page 9 of 19 P.T.O.
(b) Write a function RevString()
prints the words The rest of the
content is displayed normally. 3
Example :
If content in the text file is :
UBUNTU IS AN OPEN SOURCE OPERATING SYSTEM
Output will be :
UBUNTU IS AN NEPO SOURCE GNITAREPO SYSTEM

28. Write the output of any three SQL queries (i) to (iv) based on the tables
COMPANY and CUSTOMER given below : 3

Table : COMPANY
CID C_NAME CITY PRODUCTNAME
111 SONY DELHI TV
222 NOKIA MUMBAI MOBILE
333 ONIDA DELHI TV
444 SONY MUMBAI MOBILE
555 BLACKBERRY CHENNAI MOBILE
666 DELL DELHI LAPTOP

Table : CUSTOMER
CUSTID CID NAME PRICE QTY
C01 222 ROHIT SHARMA 70000 20
C02 666 DEEPIKA KUMARI 50000 10
C03 111 MOHAN KUMAR 30000 5
C04 555 RADHA MOHAN 30000 11

(i) SELECT PRODUCTNAME, COUNT(*)FROM COMPANY GROUP BY


PRODUCTNAME HAVING COUNT(*)> 2;
(ii) SELECT NAME, PRICE, PRODUCTNAME FROM COMPANY C,
CUSTOMER CT WHERE C.CID = CU.CID AND C_NAME = 'SONY';
(iii) SELECT DISTINCT CITY FROM COMPANY;
(iv) SELECT * FROM COMPANY WHERE C_NAME LIKE '%ON%';

91 Page 10 of 19
29. Write a function search_replace() in Python which accepts a list L of
numbers and a number to be searched. If the number exists, it is replaced
by 0 and if the number does not exist, an appropriate message is
displayed. 3
Example :
L = [10,20,30,10,40]
Number to be searched = 10

List after replacement :


L = [0,20,30,0,40]

30. A list contains following record of course details for a University :


[Course_name, Fees, Duration]

Write the following user defined functions to perform given operations on


the stack named 'Univ' : 3
(i) Push_element() To push an object containing the
Course_name, Fees and Duration of a course, which has fees
greater than 100000 to the stack.

(ii) Pop_element() To pop the object from the stack and display it.

For example :
If the lists of courses details are :

3]
2]

3]

The stack should contain :

2]
3]
91 Page 11 of 19 P.T.O.
SECTION D

31. ABC Consultants are setting up a secure network for their office campus
at Noida for their day-to-day office and web-based activities. They are
planning to have connectivity between three buildings and the head office
situated in Bengaluru. As a network consultant, give solutions to the
questions (i) to (v), after going through the building locations and other
details which are given below :

NOIDA BRANCH BENGALURU BRANCH

BUILDING 1 HEAD OFFICE


BUILDING 2

BUILDING 3

Distance between various blocks/locations :


Building Distance
Building 1 to Building 3 120 m
Building 1 to Building 2 50 m
Building 2 to Building 3 65 m
Noida Branch to Head Office 1500 km

Number of computers
Building Number of Computers
Building 1 25
Building 2 51
Building 3 150
Head Office 10
(i) Suggest the most suitable place to install the server for this
organization. Also, give reason to justify your suggested location. 1
(ii) Suggest the cable layout of connections between the buildings
inside the campus. 1

91 Page 12 of 19
(iii) Suggest the placement of the following devices with justification : 1
Switch
Repeater

(iv) The organization is planning to provide a high-speed link with the


head office situated in Bengaluru, using a wired connection.
Suggest a suitable wired medium for the same. 1

(v) The System Administrator does remote login to any PC, if any
requirement arises. Name the protocol, which is used for the same. 1

32. (a) (i) What possible output(s) are expected to be displayed on


screen at the time of execution of the following code ? 2

import random
S=["Pen","Pencil","Eraser","Bag","Book"]
for i in range (1,2):
f=random.randint(i,3)
s=random.randint(i+1,4)

print(S[f],S[s],sep=":")

Options :
(I) Pencil:Book

(II) Pencil:Book
Eraser:Bag

(III) Pen:Book
Bag:Book

(IV) Bag:Eraser

91 Page 13 of 19 P.T.O.
(ii) The table Bookshop in MySQL contains the following
attributes :
B_code Integer
B_name String
Qty Integer
Price Integer

Note the following to establish connectivity between Python


and MySQL o :
Username is shop
Password is Book
The table exists in a MySQL database named
Bstore.
The code given below updates the records from the table
Bookshop in MySQL. 3
Statement 1 to form the cursor object.
Statement 2 to execute the query that updates the Qty to
20 of the records whose B_code is 105 in the table.
Statement 3 to make the changes permanent in the
database.

import mysql.connector as mysql


def update_book():

mydb=mysql.connect(host="localhost",
user="shop",passwd="Book",database="Bstore")
mycursor=__________ # Statement 1
qry= "update Bookshop set Qty=20 where
B_code=105"
___________________ # Statement 2
___________________ # Statement 3

OR

91 Page 14 of 19
(b) (i) Predict the output of the code given below : 2
text="LearningCS"
L=len(text)
ntext=""
for i in range (0,L):
if text[i].islower():
ntext=ntext+text[i].upper()
elif text [i].isalnum():
ntext=ntext+text[i 1]
else:
ntext=ntext+'&&'
print(ntext)

(ii) The table Bookshop in MySQL contains the following


attributes :
B_code Integer
B_name String
Qty Integer
Price Integer

Note the following to establish connectivity between Python


and MySQL o :
Username is shop
Password is Book
The table exists in a MySQL database named
Bstore.
The code given below reads the records from the table
Bookshop and displays all the records : 3
Statement 1 to form the cursor object.
Statement 2 to write the query to display all the records
from the table.

91 Page 15 of 19 P.T.O.
Statement 3 to read the complete result of the query into
the object named B_Details, from the table Bookshop in
the database.

import mysql.connector as mysql


def Display_book():

mydb=mysql.connect(host="localhost",
user="shop",passwd="Book",database="Bstore")
mycursor=___________ # Statement 1
mycursor.execute("_________") # Statement 2
B_Details=__________ # Statement 3
for i in B_Details:

print(i)

33. (a) Write a point of difference between append (a) and write (w)
modes in a text file. 5
Write a program in Python that defines and calls the following
user defined functions :
(i) Add_Teacher() : It accepts the values from the user and
inserts
record consists of a list with field elements as T_id, Tname
and desig to store teacher ID, teacher name and
designation respectively.
(ii) Search_Teacher() : To display the records of all the PGT
(designation) teachers.
OR
(b) Write one point of difference between seek() and tell()
functions in file handling. Write a program in Python that defines
and calls the following user defined functions : 5
(i) Add_Device() : The function accepts and adds records of the

consists of a list with field elements as P_id, P_name and


Price to store peripheral device ID, device name, and price
respectively.
(ii) Count_Device() : To count and display number of peripheral
devices, whose price is less than < 1000.

91 Page 16 of 19
SECTION E

34. The ABC Company is considering to maintain their salespersons records


using SQL to store data. As a database administrator, Alia created the
table Salesperson and also entered the data of 5 Salespersons.

Table : Salesperson
S_ID S_NAME AGE S_AMOUNT REGION
S001 SHYAM 35 20000 NORTH
S002 RISHABH 30 25000 EAST
S003 SUNIL 29 21000 NORTH
S004 RAHIL 39 22000 WEST
S005 AMIT 40 23000 EAST

Based on the data given above, answer the following questions :


(i) Identify the attribute that is best suited to be the Primary Key and
why ? 1
(ii) The Company has asked Alia to add another attribute in the table.
What will be the new degree and cardinality of the above table ? 1
(iii) Write the statements to : 2
(a) Insert details of one salesman with appropriate data.
(b) SHYAM SOUTH
table Salesperson.

OR (Option for part iii only)

(iii) Write the statement to : 2


(a) Delete the record of salesman RISHABH, as he has left the
company.
(b) Remove an attribute REGION from the table.

91 Page 17 of 19 P.T.O.
35. Atharva is a programmer, who has recently been given a task to write a
Python code to perform the following binary file operation with the help
of a user defined function/module :

Copy_new() : to create a binary file new_items.dat and write all

the item details stored in the binary file, items.dat, except for

the item whose item_id is 101. The data is stored in the following
format :
{item_id:[item_name,amount]}

import ___________ # Statement 1

def Copy_new():

f1=_____________ # Statement 2

f2=_____________ # Statement 3

item_id=int(input("Enter the item id"))

item_detail=___________ # Statement 4

for key in item_detail:

if _______________: # Statement 5

pickle.___________ # Statement 6

f1.close()

f2.close()

He has succeeded in writing partial code and has missed out certain
statements. Therefore, as a Python expert, help him to complete the code

based on the given requirements :

91 Page 18 of 19
(i) Which module should be imported in the program ? (Statement 1) 1

(ii) Write the correct statement required to open the binary file
"items.dat". (Statement 2) 1

(iii) Which statement should Atharva fill in Statement 3 to open the


binary file "new_items.dat" and in Statement 4 to read all the
details from the binary file "items.dat". 2

OR (Option for part iii only)

(iii) What should Atharva write in Statement 5 to apply the given


condition and in Statement 6 to write data in the binary file
"new_items.dat". 2

91 Page 19 of 19 P.T.O.
Series &RQPS/S Set-4
>
Q.P. Code 91/S

Roll No. Candidates must write the Q.P. Code


on the title page of the answer-book.

COMPUTER SCIENCE

Time allowed : 3 hours Maximum Marks : 70

NOTE
(I) Please check that this question paper contains 15 printed pages.

(II) Please check that this question paper contains 35 questions.

(III) Q.P. Code given on the right hand side of the question paper should be written on
the title page of the answer-book by the candidate.

(IV) Please write down the serial number of the question in the answer-book
before attempting it.

(V) 15 minute time has been allotted to read this question paper. The question paper
will be distributed at 10.15 a.m. From 10.15 a.m. to 10.30 a.m., the students will
read the question paper only and will not write any answer on the answer-book
during this period.

91/S 1 P.T.O.
General Instructions :
Please read the instructions carefully.
· This question paper has 5 Sections : Sections A, B, C, D, E.
· All questions are compulsory. However, an internal choice of approximately
30% is provided.
· Section A has 18 questions carrying 1 mark each.
· Section B has 7 Very Short Answer (VSA) type questions carrying 2 marks
each.
· Section C has 5 Short Answer (SA) type questions carrying 3 marks each.
· Section D has 2 Long Answer (LA) type question carrying 4 marks.
· Section E has 3 Source-based/Case-based/Passage-based questions carrying
5 marks each.

SECTION A 18´1=18
1. State True or False : 1
“In Python, tuple is a mutable data type”.

2. The primary key is selected from the set of ___________ . 1


(A) composite keys (B) alternate keys
(C) candidate keys (D) foreign keys

3. What will be the output of the following statement ? 1


print(6+5/4**2//5+8)
(A) –14.0 (B) 14.0

(C) 14 (D) –14

4. Select the correct output of the code : 1


S = "text#next"
print(S.strip("t"))
(A) ext#nex (B) ex#nex
(C) text#nex (D) ext#next

91/S 2
5. In SQL, which command will be used to add a new record in a table ? 1
(A) UPDATE
(B) ADD
(C) INSERT
(D) ALTER TABLE

6. ‘L’ in HTML stands for : 1


(A) Large (B) Language
(C) Long (D) Laser

7. Identify the valid Python identifier from the following : 1

(A) 2user (B) user@2

(C) user_2 (D) user 2

8. Consider the statements given below and then choose the correct output
from the given options : 1
Game="World Cup 2023"
print(Game[-6::-1])

(A) CdrW (B) ce o

(C) puC dlroW (D) Error

9. Predict the output of the following Python statements : 1


>>>import statistics as s
>>>s.mode ([10, 20, 10, 30, 10, 20, 30])
(A) 30
(B) 20
(C) 10
(D) 18.57

91/S 3 P.T.O.
10. Which of the following output will never be obtained when the given code
is executed ? 1
import random
Shuffle = random.randrange(10)+1
Draw = 10*random.randrange(5)
print ("Shuffle", Shuffle, end="#")
print ("Draw", Draw)
(A) Shuffle 1 # Draw 0
(B) Shuffle 10 # Draw 10
(C) Shuffle 10 # Draw 0
(D) Shuffle 11 # Draw 50

11. Ethernet card is also known as : 1


(A) LIC (B) MIC
(C) NIC (D) OIC

12. What will be the output of the given code ? 1


a=10
def convert(b=20):
a=30
c=a+b
print(a,c)
convert(30)
print(a)

13. For the following Python statement : 1


N = (25)
What shall be the type of N ?
(A) Integer
(B) String
(C) Tuple
(D) List
91/S 4
14. Mr. Ravi is creating a field that contains alphanumeric values and fixed
lengths. Which MySQL data type should he choose for the same ? 1
(A) VARCHAR
(B) CHAR
(C) LONG
(D) NUMBER

15. Fill in the blank : 1

The full form of WWW is __________.

16. __________ files are stored in a computer in a sequence of bytes. 1


(A) Text
(B) Binary
(C) CSV
(D) Notepad

Questions No.17 and 18 are Assertion and Reason type questions. Each question
consists of two statements, namely, Assertion (A) and Reason (R). Select the most
suitable option considering the Assertion and Reason.
17. Assertion (A) : Global variables are accessible in the whole program. 1
Reason (R) : Local variables are accessible only within a function or block
in which it is declared.

(A) Both Assertion (A) and Reason (R) are true and Reason (R) is the
correct explanation of Assertion (A).

(B) Both Assertion (A) and Reason (R) are true, but Reason (R) is not the
correct explanation of Assertion (A).

(C) Assertion (A) is true, but Reason (R) is false.

(D) Assertion (A) is false, but Reason (R) is true.

91/S 5 P.T.O.
18. Assertion (A) : If numeric data are to be written to a text file, the data
needs to be converted into a string before writing to the file. 1
Reason (R) : write() method takes a string as an argument and writes it
to the text file.
(A) Both Assertion (A) and Reason (R) are true and Reason (R) is the
correct explanation of Assertion (A).
(B) Both Assertion (A) and Reason (R) are true, but Reason (R) is not the
correct explanation of Assertion (A).
(C) Assertion (A) is true, but Reason (R) is false.
(D) Assertion (A) is false, but Reason (R) is true.

SECTION B 7´2=14
19. (a) (i) Expand the following terms : 1+1=2
URL, XML

(ii) Give one difference between HTTP and FTP.


OR

(b) (i) Define the term IP address with respect to network.

(ii) What is the main purpose of a Router ? 1+1=2

20. Observe the following code carefully and rewrite it after removing
all syntactical errors. Underline all the corrections made. 2
def 1func():
a=input("Enter a number"))
if a>=33
print("Promoted to next class")
ELSE:
print("Repeat")

91/S 6
21. (a) Write the definition of a method/function SearchOut(Teachers,
TName) to search for TName from a list Teachers, and display the
position of its presence. 2
For example :
If the Teachers contain ["Ankit", "Siddharth", "Rahul",
"Sangeeta", "rahul"]
and TName contains "Rahul"
The function should display
Rahul at 2
rahul at 4

OR

(b) Write the definition of a method/function Copy_Prime(lst) to copy


all the prime numbers from the list lst to another list lst_prime. 2

22. Predict the output of the following code : 2


d={"IND":"DEL","SRI:"COL","CHI":"BEI"}
str1=""
for i in d:
str1=strl+str(d[i])+"@"
str2=str1[:–1]
print (str2)

23. (a) Write the Python statement for each of the following tasks using
BUILT-IN functions/methods only : 1+1=2
(i) To delete an element 10 from the list lst.
(ii) To replace the string "This" with "That" in the string str1.
OR
(b) A dictionary dict2 is copied into the dictionary dict1 such that the
common key’s value gets updated. Write the Python commands to do
the task and after that empty the dictionary dict1. 2

91/S 7 P.T.O.
24. (a) Mr. Atharva is given a task to create a database, Admin. He has to
create a table, users in the database with the following columns : 1+1=2
User_id – int
User_name – varchar(20)
Password – varchar(10)
Help him by writing SQL queries for both tasks.

OR

(b) Ms. Rita is a database administrator at a school. She is working on


the table, student containing the columns like Stud_id, Name,
Class and Stream. She has been asked by the Principal to strike off
the record of a student named Rahul with student_id as 100 from
the school records and add another student who has been admitted
with the following details : 1+1=2
Stud_id – 123
Name – Rajeev
Class – 12
Stream – Science
Help her by writing SQL queries for both tasks.

25. Predict the output of the following code : 2


def Total (Num=10):
Sum=0
for C in range(1,Num+1):
if C%2!=0:
continue
Sum+=C
return Sum
print(Total(4),end="$")
print(Total(),sep="@")

91/S 8
SECTION C 5´3=15
26. Predict the output of the Python code given below : 3
s="India Growing"
n = len(s)
m=""
for i in range (0, n) :
if (s[i] >= 'a' and s[i] <= 'm') :
m = m + s [i].upper()
elif (s[i] >= 'O' and s[i] <= 'z') :
m = m +s [i-1]
elif (s[i].isupper()):
m = m + s[i].lower()
else:
m = m + '@'
print (m)

27. Consider the table Stationery given below and write the output of the
SQL queries that follow. 3
Table : Stationery
ITEMNO ITEM DISTRIBUTOR QTY PRICE
401 Ball Pen 0.5 Reliable Stationers 100 16
402 Gel Pen Premium Classic Plastics 150 20
403 Eraser Big Clear Deals 210 10
404 Eraser Small Clear Deals 200 5
405 Sharpener Classic Classic Plastics 150 8
406 Gel Pen Classic Classic Plastics 100 15

(i) SELECT DISTRIBUTOR, SUM(QTY) FROM STATIONERY GROUP


BY DISTRIBUTOR;

(ii) SELECT ITEMNO, ITEM FROM STATIONERY WHERE


DISTRIBUTOR = "Classic Plastics" AND PRICE > 10;

(iii) SELCET ITEM, QTY * PRICE AS "AMOUNT" FROM STATIONERY


WHERE ITEMNO = 402;
91/S 9 P.T.O.
28. (a) Write a method/function COUNTWORDS() in Python to read contents
from a text file DECODE.TXT, to count and return the occurrence of
those words, which are having 5 or more characters. 3

OR

(b) Write a method/function COUNTLINES() in Python to read lines from


a text file CONTENT.TXT, and display those lines, which have
@ anywhere in the line. 3

For example :
If the content of the file is :
Had an amazing time at the concert last night with
@MusicLoversCrew.
Excited to announce the launch of our new website!
G20 @ India

The method/function should display


Had an amazing time at the concert last night with
@MusicLoversCrew
G20 @ India

29. Consider the table Rent_cab, given below :


Table : Rent_cab
Vcode VName Make Color Charges
101 Big car Carus White 15
102 Small car Polestar Silver 10
103 Family car Windspeed Black 20
104 Classic Studio White 30
105 Luxury Trona Red 9

Based on the given table, write SQL queries for the following : 3

(i) Add a primary key to a column name Vcode.

(ii) Increase the charges of all the cabs by 10%.

(iii) Delete all the cabs whose maker name is "Carus".

91/S 10
30. A dictionary, d_city contains the records in the following format :
{state:city}
Define the following functions with the given specifications : 3
(i) push_city(d_city): It takes the dictionary as an argument and
pushes all the cities in the stack CITY whose states are of more than
4 characters.
(ii) pop_city(): This function pops the cities and displays "Stack
empty" when there are no more cities in the stack.

SECTION D 2´4=8

31. Consider the tables GAMES and PLAYERS given below :

Table : GAMES
GCode GameName Type Number PrizeMoney
101 Carrom Board Indoor 2 5000
102 Badminton Outdoor 2 12000
103 Table Tennis Indoor 4 NULL
104 Chess Indoor 2 9000
105 Lawn Tennis Outdoor 4 25000

Table : PLAYERS
PCode Name GCode
1 Nabi Ahmad 101
2 Ravi Sahai 108
3 Jatin 101
4 Nazneen 103
Write SQL queries for the following : 4
(i) Display the game type and average number of games played in each
type.
(ii) Display prize money, name of the game, and name of the players from
the tables Games and Players.
(iii) Display the types of games without repetition.
(iv) Display the name of the game and prize money of those games whose
prize money is known.

91/S 11 P.T.O.
32. Mr. Mahesh is a Python Programmer working in a school. He has to
maintain the records of the sports students. He has created a csv file
named sports.csv, to store the details. The structure of sports.csv is :
[sport_id, competition, prize_won]
where
sport_id, is Sport id (integer)
competition is competition name (string)
prize_won is (“Gold”, “Silver”, “Bronze”)
Mr. Mahesh wants to write the following user-defined functions :
Add_detail(): to accept the detail of a student and add to a csv file,
"sports.csv".
Count_Medal(): to display the name of competitions in which students
have won "Gold" medal.
Help him in writing the code of both the functions. 4

SECTION E 3´5=15

33. Logistic Technologies Ltd. is a Delhi based organization which is expanding


its office set-up to Ambala. At Ambala office campus, they are planning to
have 3 different blocks for HR, Accounts and Logistics related work. Each
block has a number of computers, which are required to be connected to a
network for communication, data and resource sharing.

91/S 12
As a network consultant, you have to suggest the best network related
solutions for them for issues/problems raised in (i) to (v), keeping in mind
the distances between various block/locations and other given parameters.
Distances between various blocks/locations :

HR Block to Accounts Blocks 400 meters

Accounts Block to Logistics Block 200 meters

Logistics Block to HR Block 150 meters

Delhi Head Office to Ambala Office 220 Km


Number of computers installed at various blocks are as follows :

HR Block 70
Accounts Block 40
Logistics Block 30

(i) Suggest the most appropriate block/location to house the SERVER in


the Ambala office. Justify your answer.

(ii) Suggest the best wired medium to efficiently connect various blocks
within the Ambala office compound.

(iii) Draw an ideal cable layout (Block to Block) for connecting these blocks
for wired connectivity.

(iv) The company wants to schedule an online conference between the


managers of Delhi and Ambala offices. Which protocol will be used for
effective voice communication over the Internet ?

(v) Which kind of network will it be between Delhi office and Ambala
office ? 5

91/S 13 P.T.O.
34. (a) (i) What is the main purpose of seek() and tell() method ?
(ii) Consider a binary file, Cinema.dat containing information in
the following structure :
[Mno, Mname, Mtype]
Write a function, search_copy(), that reads the content from
the file Cinema.dat and copies all the details of the "Comedy"
movie type to file named movie.dat. 5
OR
(b) (i) Give one difference between write() and writeline()
function in text file.
(ii) A Binary file, "Items.dat" has the following structure :
[Icode, Description, Price]
Where
Icode – Item code
Description – Detail of item
Price – Price of item
Write a function Add_data(), that takes Icode,
Description and Price from the user and writes the
information in the binary file "Items.dat". 5
35. (a) (i) Define the term foreign key with respect to RDBMS.
(ii) Sangeeta wants to write a program in Python to delete the
record of a candidate “Raman” from the table named
Placement in MySQL database, Agency:
The table Placement in MySQL contains the following
attributes :
CName – String
Dept – String
Place – String
Salary – integer
Note the following to establish connectivity between Python
and MySQL :
· Username – root
· Password – job
· Host – localhost
Help Sangeeta to write the program in Python for the above
mentioned task. 5
OR

91/S 14
(b) (i) Give one difference between CHAR and VARCHAR datatype in
MySQL.
(ii) Rahim wants to write a program in Python to insert the
following record in the table named Bank_Account in MySQL
database, Bank :
· Accno – integer
· Cname – string
· Atype – string
· Amount – float
Note the following to establish connectivity between Python
and MySQL :
· Username – admin
· Password – root
· Host – localhost
The values of fields Accno, Cname, Atype and Amount have
to be accepted from the user. Help Rahim to write the program
in Python. 5

91/S 15 P.T.O.
ARMY PUBLIC SCHOOL, DHAULA KUAN
EXAMINATION: HALF YEARLY
CLASS : XII YEAR: 2024-25
SUBJECT: COMPUTER SCIENCE (Code 083)
Max. Marks: 70 SET B Max. Time: 3 Hours
General Instructions:
1. Each part is compulsory.
2. Programming Language is Python and SQL

SECTION-A
Q. No. Question
Marks
1. State True or False 1
“break keyword skips remaining part of an iteration in a loop and compiler goes to
starting of the loop and executes again”
2. Find the valid keyword from the following? 1
a) Student-Name b) False c) 3rdName d) P_no
3. What will be the output for the following Python statement? X={‘Sunil’:190, ‘Raju’:10, 1
‘Karambir’:72, ‘Jeevan’:115}
print(‘Jeevan’ in X, 190 in X, sep=”#”)
(a)True#False (b) True#True
(c) False#True (d) False#False
4. Consider the given expression: 1
True and False or not True
Which of the following will be correct output if the given expression is evaluated?
(a) True (b) False
(b) NONE (d) NULL
5. Select the correct output of the code: 1
a = "Python! is amazing!"
a = a.split('!')
b = a[0] + "." + a[1] + "." + a[2]
print (b)
(a) Python!. is amazing!. (b) Python. is amazing.
(c) Python. ! is amazing.! (d) will show error
6. Which of the following mode in file opening statement overwrite the existing content? 1
(a) a+ (b) r+
(c) w+ (d) None of the above

7. The attribute which have properties to be as referential key is known as. 1


(a) foreign key (b)alternate key
(c) candidate key (d) Both (a) and (c)
8. Which command is used to change some values in existing rows? 1
(a) CHANGE (b) MODIFY
(c) ALTER (d) UPDATE
9. Which of the following statement(s) would give an error after executing the 1
following code?
Q="Humanity is the best quality" # Statement1
print(Q) # Statement2
Q="Indeed.” # Statement3
Q[0]= '#' # Statement4
Q=Q+"It is." # Statement5
(a) Statement 3 (b) Statement 4 (c)Statement 5 (d)Statement 4 and 5
10. p=150 1
def fn(q):
#missing statement p=p+q
fn(50)
print(p)
Which of the following statements should be given in the blank for #missing statement if
the output produced is 200
(a) global p=150 (b) global p
(c) p=150 (d) globalq
11. Which function is used to split a line of string in list of words? ( 1
a)split( ) (b) splt( )
(c) split_line( ) (d) all of these
12. What possible output(s) will be obtained when the following code is executed import 1
random
k=random.randint(1,3)
fruits=[‘mango’, ‘banana’, ‘grapes’, ‘water melon’, ‘papaya’]
for j in range(k):
print(j, end=“*”)
(a) mango*banana*grapes (b) banana*grapes
(c) banana*grapes*watermelon (d) mango*grapes*papaya
13. Write the syntax to change the name of the column in MySQL 1

14. What will be the output when following expression be evaluated in Python? 1
print(21.5 // 4 + (8 + 3.0))
(a) 16 (b)14.0 (c) 15 (d) 15.5
15. Which of the following functions other than close() writes the buffer data to file 1
(a) push() (b) write() (c) writeBuffer() (d) flush()
16. To get counting of the returned rows, you may use……………. 1
(a) cursor.rowcount (b) cursor.count
(c) cursor.countrecords() (d) cursor.manyrecords()
Q17 and 18 are ASSERTION AND REASONING based questions. Mark the correct choice as
Both A and R are true and R is the correct explanation for A
Both A and R are true and R is not the correct explanation for A
A is True but R is False
A is false but R is True
17. Assertion (A):- If the arguments in function call statement are provided in the format 1
parameter=argument, it is called keyword arguments.
Reasoning (R):- During a function call, the argument list first contain keyword argument(s)
followed by positional argument(s).
18. Assertion (A): CSV (Comma Separated Values) is a file format for data storage with one 1
record on each line and each field is separated by comma.
Reason (R): The format is used to share data between cross platform as text editors are
available on all platforms.

SECTION B
19. Rewrite the following code in python after removing all syntax error(s). Underline each 2
correction done in the code.
Num=int(rawinput("Number greater than 10 :"))
sum=0
for i in range(10,Num,3)
sum+=1
if i%2=0:
print(i*2)
else: print(i*3)
print(sum)
20. What is the difference between formal and actual parameter? Explain with the help of an 2
example.

21. (A) Given is a Python string : 1


X=”Kendriya Vidyalaya sangathan”
Write the output of:
print(X[4:9]*2)
(B) Write the output of the python program code given below: 1
hello = {empname: "Ishan", address: ”New Delhi”, salary: 10000}
hello[salary] = 15000
hello[address] = "Delhi"
print(hello.keys())
22. Explain the use of GROUP BY clause in a Relational Database Management 2
System. Give example to support your answer.
23. A resultset is extracted from the database using the cursor object (that has been already 2
created) by giving the following statement.
Mydata=cursor.fetchone()
(a) How many records will be returned by the fetchone() method?
(b) What will be the datatype of Mydata object after the given command is executed?

24. Predict the output of the Python code given below: 2

OR
Predict the output of the Python code given below:
a=tuple()
a=a + tuple(‘Python’)
print(a)
print(len(a))
b=(10,20,30)
print(len(b))

25. Differentiate Where and Having clause in SQL with example. 2


OR
Define aggregate function and give example.
SECTION-C
26. (a) Consider the following tables – Employee and Office: 1+2
Table: Emp
Emp_Id Name Salary
E01 Lakshya 54000
E02 Ravi NULL
E03 Neeraj 32000
E04 Brijesh 42000

Table: dept
Emp_Id Dept DOJ
E01 Computer 05-SEP-2007
E02 Physics 05-JAN-2008
E03 Sports 30-DEC-2000
E04 English 05-SEP-2012
What will be the output of the following statement?
SELECT Name, Dept FROM Emp E, dept d WHERE E.Emp_Id=d.Emp_Id;
(b) Consider the following tables SCHOOL and ADMIN. Give the output the following
SQL queries:

(i) SELECT Designation, COUNT (*) FROM Admin GROUP BY Designation HAVING
COUNT (*) <2;
(ii) SELECT TEACHER FROM SCHOOL WHERE EXPERIENCE >12 ORDER BY TEACHER
DESC;
27. Write a method beginA() in Python to read lines from a text file Notebook.TXT, and display 3
those lines, which are starting with ‘A’.
For example If the file content is as follows:
An apple a day keeps the doctor away. We all pray for everyone’s safety.
A marked difference will come in our country.
The beginA() function should display the output as:
An apple a day keeps the doctor away.
A marked difference will come in our country.
OR
A text file “PYTHON.TXT” contains alphanumeric text. Write a program that reads this text
file and writes to another file “PYTHON1.TXT” entire file except the numbers or digits in the
file.
28. (a) Write the outputs of the SQL queries (i) to (iv) based on the relations CLUB and 3
STUDENT given below:
Table : CLUB

COACHID CNAME AGE SPORTS DATEOFAPP PAY GENDER


1 KUKREJA 35 KARATE 27/03/1996 1000 M
2 RAVINA 34 KARATE 20/01/1998 1200 F
3 KARAN 34 SQUASH 19/02/1998 2000 M
4 TARUN 33 BASKETBALL 01/01/1998 1500 M
5 ZUBIN 36 SWIMMING 12/01/1998 750 M
6 KATAKI 36 SWIMMING 24/02/1998 800 F
7 ANKITA 39 SQUASH 20/02/1998 2200 F
8 ZAREEN 37 KARATE 22/02/1998 1100 F
9 KUSH 41 SWIMMING 13/01/1998 900 M
10 SHAILYA 37 BASKETBALL 19/02/1998 1700 M

Table : STUDENT
COACHID SNAME STIPEND STREAM MARKS GRADE CLASS
1 KARAN 400.00 MEDICAL 78.5 B 12B
12 VINNET 450.00 COMMERCE 89.2 A 11C
13 VIVEK 300.00 COMMERCE 68.6 C 12C
4 DHRUV 350.00 HUMANITIES 73.1 B 12C
15 MOHIT 500.00 NONMEDICAL 90.6 A 11A
6 ANUJ 400.00 MEDICAL 75.4 B 12B
17 ABHAY 250.00 HUMANITIES 64.4 C 11A
18 PAYAL 450.00 NONMEDICAL 88.5 A 12A
19 DIKSHA 500.00 NONMEDICAL 92.0 A 12A
10 RISHIKA 00.00 COMMERCE 67.5 C 12C

(i) SELECT SPORTS, MIN(PAY) FROM Club Group by SPORTS ;


(ii) SELECT MAX(DATEOFAPP), MIN(DATEOFAPP) FROM CLUB;
(iii) SELECT CNAME, PAY, C.COACHID, SPORTS FROM CLUB C, STUDENT S
WHERE C.COACHID =S.COACHID AND PAY>=1500;
(iv) SELECT SName, CNAME FROM Student S, CLUB C WHERE Gender =’F’ AND
C.COACHID=S.COACHID;
(b) Write SQL command to list all databases.
29. Write a function shiftn(L,n), where L is a list of integers and n is an integer. The function 3
should return a list after shifting n number of elements to the left.
Example: If the list initially contains [2, 15, 3, 14, 7, 9, 19, 6, 1, 10] and n=2
then function should return [3, 14, 7, 9, 19, 6, 1, 10, 2, 15]
If the list initially contains [2, 15, 3, 14, 7, 9, 19, 6, 1, 10] and n=4
then function should return [7, 9, 19, 6, 1, 10, 2, 15, 3, 14]
30. A nested list contains the data of visitors in a museum. Each of the inner lists contains the 3
following data of a visitor:
[V_no (int), Date (string), Name (string), Gender (String M/F), Age (int)]
Write the following user defined functions to perform given operations on the list named
"status":
Add (Visitors) - Toadd an object containing Gender of visitor who are in the age range of 15
to 20.
Display () - To show the objects from the list and count and display the number of Male and
Female entries in the list.
For example: If the list of Visitors contains:
[['305', "10/11/2022", “Geeta”,"F”, 35],
['306', "10/11/2022", “Arham”,"M”, 15],
['307', "11/11/2022", “David”,"M”, 18],
['308', "11/11/2022", “Madhuri”,"F”, 17],
['309', "11/11/2022", “Sikandar”,"M”, 13]]
The list should contain F
M
M
The output should be: Female: 1
Male: 2

SECTION-D
31. 2+3
(a) Write the output of the code given below:
a=5
def add(b=2):
global a
a=a+b
print(a,'#',b)
return a
b=add(a)
print(a,'#',b)
b=add(b)
print(a,'#',b)

(b) The code given below inserts the following record in the table
Employee: EmpNo – integer Name – string
Department – string Salary – integer
Note the following to establish connectivity between Python and MYSQL:
Username is root
Password is brick
The table exists in a MYSQL database named organization.
The details (EmpNo, Name, Department and Salary) are to be accepted from the user.

32. A list named studentAge stores the age of students of a class. 3


Write the Python command to import the required module and (using built-in function) to
display the most common age value from the given list.

33. (a) What is the advantage of using a csv file for permanent storage? 1+4
(b) Write a Program in Python that defines and calls the following user defined functions:
add() – To accept and add data of an employee to a CSV file ‘empdata.csv’. Each record
consists of a list with fieldelements as eid, ename and salaryto store empid, emp name and
emp salary respectively.
search()- To display the records of the emp whose salary is more than 10000.
SECTION E
34. Mubarak creates a table Items with a set of records to maintain the details of items. After 1+2+2
creation of the table, he has entered data of 5 items in the table.
Table: items
ItemNo Item Scode Qty Rate LastBuy
2005 Sharpener 23 60 8 31-JUN-09
Classic
2003 Balls 22 50 25 01-FEB-10
2002 Gel Pen Premium 21 150 12 24-FEB-10
2006 Gel Pen Classic 21 250 20 11-MAR-09
2001 Eraser Small 22 220 6 19-JAN-09
Based on the data given above answer the following questions:
(i) Identify the most appropriate column, which can be considered as Primary key.
(ii) If 3 columns are added and 2 rows are deleted from the table , what will be the new
degree and cardinality of the above table?
(iii) Write the statements to:
(a) Insert the following record into the table as (2024, Point Pen, 20, 11, 350, 15-
NOV-2022).
(b) Increase the rate of the items by 2% whose name ends with ‘c’.
OR (Option for part iii only)
(iii) Write the statements to:
(a) Delete the record of items having rate greater than equal to 10.
(b) Add a column REMARKS in the table with datatype as varchar with 50 characters
35. (a) What is the difference between ‘r’ and ‘rb’ mode in Python file ? 2+3
(b) A binary file “STUDENT.DAT” has structure [admission_number, Name,
Percentage]. Write a function countrec() in Python that would read contents of the
file “STUDENT.DAT” and display the details of those students whose percentage
is above 90. Also display number of students scoring above 90%

You might also like