0% found this document useful (0 votes)
53 views25 pages

Class 12 Computer Science Exam Marking Scheme

Uploaded by

bvcbsecslab
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
53 views25 pages

Class 12 Computer Science Exam Marking Scheme

Uploaded by

bvcbsecslab
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 25

COMMON PRE-BOARD EXAMINATION: 2022-23

Class-XII Subject: COMPUTER SCIENCE (083)


MARKING SCEME
SECTION A

(1 mark to be awarded for every correct answer)


1. State True or False 1

In Dynamic Typing the datatype attached with the variable can change during the program run.

Ans) True

2. Which of the following is/are invalid identifier(s) in Python? 1

(a) _number (b) None (c)123int (d)decimal

Ans) b and c
None, 123int

3. Given the following dictionary: 1

D1={"Math":25,"CS":6,"Biology":23,"Chemistry":20}

What is printed by the following statement?

print (25 in D1)

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

5. Select the correct output of the code: 1

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

8 Command to remove the row(s) from table Category is:


a. drop table Category;
b. drop from Category;
c. delete * from Category;
d. delete from Category;

Ans) d)delete from Category;

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

12 In SQL where clause--------------


a. limits the row data being returned
b. limits the column data being returned
c. both (a) and (b) are correct
d. neither (a) nor (b) is correct
Ans) a)limits the row data being returned

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

14 Consider the expression given below. The value of X is: 1


X = 2+9*((3*12)-8)/10
a) 30.0
b) 27.2
c) 28.4
d) 30.8
Ans) b)27.2

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)

(½ mark for each correct correction made and underlined.)

20 What is the difference between Radio wave Transmission and Microwave Transmission? 2

Ans)

(1 mark for each correct difference - Any valid two points)

OR

Differentiate between Web server and Web browser.

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)

21 a. Write the output of the code given below: 1

upper = 'CYBERCRIME'
seq = '12345678'
my_list2 = upper[6:]
my_list3 = seq[-3:]
final_list = my_list2 + my_list3
print( my_list2 , my_list3 )

Ans) RIME 678

(1 mark for correct answer)


b. What will be the output of the following Python code? 1

Runs = {‘virat’:50, ‘rohit’:100, ‘rahul’:80, ‘rohit’:120, ‘Virat’:105}


Runs[‘jadeja’] = 50
total = 0
for k in Runs:
total+=Runs[k]
print(total)

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

PKG_NO LOC DEP_AIRPO NO_DA ST_DAT DEP_DA


RT YS E Y
T101 Tenerife Manchester 7 21/5/02 TH
T102 Tenerife Manchester 14 1/6/02 TU
C101 Corfu Gatwick 14 11/10/02 SA
C101 Rhodes Heathrow 7 15/6/02 MO

TABLE:PACKAGE

PACKAGENO ACTIVITY COSTPERDAY


T101 Sailing 300
K101 River Rafting 1200
T102 Volcano Exploration 530
C101 River Rafting 282
R101 Windsurfing 725
a. Identify the foreign key of table HOLIDAYS. Justify your answer.

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.

(1 mark for correct reason)

23 a. Write the full forms of the following: 2


i. Wi-Fi
ii. TCP/IP

Ans) Wireless Fidelity


Transmission Control Protocol/Internet Protocol

Page 7 of 25
(½ mark for every correct full form)

b. Mention one point of difference between HTTP and FTP

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)

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


X = 50
def Func1(start1):
global X
start1 += X
X += 20
start1 = Func2(start1)
return start1
def Func2(start1):
global X
X += 10
start1 += X
return start1
start = 100
start = Func1(start)
print(start,X)
230 80
(1 mark for each correct number)
OR

Predict the output of the Python code given below:

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)

25 Write two differences between HAVING and WHERE clauses in SQL. 2

(1 mark each for each correct difference)

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

What will be the output of the following statement?


