QP Class Xii CS PB 2022
QP Class Xii CS PB 2022
GENERAL INSTRUCTIONS:
1. This question paper contains five sections, Section A to E.
2. All questions are compulsory.
3. Section A have 18 questions carrying 01 mark each.
4. Section B has 07 Very Short Answer type questions carrying 02 marks each.
5. Section C has 05 Short Answer type questions carrying 03 marks each.
6. Section D has 03 Long Answer type questions carrying 05 marks each.
7. Section E has 02 questions carrying 04 marks each. One internal choice is given in
Q35 against part c only.
8. All programming questions are to be answered using Python Language only.
SECTION – A
1 Which of the following is valid logical operator in Python: 1
(a) > (b) and (c) ** (d) OR
2 Write the valid identifier in the following: 1
(a) My.File (b) My-File (c) 2num (d) While
3 Write the statements to find square root of 25. 1
4 x={‘cs’:90,’maths’:84} 1
y={‘eng’:75,’phy’:87}
Write the statements to merge above two dictionaries.
(a) x+y (b) x.add(y) (c) x.join(y) (d) x.update(y)
5 5!=10 and not 10>15 or 5>10 1
Write the output of the given expression.
(a) False (b) None (c) True (d) false
6 The readlines() method returns: 1
(a) String (b) A list of integers
(c) A list of single characters (d) A list of lines
7 Suppose list1 = [0.5 * x for x in range(0,4)], 1
list1 is :
(a) [0, 1, 2, 3] (b) [0, 1, 2, 3, 4]
(c) [0.0, 0.5, 1.0, 1.5] (d) [0.0, 0.5, 1.0, 1.5, 2.0]
8 Which is known as range operator in MySQL? 1
( a) IN (b) BETWEEN (c) IS (d) DISTINCT
9 If column “salary” of table “EMP” contains the dataset {10000, 15000, 25000, 1
10000, 25000}, what will be the output of following SQL statement?
> SELECT SUM(DISTINCT SALARY) FROM EMP;
(a) 85000 (b) 25000 (c) 10000 (d) 50000
10 The following SQL is which type of join: 1
SELECT CUSTOMER.CUST_ID, ORDER.CUST_ID, NAME, ORDER_ID FROM
CUSTOMER, ORDER;
(a) Equi-join (b) Natural join (c) Outer join (d) Cartesian product
Page 1 of 8
11 TCP/IP stands for 1
(a) Transmission Communication Protocol / Internet Protocol
(b) Transmission Control Protocol / Internet Protocol
(c) Transport Control Protocol / Interwork Protocol
(d) Transport Control Protocol / Internet Protocol
12 Which is not a constraint in SQL? 1
( a) Unique (b) Distinct (c) Primary key (d) check
13 Consider the given expression: 1
51+4-3**3//19-3
Which of the following will be correct output if the given expression is evaluated?
(a) 50 (b) 51 (c) 52 (d) 55
14 Identify the name of connector to establish bridge between Python and MySQL 1
(a) mysql.connection (b) connector (c) mysql.connect (d) mysql.connector
15 The keys of a dictionary must be of ______ types. 1
(a) integer (b) mutable (c) immutable (d) None of these
16 What is the meaning of Remark LIKE “%5%5%”? 1
(a) Column Remark begins with two 5
(b) Column Remark ends with two 5
(c) Column Remark has more than two 5
(d) Column Remark has two 5 in it, at any position
17 Assertion (A): Python variable cannot hold values of different types at different 1
times.
Reason (R): Python supports dynamic typing.
a) Both A and R are true and R is the correct explanation of A.
b) Both A and R are true but R is not the correct explanation of A.
c) A is true but R is false.
d) A is false but R is true.
18 Assertion (A): In the case of rb mode, the file pointer exists at the beginning of 1
the file.
Reason (R): In the case of rb+ mode, the file pointer exists at the end of the file.
a) Both A and R are true and R is the correct explanation of A.
b) Both A and R are true but R is not the correct explanation of A.
c) A is true but R is false.
d) A is false but R is true.
SECTION -B
19 Rewrite the following code in python after removing all syntax error(s). 2
Underline each correction done in the code.
M= int(input("Enter a number")
for K in range(0,11):
if M=K:
print(M+K)
else
Print(M-K)
20 Write difference between HTML and XML. 2
OR
Write difference between IPv4 and IPv6
21 (a) Write output of the given expression : 1
> 18 % 4 ** 3 // 7 + 9 1
(b) Write output of the code given below :
> msg = “KVS Ahmedabad”
> print(msg [ : : -2])
Page 2 of 8
22 Differentiate between fetchone( ) and fetchall( ) function. 2
def Change(M,N):
for i in range(N):
if M[i]%5==0:
M[i]//=5
if M[i]%3==0:
M[i]//=3
L=[25,8,75,12]
Change(L,4)
for i in L:
print(i, end=”#”)
25 Define the primary key and foreign key with example. 2
OR
Define the check and default constraint with example.
SECTION – C
26 Write the query (i) and Output of SQL Queries (ii) to (v) based on PRODUCTS 1+2
table.
Table:
PCODE PNAME COMPANY PRICE STOCK WARRANTY
P001 TV BPL 10000 2200 3
P002 TV SONY 12000 150 4
P003 PC LENOVO 39000 100 NULL
P004 PC COMPAQ 38000 120 2
P005 HANDICAM SONY 18000 250 3
(i) Increase the stock as 100 Rs whose company name is SONY.
(ii) select distinct company from PRODUCTS;
(iii) select max(price) from PRODUCTS where warranty<=3;
(iv) select PNAME, sum(price) from PRODUCTS group by PNAME;
(v) select count(warranty) from PRODUCTS;
27 Write a function Show_cap() in Python to read content of a text file ‘NOTES.TXT’ 3
and display the entire content in capital letters. Example, if the file contains :
Wish you all the Best.
Page 3 of 8
Then the function should display output to be :
WISH YOU ALL THE BEST.
OR
Write a function Display_Lines() in Python which should read lines from a text file
MYFILE.TXT and display the lines starting with the alphabet K. Example, if the file
contains:
Kavita sighed.
It was an usually warmer day.
Keeping one’s hands cleaner was the only option.
Then the function should display:
Kavita sighed.
Keeping one’s hands cleaner was the only option.
28 Write the outputs SQL query (i) to (iv) based on the relations employee and Job 3
given below
Table : Employee
EmployeeId Name Sales JobId
E1 Sumit Sinha 110000 102
E2 Vijay Singh Tomar 130000 101
E3 Ajay Rajpal 140000 103
E4 Mohit Kumar 125000 102
E5 Sailja Singh 145000 103
Table: Job
JobId JobTitle Salary
101 President 200000
102 Vice President 125000
103 Administrator Assistant 80000
104 Accounting Manager 70000
105 Accountant 65000
106 Sales Manager 80000
(a) Give the output of following SQL statement:
(i) Select max(salary),min(salary) from job
(ii) Select Name,JobTitle, Sales from Employee,Job
where Employee.JobId=Job.JobId and JobId in (101,102)
(iii) Select JobId, count(*) from Employee group by JobId
(iv) Select name, EmployeeId from Employee where Name like ‘s%’;
(b) Display structure of the table employee.
29 Write a Python function to store the odd values and even values of the given list 3
as per the example given below :
Sample List : [23, 12, 4, 27, 10, 7, 54]
Expected Output :
original list : [23, 12, 4, 27, 10, 7, 54]
even list [12, 4, 10, 54]
odd list [23, 27, 7]
30 Reva has created a dictionary containing Product names and prices as key value 3
pairs of 4 products. Write a user defined function for the following:
● PRODPUSH() which takes a list as stack and the above dictionary as the
parameters. Push the keys (Pname of the product) of the dictionary into a stack,
where the corresponding price of the products is less than 6000. Also display the
count of elements pushed into the stack.
SECTION – D
31 Quick Learn University is setting up its academic blocks at Delhi and planning to 5
set up a network. The university has 3 academic blocks and one human resource
Centre as shown in the diagram given below:
Page 5 of 8
32 (a) Find the output 2+3
Msg1="WeLcOME"
Msg2="GUeSTs"
Msg3=""
for I in range(0,len(Msg2)+1):
if Msg1[I]>="A" and Msg1[I]<="M":
Msg3=Msg3+Msg1[I]
elif Msg1[I]>="N" and Msg1[I]<="Z":
Msg3=Msg3+Msg2[I]
else:
Msg3=Msg3+"*"
print(Msg3)
(b) Your friend Jagdish is writing a code to fetch data from a database Shop and
table name Products using Python. He has written incomplete code. You have to
help him write complete code:
import as m # Statement-1
object1 = m.connect(host="localhost", user="root", password="root",
database="Shop")
object2 = object1. # Statement-2
query = '''SELECT * FROM Products WHERE NAME LIKE "A%";'''
object2. (query) # Statement-3
object1.close()
OR
(a) s="Software@Python"
n = len(s)
m=" "
for i in range(0, n):
if (s[i] >= 't' and s[i] <= 'h'):
m = m +s[i].upper()
elif (s[i] >= 'a' and s[i] <= 'w'):
m = m +s[i-1]
elif (s[i].isupper()):
m = m + s[i].lower()
else:
m = m +'#'
print(m)
(b) The code given below reads the following record from the table named
emp and displays only those records who have salary greater than 15000
ENo – integer
Name – string
Desig – string
Salary – integer
Note the following to establish connectivity between Python and MYSQL:
• Username is root
• Password is tiger
• The table exists in a MYSQL database named organization. Write the
following missing statements to complete the code:
Statement 1 – to form the cursor object
Statement 2 – to execute the query that extracts records of those
Page 6 of 8
employees whose salary is greater than 15000.
Statement 3- to read the complete result of the query (records whose
salary is greater than 15000) into the object named data, from the table
emp in the database.
con1=mysql.connect(host="localhost",user="root",password="tiger",
database="organization")
mycursor=_______________ #Statement 1
print("Employees with salary greater than 15000 are : ")
_________________________ #Statement 2
data=__________________ #Statement 3
for i in data:
print(i)
print()
33 Explain the importance of CSV file in file handling. 5
Write a Program in Python that defines and calls the following user defined
functions:
a) ADDITION() – To accept and add data of an staff to a CSV file ‘info.csv’. Each
record consists of a list with field elements as empid, name and salary to store
employee id, employee name and employee salary respectively.
b) COUNT() – To count the number of records present in the CSV file named
‘info.csv’.
OR
Page 7 of 8
ECode EName Desig Remn
80001 Lokesh Programmer 50000
80004 Aradhana Manager 65000
80007 Jeevan Programmer 45000
80008 Arjun Admin 55000
80012 Priya Executive 35000
a) Identify the attribute best suitable to be declared as a primary key.
b) If one column is added and 1 row is deleted from the table, what will be the
new degree and cardinality of the table HRDATA.
c) Write the statements to :
35 AJAY of Class XII is writing a program to search a name in a CSV file “FILE1.csv”. 4
He has written the following code. As a programmer, help him to successfully
execute the given task.
******************
Page 8 of 8