SQP 03 - QP
SQP 03 - QP
MARKING SCHEME
CLASS - XII MAX. MARKS: 70
_________________________________________________________________________________________
SECTION A
1. State True or False : 1
Python does not allows same variable to hold different data literals / data types.
Ans : False
2. Which of the following datatype in python is used to represent any real number : 1
(a) int , (b) complex , ( c ) float , (d ) bool
( c ) float
3. 1
Given the following list
place=[ (“State” , ”Sikkim”), (“Population”, ”8 Lakh”) ]
which of the following method will turn the above list place into something like
{ “State” : “Sikkim” , “Population” : “8 Lakh” }
when applied over it :
a. dictionary( )
b. to_dict( )
c. dict( )
d. Items( )
c. dict( )
b. False
d) Poser is ending
6. Which of the following mode in file opening statement does not overwrites the any previous 1
content of the file ?
a. w+ b. r+ c. a+ d. None of the above
c. a+
7. ___________ command is used to a remove a tuple or many tuple(s) from a table / relation 1
in SQL
b. delete
8. Which of the following commands will remove a particular table’s schema along with its data 1
, contained in a MySQL database?
a. DROP DATABASE
b. ALTER TABLE
c. DELETE FROM TABLE
d. DROP TABLE
c. DROP TABLE
9. Which of the following statement(s) would give an error after executing the following code? 1
EM = “Blue Tick will cost $8” # Statement 1
print( EM) # Statement 2
ME = “Nothing costs more than Truth” # Statement 3
EM *= 2 # Statement 4
EM [-1: -3 : -1] += ME[ : 7] # Statement 5
a. Statement 3
b. Statement 4
c. Statement 5
d. Statement 4 and 5
c.Satement 5
10. ……………………is an attribute, which is not a primary key of a table but has a capability of 1
becoming a primary key.
a. Primary Key
b. Foreign Key
c. Candidate Key
d. Alternate Key
c.Candidate Key
11. The seek( 8 ) if applied to a text file stream object moves the read cursor/ pointer : 1
12. To restrict repeated values from being entered under a column of table, while creating the 1
table in MySQL we take help of which of the following :
a. DESCRIBE
b. NULL
c. PRIMARY KEY
d. DISTINCT
b. PRIMARY KEY
13 ……………………is a communication methodology designed to establish a direct and dedicated 1
communication between an internet user and his/her ISP.
c. PPP
a. 10.0
b. -15.0
c. 15.0
d. -10.0
c. 15.0
15. Which function is not an aggregate function ? 1
a. sum()
b. total()
c. count()
d. avg()
b. total( )
16. Which of the following method is needed to create an object using whose method a query 1
is executed from python’s front end connected to a mysql database.
a. cursor( )
b. execute( )
c. Connect( )
d. fetchall( )
a. cursor( )
Q17 and 18 are ASSERTION AND REASONING based questions.
Mark the correct choice as
i. Both A and R are true and R is the correct explanation for A
ii. Both A and R are true and R is not the correct explanation for A
iii. A is True but R is False
iv. A is false but R is True
17. Assertion(A):Key word arguments are related to the function calls 1
Reason(R): When you use keyword arguments in a function call, the caller identifies the
arguments by the parameter name
18. Assertion (A): - The acronym for a CSV File is “ Comma Separated Value” 1
Reasoning (R):- Since the seprator symbols between data elements with a line should
always be a comma hence the name CSV originated.
f=0
num = input("Enter a number whose factorial you want to evaluate :")
n = num
while num > 1:
f = f * num
num -= 1
else:
print("The factorial of : ", n , "is" , f)
Ans :
1. f =1 # f is wrongly initialized to 0
2. int( ) must be used with input( )
3. else part of while should be properly indented
4. print("The factorial of : ", n , "is" , f)
Hence the correct code will be :
f=1
num = int(input("Enter a number whose factorial you want to evaluate :"))
org_num = num
while num > 1:
f = f * num
num -= 1
else:
print("The factorial of : ", org_num , "is" , f)
20. 2
Write any one point of difference between
i. Circuit Switching and Packet Switching.
ii. Co-axial cable and Fiber – optic cable
OR
Write two points of difference between Bus and Star Topologies.
Ans : lyli#
NUM= [10,23,14,54,32]
for VAR in range (4,0,-1):
A=NUM[VAR]
B=NUM[VAR-1]
if VAR > len(NUM)//2:
print(Compy(A,B),'#', end=' ')
else:
print(Compy(B),'%',end=' ')
OR
Ans : ( 4,4,5,5)
25. Differentiate between ‘WHERE’ clause and ‘HAVING’ clause in MySQL with appropriate 2
example.
OR
Differentiate between DELETE and DROP keywords used in MySQL,giving suitable example
for each
Correct difference one mark
Correct example one mark
SECTION C
26. (a) Consider the following tables – Bank_Account and Branch: 1+2
BANK_ACCOUNT
E_CODE NAME
E01 ASHISH
E02 SURESH
BRANCH
E_CODE LOCATION
E05 MUMBAI
Ans :
+--------+--------+--------+----------+
| e_code | name | e_code | location |
+--------+--------+--------+-----------+
| E01 | ASHISH | E05 | MUMBAI |
| E02 | SURESH | E05 | MUMBAI |
+--------+--------+--------+------------+
(1 mark for correct output)
(b) Write the output of the queries (i) to (iv) based on the table, TECHER given below:
TEACHER
TCODE TNAME SUBJECT SEX SALARY
5467 Narendra Kumar Computer Science M 70000
6754 Jay Prakash Accountancy M Null
8976 Ajay Kumar Chemistry M 65000
5674 Jhuma Nath English F 55000
8756 Divya Bothra Computer Science F 75000
6574 Priyam Kundu Physics M Null
3425 Dinesh Verma Economics M 71000
Ans:I)
SUBJECT
Computer Science
Chemistry
English
Economics
II)
SUBJECT TOTA_FACUL
Computer Science 2
III)
TNAME
Dinesh Verma
Narendra Kumar
IV)
MAX(SALARY)
70000
( ½ mark for the correct output)
27. Write a function COUNTLINES( ) which reads a text file STORY.TXT and then count and 3
display the number of the lines which starts and ends with same letter irrespective of its
case . For example if the content of the text file STORY.TXT is :
Ans :
def COUNTLINES():
fin = open("Story.txt", 'r')
lines = fin.readlines()
count = 0
for line in lines:
if line[0].lower() == line[-1].lower():
count+=1
else:
print("The Number of lines starting with same letter is",count)
fin.close()
( ½ mark for correctly opening and closing the file ½ for readlines() , ½ mark for correct loop
½ for correct if statement, ½ mark for correctly incrementing count , ½ mark for displaying
the correct output)
OR
Write a function VOWEL_WORDS which reads a text file TESTFILE.TXT and then count and
display the number of words starting with vowels ‘a’ or ‘u’ (including capital cases A and U
too)
For example is the text in the file TESTFILE.txt is :
The train from Andaman has earned the name ‘Floating Train’. What is so unique about this
train to receive such a name?
Ans :
def VOWEL_WORDS():
fin = open("TESTFILE.TXT" , 'r')
content = fin.read()
words = content.split()
acount,ucount = 0,0
for word in words:
if word[0] in "aA":
acount+=1
if word[0] in "uU":
ucount+=1
else:
print("The Number of words starting with letter ‘a’ is :",acount)
print("The Number of words starting with letter ‘u’ is :",ucount)
VOWEL_WORDS()
(½ mark for correctly opening and closing the file, ½ for readlines() , ½ mark for correct
loops, ½ for correct if statement, ½ mark for correctly incrementing counts, ½ mark for
displaying the correct output)
Note: Any other relevant and correct code may be marked
28. (a) Write the outputs of the SQL queries (i) to (iv) based on the relations Event and 3
COMPANY given below:
Table : Event
EventId EventName Date Organizer Budget
101 Wedding 26/10/2019 1004 700000
102 Birthday Bash 05/11/2019 1002 70000
103 Engagement 13/11/2019 1004 200000
104 Wedding 01/12/2019 1003 800000
105 Farewell 25/11/2019 1001 20000
Table : Company
OrganizerId Name Phone
1001 Peter 9745684122
1002 Henry 9468731216
1003 Smith 9357861542
1004 Fred 9168734567
Ans : (a) I)
Organizer Min(date)
1004 26/10/2019
1002 05/11/2019
1003 01/12/2019
1001 25/11/2019
( ½ mark for the correct output)
(ii)
Max(date) Min(date)
01/12/2019 26/10/2019
( ½ mark for the correct output)
iii)
EventName Name Phone
Birthday Bash Henry 9468731216
Farewell Peter 9745684122
( ½ mark for the correct output)
iv)
Name Date
Smith 01/12/2019
( ½ x 4 = 2)
29. Write a function INDEX_LIST(L), where L is the list of elements passed as argument to the 3
function. The function returns another list named ‘indexList’ that stores the indices of all
Elements of L which has a even unit place digit.
For example:
If L contains [12,4,15,11,9,56]
The indexList will have - [0,1,5]
def INDEX_LIST(L):
indexList = [ ]
for i in range(0,len(L)):
if (L[i]%10)%2 == 0:
indexList.append(i)
else:
return indexList
(½ mark for correct function header, 1 mark for correct loop , 1 mark for correct if
statement, ½ mark for return statement)
Note: Any other relevant and correct code may be marked
(ii) Pop_tour() – To Pop the list objects from the stack and display them. Also, display “No
more tours” when there are no elements in the stack.
For example if the following dictionaries are passed to Push_tour( ) function in the following
sequence:
{ ‘Name’: ‘Goa’ , ‘PeakSeason’ : ‘December’ , ‘Budget’ : 15000 , ‘Famous’:’Beaches’}
{ ‘Name’: ‘Nainital’ , ‘PeakSeason’ : ‘May’ , ‘Budget’ : 9000 , ‘Famous’:’Nature’}
{ ‘Name’: ‘Sikkim’ , ‘PeakSeason’ : ‘May’ , ‘Budget’ : 9500 , ‘Famous’:’Mountains’}
{ ‘Name’: ‘Kerala’ , ‘PeakSeason’ : ‘November’ , ‘Budget’ : 15000 , ‘Famous’:’Back Waters’}
{ ‘Name’: ‘Orissa’ , ‘PeakSeason’ : ‘January’ , ‘Budget’ : 8000 , ‘Famous’:’Temples’}
Ans :
tour = [ ]
def Push_tour( tour_dict ) :
if tour_dict[‘Budget’] < 10000 :
LstTour = [ tour_dict[‘Name’] , tour_dict[‘PeakSeason’] ]
tour.append( LstTour )
def Pop_tour( ) :
while tour != [ ] :
T = tour.pop( )
print(T)
else:
print( “No more tours”)
(1.5 marks for correct push_element() and 1.5 marks for correct pop_element())
OR
Write a function in Python, Push(stack, SItem) where , SItem is a List containing the details
of stationary items in a format like – [Name , price , Unit , Company , MRP ].
The function should push the company names of those items in the stack whose price is 10
% percent less than its MRP. Also write a function print_stack( ) to display the Item Names
and the count of Items pushed into the stack.
For example:
If following data is passed to the function:
[ ‘Pen’ , 120.00 , ‘Pcs.’ , ‘Reynolds’ , 132.00 ]
[‘Paper’, 345.00 , ‘Rim’ , ‘Camel’, 500.00]
[Eraser , 100.00 , ‘Box’ , ‘IBP’ , 110.00
The stack should contain
Eraser
Pen
The output should be:
The count of elements in the stack is 2
Ans :
def Push(stack , SItem) :
if SItem[ 1] == SItem[4] * 0.90 :
Stack.append(SItem)
def print_stack( ):
Count = len(stack)
while stack != [ ]:
Item = stack.pop()
print( Item[ 0 ] )
else:
print(“Total items present in the stack is :”, count)
(1 mark for correct function header, 1 mark for correct loop, ½ mark for correct If
statement, ½ mark for correct display of count)
SECTION D
31. “VidyaDaan” an NGO is planning to setup its new campus at Nagpur for its web-based 5
activities. The campus has four(04) UNITS as shown below:
i) Suggest an ideal cable layout for connecting the above UNITs.
ii)Suggest the most suitable place i.e. UNIT to install the server for the above
iii)
Which network device is used to connect the computers in all UNITs?
iv)Suggest the placement of Repeater in the UNITs of above network.
v) NGO is planning to connect its Regional Office at Kota, Rajasthan. Which out of
the following wired communication, will you suggest for a very high-speed
Connectivity ?
(a) Twisted Pair cable (b) Ethernet cable (c) Optical Fiber
Finance Resource
ii. Admin
iii. SWITCH/HUB
iv. ADMIN & FINANCE
v. (c) Optical Fiber
Ans : 3%6%
(1 mark for 3% and 1 mark for 6%)
(b) The code given below inserts the following record in the table Emp:
EmpNo – integer
EName – string
Desig – string
Salary – integer
Note the following to establish connectivity between Python and MYSQL:
Username is admin
Password is 22admin66
The table exists in a MYSQL database named company.
The details (EmpNo, EName, Desig and Salary) are to be accepted from the user.
Write the following missing statements to complete the code:
Statement 1 – to establish a connectivity to the table in the database
Statement 2 - to form the cursor object
Statement 3 – to execute the command that inserts the record in the table Student.
OR
(b) The code given below reads the following record from the table named product and
displays only those records which have name starting with a specific letters :
PId – integer
PName – string
Price – integer Marks – integer
Note the following to establish connectivity between Python and MYSQL:
Username is admin
Password is 22admin66
The table exists in a MYSQL database named inventory.
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 products whose
name starts with a specific letters.
Statement 3- to read the complete result of the query (records whose product
name starts with a specific letters ) into the object named data, from the table
student in the database.
33. What is the significance of a delimiter symbol in a csv file? Write a Program in Python that 5
defines and calls the following user defined functions:
(i) ADD_CONT() – To accept and add data of a contact to a CSV file ‘address.csv’.
Each record consists of a list with field elements as contId, cname and cmobile to
store contact id, contact name and contact number respectively.
(ii) COUNT_CONT() – To count the number of records present in the CSV file named
‘address.csv’.
Ans: The delimiter symbol is used to separate two data elements within a line of text in the
csv file. By default it is comma but can be set to any other symbol.
import csv
def ADD_CONT( ):
fout=open("address.csv","a",newline="\n")
wr=csv.writer(fout)
contid=int(input("Enter Contact id :: "))
cname=input("Enter Contact name :: ")
cmobile=int(input("Enter mobile number :: "))
lst=[contid, cname, cmobile] ---------1/2 mark
wr.writerow(lst) ---------1/2 mark
fout.close()
def COUNT_CONT( ):
fin=open("address.csv","r",newline="\n")
data=csv.reader(fin)
d=list(data)
print(len(d))
fin.close()
ADD_CONT( )
COUNT_CONT()
(1 mark for advantage ½ mark for importing csv module , 1 ½ marks each for correct
definition of ADD_CONT( ) and COUNT_CONT( ), ½ mark for function call statements )
OR
How csv file is different from a binary file? Write a Program in Python that defines and calls
the following user defined functions:
(i) save() – To accept and add data of watches to a CSV file ‘watchdata.csv’. Each
record consists of a list with field elements as watchid, wname and wprice to store
watch id, watch name and watch price respectively.
(ii) search()- To display the records of the watch whose price is more than 6000.
Ans: CSV file stores data using ASCII Plain Text Format. Or any other correct answer award
one mark.
import csv
def save():
fout=open(“watchdata.csv","a",newline='\n')
wr=csv.writer(fout)
watchid=int(input("Enter Furniture Id :: "))
wname=input("Enter Furniture name :: ")
wprice=int(input("Enter price :: "))
FD=[ watchid, wname, wprice ]
wr.writerow(FD)
fout.close( )
def search():
fin=open(“watchdata.csv","r",newline='\n')
data=csv.reader(fin)
found=False print("The Details are")
for i in data:
if int(i[2])>6000:
found=True
print(i[0],i[1],i[2])
if found==False:
print("Record not found")
fin.close()
save()
print("Now displaying")
search()
(1 mark for difference, ½ mark for importing csv module, 1 ½ marks each for correct
definition of add() and search() , ½ mark for function call statements)
SECTION E
34 Sagar a cloth merchant creates a table CLIENT with a set of records to maintain the client’s 1+1+
order volume in Qtr1, Qtr2, Qtr3 and their total. After creation of the table, he has entered 2
data of 7 clients in the table.
CLIENT
ClientName Client_ID Qtr1 Qtr2 Qtr3 Total
Suraj C120 200 300 400 900
Radha C650 190 356 220 766
Estha C430 200 100 400 700
Karuna C790 130 540 380 1050
Naresh C660 200 400 800 1400
Varun C233 400 300 220 920
Kritika C540 500 100 400 1000
Ans :
(i ) Client_ID (1 mark for correct answer)
(ii) 6x7 = 42 ( 1 Marks for correct answer)
(iii) Update Client set Qtr2 = 200 , Qtr3- 600 , total = 1000 where Client_ID = 660;
( 2 marks for fully correct answer / 1 mark for partially correct
answer)
OR
(iii) (a) Delete From Client where total between 500 and 900; ( 1 mark )
(b) ALTER TABLE Client ADD Ratings int CHECK ( Ratings between 1 and 5)
( 1 mark for use of ALTER and 1 mark for CHECK Constraint )
35. Vaishanavi is a budding Python programmer. She has written a code and created a binary 4
file phonebook.dat with contactNo, name and blocked [ Y/ N ]. The file contains 10 records
as a dictionary like {‘contactNo’ : 32344455 , ‘name’: ‘kamal kant’ ,’blocked’ : “Y” }
She now wants to shift all the records which have blocked = ‘Y’ status from phonebook.dat
to a binary file blocked.dat also all records which have blocked = ‘N’ status from
phonebook.dat to unblocked.dat. She also wants to keep count and print the total number
of blocked and unblocked records. As a Python expert, help her to complete the following
code based on the requirement given above:
Ans :
(i) pickle ( 1 mark)
(ii) open( “blocked.dat” , “wb”) ; open(“unblocked.dat”,”wb”) ( ½ + ½ )
(iii) pickle.load(fin) ( 1 Mark)
(iv) pickle.dump(rec,fblock);pickle.dump(rec , funblock) ( ½ + ½ )