SELECT E.Ecode,E.Ename,D. Department FROM EMPLOYEE E, DEPARTMENT D
WHERE E.Ecode = D.Ecode;
Ans) E.Ecode Ename D.Department
M01 Bhavya Marketing
S01 Mehul Sales
A05 Vansh Accounts
H03 Pallavi HR
(1 mark for correct output)

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

( ½ mark for the correct output)

ii. Select department, count(Tno) from Teacher group by Department having count(*)>=2;
department count(Tno)
Physics 2
Chemistry 2
Computer 2
Commerce 2

( ½ mark for the correct output)

iii. Select sum(Basic),avg(Allowances) from Teacher where Basic>=30000 and


Allowances IN(1200,1900,2000);
sum(Basic) avg(Allowances)
110600 1700.00

( ½ mark for the correct output)

iv. Select count(distinct Allowances) from Teacher;


count(distinct Allowances)
7
( ½ mark for the correct output)

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.

The COUNTLINES() function should display the output as:


The number of lines which starts with s and ends with g : 2

Ans) def COUNTLINES():


f1=open(“data.txt”, “r”)
lines=f1.readlines()
print(“All Data of file in lines: \n”,lines)
count=0
i=1
for line in lines:
i+=1
if line[0].upper()==’S’: and line[-1].upper()==’E’:
count+=1
print(“The number of lines which starts with s and ends with g : ”, count)
f1.close()
COUNTLINES()
( ½ 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)

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.

The COUNTMAX() function should display the output as:


Word with maximum number of vowels : terminated
Maximum no of vowels: 4
Ans) def COUNTMAX():
f1=open("FILE.txt","r")
s=f1.read()
countV=0
countC=0
words=s.split()
maxV=0
final=""
for word in words:
countV=0
for ch in word:
if ch.isalnum()==True:
if ch in "aeiouAEIOU":
countV+=1
if maxV<countV:
maxV=countV
final=word
print("Word with maximum number of vowels : ",final,"\nMaximum
no of vowels: ",maxV)

Page 13 of 25
f1.close()
COUNTMAX()

(½ mark for correctly opening and closing the file


½ for read()
½ 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 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”;

A.CODE BNAME MNAME


F102 Untold Story SARTHAK JOHN

( ½ mark for the correct output)

ii. SELECT MAX(ISSUEDATE),SUM(PRICE) FROM BOOK A, MEMBER B


WHERE A.CODE=B.CODE AND MNAME LIKE “%N”;

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)

iv. SELECT MAX(PRICE),MIN(PRICE) FROM BOOK GROUP BY TYPE;

MAX(PRICE) MIN(PRICE)
35 25
30 30
24 40
( ½ mark for the correct output)

b. Write the command to view the structure of table Book

Ans) Describe Book;


( 1 mark for correct answer)

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)

Note: Any other relevant and correct code may be marked


30 Jiya has a list containing 8 integers. You need to help her create a program with two user defined 3
functions to perform the following operations based on this list.
• Traverse the content of the list and push those numbers into a stack, which are divisible by both 5
and 3.
• Pop and display the contents of the stack.
For example:
If the sample content of the list is as follows:
L=[5,15,21,30,45,50,60,75]
Sample output of the code should be:
75 60 45 30 15
Ans)

(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

Distance between various blocks are as given below:

Number of computers in each block are given below:

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

(1 mark for layout )

iii. Suggest the placement of following devices with justification: 1


(a) Switch/Hub (b) Repeater

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)

v. Which type of Network is formed between the four blocks? 1

Ans) LAN(Local Area Network)


( 1 mark for correct answer)
32 a. Write the output of the code given below: 2+3

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

Note the following to establish connectivity between Python and MYSQL:


* Username is root
* Password is tiger
* The table exists in a MYSQL database named Company
* The details (ENo, EName, Dept, Salary) are to be accepted from the user.
Write the following missing statements to complete the code:
Statement 1 – to form the cursor object
Statement 2 – to execute the command that inserts the record in the table Employee.
Statement 3- to add the record permanently in the database.

