COMP.SC - QP - [SET - 1]-1
COMP.SC - QP - [SET - 1]-1
CLASS- XII
SUB : COMPUTER SCIENCE (083)
Time Allowed: 3 hours Maximum Marks: 70
General Instructions :-
Page 1 of 15
SECTION-A
Page 2 of 15
8. What will be the output of the following code? 1
L1, L2 = [10, 15, 20, 25], []
for i in range(len(L1)) :
L2. insert( i,L1.pop())
print (L1, L2,sep="&")
(a) [ ]&[25, 20, 15, 10]
(b) [10, 15, 20, 25]&[25, 20, 15, 10]
(c) [10, 15, 20, 25]&[10, 15, 20, 25]
(d) [25, 20, 15, 10]&[]
Page 3 of 15
13. What will be the output of the following code? 1
import random
List=["Delhi","Mumbai","Chennai","Kolkata"]
for y in range(4):
x = random.randint(1,3)
print(List[x],end="#")
(a) Delhi#Mumbai#Chennai#Kolkata#
(b) Mumbai#Chennai#Kolkata#Mumbai#
(c) Mumbai# Mumbai #Mumbai # Delhi#
(d) Mumbai# Mumbai #Chennai # Mumbai
14. Which of the following functions can not be used with a tuple? 1
(a) max( ) (b) sort
(c) count (d) sorted
15. When is the finally block executed? 1
(a) When there is no exception
(b) When there is an exception
(c) Only if some condition that has been specified is satisfied
(d) Always
16. If cross product is done on two tables Table1 (2 tuples and 3 attributes) 1
and Table2 (2 attributes and 3 tuples) then what will be the cardinality
of the resultant table?
Q17 and 18 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
17. Assertion (A) : A function is a block of organized and reusable 1
code that is used to perform a single, related
action.
Reason (R) : Function provides better modularity for your
application and a high degree of code reusability.
Page 4 of 15
Reason (R) : The information is organized with one record on
each line and each field is separated by comma.
SECTION-B
19. Rewrite the following code in Python after removing all syntax error(s). 2
Underline each correction done in the code.
value=30
for res in range(0, value)
If res%4==0:
print(res*4)
elseif res%5==0:
print(res+3)
else:
print(res+10)
22. Arjun has created a table SMS containing SRoll_no, Sname, SClass, 2
SPhone_no and percent. Later, he realizes that the field Sphone_no may
Page 5 of 15
have duplicate values. Help him to write a SQL command to set the
property of this field to deny duplicate values. Also he needs help to write
SQL command to see the structural detail of the table SMS.
OR
Ms. Trisha of a software company created a table Clients under a
database Company. After creating table, she now wants to add an
additional column CPortfolio to store textual information containing
maximum of 100 characters and that can’t be blank. Also she wants to
view all the tables present under the database Company. Help her to write
the SQL commands to complete the above tasks.
23. Predict the output of the Python code given below: 2
def fun(s):
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] >= 'n' and s[i] <= 'z'):
m = m + s[i-1]
elif (s[i].isupper()):
m = m + s[i].lower()
else:
m = m + '#'
print(m)
fun('Gini%Jony')
OR
Predict the output of the Python code given below:
def fun():
frequency = { }
list = ['a','b','c','a','c']
for index in list:
if index in frequency:
frequency[index]+=1
else:
Page 6 of 15
frequency[index]=1
print(len(frequency))
print(frequency)
fun()
24. Write the Python statement for each of the following tasks using BUILT- 2
IN functions/methods only:
(a) Sort the elements of a tuple Tup in ascending order.
(b) Remove an element present at index 3 of a List Li.
OR
(a) Convert the input to the type of element as entered.
(b) Find the total of values in a list of integers.
25. Write the output of the following code snippet.
V=70 2
def display(N):
global V
V=35
if N%9==0:
V=V*N
else:
V=V/N
print(V, end="*")
display(15)
print(int(V))
SECTION-C
26. (a) Refer the tables given below: 3
Table: Book
Code Sub
B1 English
B2 Physics
B3 History
B4 Science
Page 7 of 15
Table B: Stock
Table: PAYLEVEL
Page 8 of 15
27. (a) Write the outputs of the SQL queries (i) to (iv) based on the 2+1=3
relations PRODUCT and ORDER.
Table: PRODUCT
PID BRAND CITY_STOR PNAME PRICE
E
111 SONY DELHI TV 70000
Table: ORDER
CID CNAME QTY PID
101 ROHAN SHARMA 20 222
102 DEEPAK KUMAR 10 666
103 MOHAN KUMAR 5 111
104 SAHIL BANSAL 3 333
105 NEHA SONI 7 444
106 SONAL AGARWAL 5 333
107 ARUN SINGH 15 666
Page 9 of 15
Example: If content of the text file is: INDIA IS MY COUNTRY Output
will be: AIDNI SI MY COUNTRY
OR
Write a function countmy( )in Python to read the text file “Data.txt” and
count the number of times “my” or “My” occurs in the file.
For example if the file “Data.txt” contains:
“This is my website. I have displayed my preferences in the CHOICE
section.”
The countmy( ) function should display the output as:
my occurs 2 times.
29. Observe the following table and answer the parts (a) to (c): 3
Table: Store
ItemCode ItemName Qty Rate
10 Gel Pen Classic 1150 25
11 Sharpner 1500 10
12 Ball Pen 0.5 1600 12
13 Eraser 1600 5
15 Ball Pen 0.25 800 20
30. Mayank has created a dictionary containing names and marks as key value 3
pairs of 6 students. Write a function in Python PushName(S) to Push the
keys (name of the student) of the dictionary S into a stack, where the
corresponding value (marks) is greater than 75.
Also write a function POP(S) to delete an element from the stack S and
check for underflow in it.
For example: If the sample content of the dictionary is as follows
Page 10 of 15
S={"OM":66, "JAI":45, "BOB":95, "ALI":65, "ANU":90, "TOM":82}
SECTION-D
31. Consider the following tables ITEM and CUSTOMER, write SQL commands 1*4=4
for the statements (a) to (d)
TABLE: ITEM
TABLE: CUSTOMER
(a) To display the details of those Customers whose city is Delhi in the
descending order of Customer_Name.
(b) To display the details of Items whose Price is not in the range of 35000
to 55000 (Both values included).
Page 11 of 15
(c) To display the Customer_Name, City from table CUSTOMER and
Item_Name and Price from table ITEM, with their corresponding
matching I_ID.
(d) To increase the Price of all items by 1000 in the table ITEM.
32. Manish is a Python programmer working in a School. For the Result analysis 4
in School, he has created a csv file named student.csv, to store the results of
students in different Exams. The structure of record of file student.csv is
[RollNo, Name, Percentage] where, RollNo is the Roll Number of student
(integer), Name is the Student Name (string) and
Percentage is the percentage of marks secured by the student (float).
For efficiently maintaining data of the Result analysis, Manish wants to write
the following user defined functions.
(a) ADD() – To accept and add data of students to a CSV file ‘student.csv’.
(b) Display() – To read all content of “student.csv” and display records of
only those students who scored more than 90 percentage.
SECTION-E
33. “Sikshya for All” is an educational NGO. It is setting up its new campus at 1*5=5
Jaipur for its web-based activities. The campus has four buildings as shown in
the diagram below:
Training Building
Accounts Building
Page 12 of 15
Centre to Centre distances between various buildings as per architectural
drawings (in meters) is as follows:
Main Building to Resource Building 120 m
Main Building to Training Building 40 m
Main Building to Accounts Building 135 m
Resource Building to Training Building 125 m
Resource Building to Accounts Building 45 m
Training Building to Accounts Building 45 m
Expected number of Computers in each building:
Main Building 15
Resource Building 25
Training Building 250
Accounts Building 10
Page 13 of 15
▪ Bus Number
▪ Bus Starting Point
▪ Bus Destination
OR
(a) Write any two differences between ‘rb’ and ‘ab’ modes w.r.t. Binary
files.
(b) A binary file “salary.dat” has structure [employee id, employee name,
salary]. Write a function CountRec() in Python that would read
contents of the file “salary.dat” and display the details of those
employee whose salary is above 20000.
35. (a) Define the term Cardinality with respect to RDBMS. 1+4=5
(b) A company has stored the data of its employees in emp Table. The
management of the company has decided to increase the salary by 20%
of all those employees who belong to the IT Department. As a Software
programmer. Help the management by writing the following missing
statements 1-4 to complete the code:
Page 14 of 15
OR
(a) Define the term degree with respect to RDBMS.
(b) The code given below intends to delete a record from the table
‘Employee’ available in the database ‘Company’, whose ‘Dept’ is
‘Elect’ and Grade is ‘G4’. Write the following missing statements 1-4
to complete the code:
import mysql.connector as mycon
mydb= #Statement 1
mycursor= #Statement 2
mycursor.execute ( ) #Statement 3
mydb. #Statement 4
Statement 1 - To form the database connection object.
Statement 2 - To form the cursor object
Statement 3 - To execute the command that will delete the desired
record from the table ‘Employee’.
Statement 4 - To make the changes after deletion of record permanently
in the database.
Note: The connection object parameters are localhost, user name is root
and password is 1234.
Page 15 of 15