Class 12 Computer Science Exam Marking Scheme
Class 12 Computer Science Exam Marking Scheme
In Dynamic Typing the datatype attached with the variable can change during the program run.
Ans) True
Ans) b and c
None, 123int
D1={"Math":25,"CS":6,"Biology":23,"Chemistry":20}
A.True
B.False
C.Error
D.None
Ans) False
4. Seth was attending a seminar on the topic Python operators. He was given a set of questions to 1
solve. In one particular question he had a doubt about the output generated. Help him to solve it,
with your understanding of Operators.
Page 1 of 25
Ans) Computer
a = "assistance"
a = a.partition('a')
b = a[0] + "-" + a[1] + "-" + a[2]
print (b)
a) -a-ssistance
b) -a-ssist-nce
c) a-ssist-nce
d) -a-ssist-ance
Ans) a) -a-ssistance
6 If a text file is opened in w+ mode, then what is the initial position of file pointer/cursor? 1
a. Beginning of file
b. End of the file
c. Beginning of the last line of text file
d. Undetermined
Ans) a)Beginning of the file
7 An alternate key is a _________, which is not the primary key of the table.
a. Primary Key
b. Foreign Key
c. Candidate Key
d. Unique Key
Ans) c) Candidate key
9 What will be the values stored in final_S upon execution if two strings S1 and S2 are taken as 1
“Delhi” and “New Delhi” respectively?
(i) final_S = S1 > S 2
(ii) final_S = S1. lower ( ) < S2
Ans) (i)False
(ii)False
10 A relationship is formed via ------ ,that relates two tables where one table references another 1
table’s key.
Page 2 of 25
a. Candidate key
b. Primary key
c. Foreign key
d. Check constraint
Ans) c)Foreign key
11 Syntax of seek function in Python is myfile.seek(offset, reference_point) where myfile is the file
object. What is the default value of reference_point?
a. 0
b. 1
c. 2
d. 3
Ans) a)0
13 ___________ is the protocol used to send emails to the e-mail server and _________ is the
protocol used to download mail to the client computer from the server.
(a) SMTP,POP
(b) HTTP,POP
(c) FTP,TELNET
(d) HTTP,IMAP
Ans) SMTP,POP
15 Table Student has the columns RNO and SCORE. It has 3 rows in it. Following two SQL 1
statements were executed, that produced the outputs as 45 and 2 respectively:
Page 3 of 25
(i) Select AVG(SCORE) from Student;
(ii) Select COUNT(SCORE ) from Student;
Data in SCORE column is same in two rows. What data is present in the SCORE column in the
three rows ?
Ans)
SCORE
45
45
NULL
16 Which method of cursor class is used to get the number of rows affected after any of the 1
insert/update/delete operation is executed from Python?
a. cursor.rowcount
b. cursor.rowscount
c. cursor.fetchall()
d. cursor.executequery()
Ans) cursor.rowcount
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): Preserving the data for future purpose in Python is called pickling. 1
Reason (R): Unpickling is a technique that returns the byte stream produced by pickling back into
Python objects.
Ans) d)A is false but R is True
18 Assertion (A) : A variable defined outside any function or any block is known as a global variable. 1
Reason ( R ) : A variable defined inside any function or a block is known as a local variable.
Ans) b) Both A and R are true and R is not the correct explanation for A
SECTION B
19 Consider the following code written by a programming student. The student is a beginner and has 2
made few errors in the code. You are required to rewrite the code after correcting it and underline
the corrections.
Def swap(d):
n = {}
Page 4 of 25
values = d.values()
keys = list(d.keys[])
k=0
for i in values
n(i) = keys[k]
k=+1
return n
result = swap({‘a’:1,’b’:2,’c’:3})
print(result)
Ans) def swap(d):
n = {}
values = d.values()
keys = list(d.keys())
k=0
for i in values:
n[i] = keys[k]
k+=1
return n
result = swap({‘a’:1,‘b’:2,‘c’:3})
print(result)
20 What is the difference between Radio wave Transmission and Microwave Transmission? 2
Ans)
OR
Ans) Web Browser: A web browser is a software which is used for displaying the content on web
page(s). It is used by the client to view websites. Examples of web browser—Google Chrome,
Firefox, Internet Explorer, Safari, Opera, etc.
Web Server: A web server is a software which entertains the request(s) made by a web browser. A
web server has different ports to handle different requests from web browser, like generally FTP
request is handled at Port 110 and HTTP request is handled at Port 80. Example of web server is
Apache.
Page 5 of 25
( 1 mark for each correct point of difference- Any valid two points)
upper = 'CYBERCRIME'
seq = '12345678'
my_list2 = upper[6:]
my_list3 = seq[-3:]
final_list = my_list2 + my_list3
print( my_list2 , my_list3 )
Ans) 405
(1 mark for correct answer)
Page 6 of 25
22 Consider the related tables in a database given below and answer the questions given. 2
TABLE:HOLIDAYS
TABLE:PACKAGE
PKG_NO
It is the linking field of the two tables and the Primary key of the parent table Package.
(1/2 mark for correct fieldname and ½ mark for correct reason)
b. Aman tried to insert the following record into the table HOLIDAYS but he was not able to.
What could be the possible reason?
R102,Moher,Dublin,2,23/10/02,MO
As per Referential Integrity, a record cannot be added in the related table if it doesn’t exist
in the parent table.
Page 7 of 25
(½ mark for every correct full form)
Ans) HTTP is a protocol used to transfer files from a web server onto a web browser in order to view a
web page that is on the Internet.
FTP is a protocol used to upload files from a workstation to an FTP server or download files from
an FTP station to workstations.
(1 mark for correct difference)
Page 8 of 25
S="1234abc"
L=list(S)
T=tuple()
index = len(L)
while index>0:
if L[index-1].isalpha():
T+=tuple(L[index-1])
index = index-1
print(T)
Ans) ('c', 'b', 'a')
( ½ mark for each correct alphabet , ½ mark for enclosing in parenthesis)
Or, one difference (1 mark) and one proper example (1 mark)is also valid
OR
Differentiate between a Candidate Key and Alternate Key with the help of an example.
Candidate key- All attributes or columns eligible to be chosen as Primary key ie no null values, no
duplicate values
Alternate key- All candidate keys which are not chosen as Primary key
GrNo Name PP Number
1234 Arun A123456
4567 Arnav Z345678
5678 A346878
In the above table Student, PP Number and GrNo are candidate keys out of which GrNo is chosen
Page 9 of 25
as Primary key. So, PP Number is the Alternate key.
(1 mark for the correct difference)
( 1 mark for any relevant example)
SECTION C
26 a. Consider the following tables – Employee and Department 1+2
EMPLOYEE
Page 10 of 25
b. Write the output of the queries (i) to (iv) based on the table, TEACHER given below:
i. Select Tname,department from teacher where Basic between 27200 and 32300 order by
T_name;
T_name department
Dinesh Goel Computer
Rakesh Sharma Physics
Suresh Kumar Chemistry
ii. Select department, count(Tno) from Teacher group by Department having count(*)>=2;
department count(Tno)
Physics 2
Chemistry 2
Computer 2
Commerce 2
Page 11 of 25
27 Write a function COUNTLINES() to count the number of lines in a text file, ‘DATA.TXT’ 3
which starts and end with ‘s’ and ‘g’ respectively.
Example:
If the file content is as follows:
Top Reasons to Learn Python:
Data science.
Scientific and mathematical computing.
Finance and trading.
System automation and administration.
Basic game development.
Security and penetration testing.
Page 12 of 25
OR
Write a function COUNTMAX() to read data from a text file ‘FILE.TXT’, and display the word
which has maximum number of vowels characters.
Example:
If the file content is as follows:
There are two types of files that can be handled in Python,
normal text files and binary files.Text files: In this type of file,
Each line of text is terminated with a special character called
EOL,which is the new line character in Python by default.
Page 13 of 25
f1.close()
COUNTMAX()
28 a. Write the outputs of the SQL queries (i) to (iv) based on the relations Book and Member 3
given below:
TABLE:BOOK
CODE BNAME TYPE PRICE
F101 The Priest Fiction 25
L102 German Easy Literature 30
C101 Tarzan in the lost world Comic 24
F102 Untold Story Fiction 35
C102 War heroes Comic 40
i. SELECT A.CODE,BNAME,MNAME FROM BOOK A, MEMBER B WHERE
A.CODE=B.CODE AND ISSUEDATE > “2016-12-30”;
MAX(ISSUEDATE) SUM(PRICE)
2017-02-23 59
( ½ mark for the correct output)
Page 14 of 25
iii. SELECT DISTINCT TYPE FROM BOOK WHERE PRICE >25 AND PRICE<35;
DISTINCT TYPE
LITERATURE
( ½ mark for the correct output)
MAX(PRICE) MIN(PRICE)
35 25
30 30
24 40
( ½ mark for the correct output)
29 Write a function MAKE_LIST(L) to return a new list L_NEW, in the following manner. 3
While making the new list L_NEW, the elements having even values in L will be replaced with its
half, and elements having odd values in L will be replaced with twice its value.
Example:
If the list L contains
[3, 4, 5, 16, 9]
Then the new list L_NEW should be displayed as
[6, 2,10,8, 18]
Ans) def MAKE_LIST(L):
L_NEW=[]
for i in range(len(L)):
if L[i] % 2 == 0:
L_NEW.append(L[i] // 2)
else:
L_NEW.append(L[i] * 2)
return (L_NEW)
L=[3, 4, 5, 16, 9]
print(MAKE_LIST(L))
Page 15 of 25
(½ mark for correct function header
1 mark for correct loop
1 mark for correct if statement
½ mark for return statement)
(1.5 marks for correct PUSH() and 1.5 marks for correct pop_Stack())
OR
Riya has created a dictionary containing Product names and prices as key value 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 write the statement to call the above function.
Page 16 of 25
For example:
If Riya has created the dictionary is as follows:
Product={"TV":10000, "MOBILE":4500, "PC":12500, "FURNITURE":5500}
The output from the program should be:
[‘FURNITURE’, ‘MOBILE’]
Ans) Product={"TV":10000, "MOBILE":4500, "PC":12500, "FURNITURE":5500}
stack=[]
def PRODPUSH(stack, P):
for k in Product:
if P[k]<6000:
stack.append(k)
PRODPUSH(stack, Product)
print(stack)
(1 mark for correct function header
1 mark for correct loop
½ mark for correct If statement
½ mark for correct function call)
SECTION D
31 Alpha Pvt Ltd is setting up the network in Chennai. There are four blocks- Block A, Block B,
Block C & Block D.
Block A
Block B
Block D
Block C
Page 17 of 25
i. Suggest the most suitable block to place the server to get the best and effective 1
connectivity, with a suitable reason.
Ans) Block A is the most appropriate to house the server as it has the maximum number of computers.
(1/2 mark for naming the server block and ½ mark for correct reason.)
ii. Suggest and draw the cable layout to efficiently connect various blocks of buildings 1
within the CHENNAI campus for connecting the digital devices.
Block B Block C
Block A
Block D
Ans) Switch/hub will be placed in all blocks to have connectivity within the block.
As per the layout suggested, repeaters can be used between blocks A and C(170 m), A and D(100
m) to regenerate the signals.
( 1 mark for correct answer)
Page 18 of 25
iv. The organization is planning to link its front office situated in the city in a hilly region 1
where cable connection is not possible. Suggest an economic way to connect with
reasonably high speed.
Ans) Radiowaves
( 1 mark for correct answer)
def increment(n):
L=[1,2,3]
L.append([4])
return L
L=[1,2,3]
m=increment(L)
print(L,m)
[1, 2, 3] [1, 2, 3, [4]]
(1 mark for each list)
b. The code given below inserts the following record in the table Employee:
ENo – integer
EName – string
Dept – string
Salary – integer
Page 19 of 25
mycursor = _________ #Statement 1
eno=int(input("Enter Employee No :: "))
ename=input("Enter Name :: ")
dept=input("Enter Dept :: ")
salary=int(input("Enter Salary :: "))
query="insert into employee values({},'{}','{}',{})".format(eno,ename,dept,salary)
___________ #Statement 2
____________ # Statement 3
print("Data Added successfully")
OR
val="bTeR%h2q8"
S=""
for x in range(len(val)):
if val[x].isdigit():
S=S+str(len(val))
elif val[x].islower():
S=S+val[x].upper()
elif val[x].isupper():
S=S+val[x].lower()
else:
S=S+"@@"
print(S)
Ans) BtEr@@H9Q9
Page 20 of 25
b. The code given below reads the following record from Table named Employee and
display those records where salary >= 30000 and <= 90000:
Empno – integer
EName – string
Desig – integer
Salary – integer
Note the following to establish connectivity between Python and MYSQL:
Username is root
Password is Password
The table exists in a MYSQL database named Bank.
import mysql.connector
mydb=mysql.connector.connect(host='localhost',user='root',passwd='Password',databas
e='bank')
mycursor =_________________ # statement1
mycursor.________________ #statement 2
data= __________________ # statement 3
for x in data:
print(x)
Ans) statement 1 – mydb.cursor()
statement 2 - mycursor.execute("select * from employee where salary>=30000 and
salary<=90000")
statement 3- mycursor.fetchall()
Page 21 of 25
33 In a csv file “Student.csv”, assuming that csv_reader is an object returned from csv.reader(), what 5
would be printed to the console with each iteration in the code given below?
def DISPLAY():
cnt=0
with open(“STORE.CSV”,”r”) as NI:
NewItem=csv.reader(NI)
for rec in NewItem:
cnt+=1
print(rec[0], “#”, rec[1])
print(“No of records is “,cnt)
#main-code
INSERT(“Sugar”, 38.00)
DISPLAY()
Give any one point of difference between a binary file and a csv file.
Page 22 of 25
Ans) Binary file:
• Extension is .dat
• Not human readable
• Stores data in the form of 0s and 1s
CSV file
• Extension is .csv
• Human readable
• Stores data like a text file
i. add() – To accept and add data of a toystore to a CSV file ‘toydata.csv’. Each record
consists of a list with field elements as tid, tname and tprice to store toy id, toy name
and toy price respectively.
ii. search()- To display the records of the toys whose price is more than 500.
Ans) def add():
fout=open("toydata.csv","a",newline='\n')
wr=csv.writer(fout)
tid=int(input("Enter Toy Id :: "))
tname=input("Enter toy name :: ")
tprice=int(input("Enter toy price :: "))
TD=[tid,tname,tprice]
wr.writerow(TD)
fout.close()
def search():
fin=open("toydata.csv","r",newline='\n')
data=csv.reader(fin)
found=False
print("The Details are: ")
for i in data:
if int(i[2])>500:
found=True
print(i[0],i[1],i[2])
if found==False:
print("Record not found")
fin.close()
add()
print("Now displaying")
search()
Page 23 of 25
Based on the data given, answer the following questions:
i. Identify the most appropriate column, which can be considered as Primary key.
Ans: Drinkcode
Ans:
New Degree: 6
New Cardinality: 4
(1/2 mark for correct degree and ½ mark for correct cardinality)
iii. Write the statements to:
Ans:
UPDATE HEALTHYDRINKS SET PRICE=PRICE + 3/100*PRICE WHERE
DNAME LIKE “A%”;
a. Delete the record of those juices having calories more than 140.
Ans:
DELETE FROM HEALTHYDRINKS WHERE CALORIES > 140;
Page 24 of 25
b. Add a column Vitamins in the table with datatype as varchar with 20 characters.
Ans.
ALTER TABLE HEALTHYDRINKS ADD Vitamins VARCHAR(20);
(ii) Write the correct statement required to open a temporary file named temp.dat. (Statement 2) 1
(iii) Which statement should Rehaan fill in Statement 3 to read the data from the binary file 2
record.dat, and in Statement 4 to write the updated data in the file, temp.dat?
Page 25 of 25