import mysql.connector as mysql


def sql_data():
con1=mysql.connect(host="localhost",user="root", password="tiger",
database="Company")

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")

Ans) Statement 1 – Create cursor object


con1.cursor() (1 mark for correct statement)
Statement 2 – to execute the command that inserts the record in the table Employee.
mycursor.execute(query) (1 mark for correct statement)
Statement 3- to add the record permanently in the database.
con1.commit() (1 mark for correct statement)

OR

a. What will be the output of the following Python code?

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

(1 mark for first 5 characters, 1 mark for next 5 characters)

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.

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 employees
whose salary >=30000 and <=90000
Statement 3- to read the complete result of the query (records whose salary is in the
given range) into the object named data, from the table Employee in the database.

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()

(1 mark for each correct statement)

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?

for item in csv_reader:


print(item)

a. The individual value data that is separated by the delimiter


b. The row data as a list
c. The column data as a list
d. The full line of the file as a string
The row data as a list.

(1 mark for correct answer)


Neha is making a software on “Items & their prices” in which various records are to be
stored / retrieved in STORE.CSV data file. Each record consists of a list with field elements Item
and Price. Write Python function definitions and calls for the following user defined functions.

i. INSERT() – Add the data of an item to the CSV file


ii. DISPLAY() – Display the records present. Also show the number of records in the file.
Ans) import csv
def INSERT (Item, Price):
f=open(“STORE.CSV”, a)
fw=csv.writer(f)
fw.writerow([Item, Price])
f.close()

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()

(½ mark for importing csv module


1 ½ marks each for correct definitions of INSERT() and DISPLAY()
½ mark for function call statements
)
OR

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

(1 mark for any one difference)


Write a Program in Python that defines and calls the following user defined functions:

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()

(½ mark for importing csv module)


1 ½ marks each for correct definition of add() and search()
½ mark for function call statements)
SECTION E

34 Table : HEALTHYDRINKS 1+1+


2

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

(1 mark for correct answer)


ii. If two columns are added and 2 rows are deleted from the table HEALTHYDRINKS ,
what will be the new degree and cardinality of the above table?

Ans:

New Degree: 6
New Cardinality: 4

(1/2 mark for correct degree and ½ mark for correct cardinality)
iii. Write the statements to:

a. Insert the following record into the table

DrinkCode – 107, Dname – Santara Special, Price – 25.00, Calories – 130

Ans. INSERT INTO HEALTHYDRINKS VALUES(107,”Santara


Special”,25.00,130);
b. Increase the price of the juices by 3% whose name begins with ‘A’.

Ans:
UPDATE HEALTHYDRINKS SET PRICE=PRICE + 3/100*PRICE WHERE
DNAME LIKE “A%”;

(1 mark for each correct statement)


OR (Option for part iii only)

iii. Write the statements to:

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);

(1 mark for each correct statement)


35 As a Python expert, help Rehaan to complete the following code based on the requirement given:

import ____________ #Statement 1


def update_data():
rec={}
fin=open("record.dat","rb")
fout=open("_____________") #Statement 2
found=False
sid=int(input("Enter student id to update their marks :: "))
while True:
try:
rec=______________ #Statement 3
if rec["Student_id"]==sid:
found=True
rec["Marks"]=int(input("Enter new marks :: "))
pickle.____________ #Statement 4
else:
pickle.dump(rec,fout)
except:
break
if found==True:
print("The mark of student id ",sid," has been updated.")
else:
print("No student with such id is found")
fin.close()
fout.close()

(i) Which module should be imported in the program? (Statement 1) 1

(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?

Ans) (i) pickle(1 mark for correct module)


(ii) fout=open(‘temp.dat’, ‘wb’) (1 mark for correct statement)
(iii)pickle.load(fin)
pickle.dump(rec,fout)

(1 mark for each correct statement)

Page 25 of 25

You might also like