Ans 2021

Download as pdf or txt
Download as pdf or txt
You are on page 1of 23

Strictly Confidential: (For Internal and Restricted use only)

Senior School Certificate Examination


September 2021
Marking Scheme – Computer Science (NEW) (SUBJECT CODE: 083)
(SERIES: 3HKP3ɓ/C , PAPER CODE – 91 , SET 4 )
General Instructions:
1. You are aware that evaluation is the most important process in the actual and correct assessment of
the candidates. A small mistake in evaluation may lead to serious problems which may affect the
future of the candidates, education system and the teaching profession. To avoid mistakes, it is
requested that before starting evaluation, you must read and understand the spot evaluation
guidelines carefully. Evaluation is a 10 -12 days mission for all of us. Hence, it is necessary that
you put in your best efforts in this process.
2. Evaluation is to be done as per instructions provided in the Marking Scheme. It should not be done
according to one’s own interpretation or any other consideration. Marking Scheme should be strictly
adhered to and religiously followed. However, while evaluating answers which are based on the
latest information or knowledge and/or are innovative, they may be assessed for their
correctness otherwise and marks be awarded to them.
3. The Head-Examiner must go through the first five answer books evaluated by each evaluator on the
first day, to ensure that evaluation has been carried out as per the instructions given in the Marking
Scheme. The remaining answer books meant for evaluation shall be given only after ensuring that
there is no significant variation in the marking of individual evaluators.
4. If a question has parts, please award marks on the right-hand side for each part. Marks awarded for
different parts of the question should then be totaled up and written in the left-hand margin and
encircled.
5. If a question does not have any parts, marks must be awarded in the left hand margin and encircled.
6. If a student has attempted an extra question, the answer of the question deserving more marks
should be retained and the other answer scored out.
7. No marks to be deducted for the cumulative effect of an error. It should be penalized only once.
8. A full scale of marks 70 (example: 1-70) has to be used. Please do not hesitate to award full marks if
the answer deserves it.
9. Every examiner has to necessarily do evaluation work for full working hours i.e. 8 hours every day and
evaluate 25 answer books per day.
10. Ensure that you do not make the following common types of errors committed by the Examiner in the
past:-
a. Leaving the answer or part thereof unassessed in an answer book.
b. Giving more marks for an answer than assigned to it.
c. Wrong transfer of marks from the inside pages of the answer book to the title page.
d. Wrong question wise totaling on the title page.
e. Wrong totaling of marks of the two columns on the title page.
f. Wrong grand total.
g. Marks in words and figures not tallying.
h. Wrong transfer of marks from the answer book to online award list.
i. Answers marked as correct, but marks not awarded. (Ensure that the right tick mark is correctly
and clearly indicated. It should merely be a line. Same is with the X for incorrect answers.)
j. Half or a part of the answer marked correct and the rest as wrong, but no marks awarded.
11. While evaluating the answer books, if the answer is found to be totally incorrect, it should be marked
as (X) and awarded zero (0) Marks.
12. Any unassessed portion, non-carrying over of marks to the title page, or totaling error detected by
the candidate shall damage the prestige of all the personnel engaged in the evaluation work as also
of the Board. Hence, in order to uphold the prestige of all concerned, it is again reiterated that the
instructions be followed meticulously and judiciously.
13. The Examiners should acquaint themselves with the guidelines given in the Guidelines for spot
Evaluation before starting the actual evaluation.
14. Every Examiner shall also ensure that all the answers are evaluated, marks carried over to the title
page, correctly totaled and written in figures and words.

[Sub Code: 083 Series: 3HKP3ɓ/C Paper Code:91] [Page #1/23]


15. The Board permits candidates to obtain a photocopy of the Answer Book on request in an RTI
application and also separately as a part of the re-evaluation process on payment of the processing
charges.

Specific Instructions:
1. This question paper contains two parts- Part A and B. Each part is compulsory.
2. Both Part A and Part B have choices.
3. Part-A has 2 sections:
a. Section – I is short answer questions, to be answered in one word or one line.
b. Section – II has two case studies questions. Each case study has 5 case-based sub parts. An
examinee is to attempt any 4 out of the 5 subparts.
4. Part - B is Descriptive Paper.
5. Part- B has three sections
a. Section-I is short answer questions of 2 marks each in which two questions have
internal options.
b. Section-II is long answer questions of 3 marks each in which two questions have internal
options.
c. Section-III is very long answer questions of 5 marks each in which one question has an
internal option.
6. All programming questions are to be answered using Python Language only

● All programming questions have to be answered with respect to Python only


● In Python, ignore case sensitivity for identifiers (Variable / Functions)
● In Python indentation is mandatory, however, the number of spaces used for indenting may vary
● In SQL related questions – both ways of text/character entries should be acceptable for Example:
“AMAR” and ‘amar’ both are acceptable.
● In SQL related questions – all date entries should be acceptable for Example: ‘YYYY-MM-DD’,
‘YY-MM-DD’, ‘DD-Mon-YY’, “DD/MM/YY”, ‘DD/MM/YY’, “MM/DD/YY”, ‘MM/DD/YY’ and
{MM/DD/YY} are correct.
● In SQL related questions – semicolon should be ignored for terminating the SQL statements
● In SQL related questions, ignore case sensitivity.

PART - A
Section I

Select the most appropriate option out of the options given for each question. Attempt any 15
questions from question no 1 to 21.

1 Which of the following options is/are not Python Keywords ? 1


(A) False
(B) Math
(C) WHILE
(D) break

Ans (B) Math


(C) WHILE

(½ Mark for writing each correct option)

[Sub Code: 083 Series: 3HKP3ɓ/C Paper Code:91] [Page #2/23]


2 Given the dictionary D={'Rno': 1, 'Name':'Suraj'} , write the output of 1
print(D('Name')).

Ans TypeError
OR
Suraj

(1 Mark for mentioning Error)


OR
(1 Mark for writing the correct output as it should have been
print(D['Name']) or print(D.get('Name')))
3 Identify the statement(s) from the following options which will raise TypeError 1
exception(s) :
(A) print('5' * 3)
(B) print( 5 * 3)
(C) print('5' + 3)
(D) print('5' + '3')

Ans (C) print('5' + 3)

(1 Mark for writing the correct option)

4 Identify the valid relational operator(s) in Python from the following : 1

(A) =
(B) <
(C) <>
(D) not

Ans (B) <

(1 Mark for writing the correct option)

5 For a string S declared as S = 'PYTHON', which of the following is incorrect? 1

(A) N=len(S)
(B) T = S
(C) 'T' in S
(D) S[0] = 'M'

Ans (D) S[0] = 'M'

(1 Mark for writing the correct option)


6 Write a single line statement in Python to assign the values 'BLUE', 'GREEN', 1
'RED' to a tuple named Colours.

Ans Colours = ('BLUE', 'GREEN', 'RED')

(1 Mark for writing the correct statement)

7 A List is declared as L = ['ONE', 'TWO', 'THREE' ] 1


What will be the output of the statement?
print(max(L))

[Sub Code: 083 Series: 3HKP3ɓ/C Paper Code:91] [Page #3/23]


Ans TWO

(1 Mark for writing the correct output)

8 Write the name of the built-in function / method of the math module which when 1
executed upon 5.8 as parameter, would return the nearest smaller integer 5.

Ans floor()
OR
math.floor()

(1 Mark for writing the correct method name)

9 In context of Communication Networks which of the following is correct expansion for 1


the abbreviation PAN :
(A) Prime Area Network
(B) Post Application Network
(C) Picture Application Network
(D) Personal Area Network

Ans (D) Personal Area Network

(1 Mark for writing the correct option)

10 In context of Cyber Crimes and Cyber Thefts the term IPR refers to : 1
(A) Internet Protocol Rights
(B) Inter Personnel Rights
(C) Intellectual Property Rights
(D) Individual Property Rights

Ans (C) Intellectual Property Rights

(1 Mark for writing the correct option)

11 In SQL, write the name of the aggregate function which will display the cardinality of 1
a table.

Ans count(*)
OR
count

(1 Mark for writing the correct function name)

12 Which of the following clauses in SQL is most appropriate to use to select matching 1
tuples in a specific range of values ?
(A) IN
(B) LIKE
(C) BETWEEN
(D) IS

Ans (C) BETWEEN

(1 Mark for writing the correct option)

[Sub Code: 083 Series: 3HKP3ɓ/C Paper Code:91] [Page #4/23]


13 Which of the following is not a valid datatype in SQL ? 1
(A) DATE
(B) STRING
(C) DECIMAL
(D) CHAR

Ans (B) STRING

(1 Mark for writing the correct option)

14 Which of the following is not a valid DML command in SQL ? 1


(A) INSERT
(B) UPDATE
(C) ALTER
(D) DELETE

Ans (C) ALTER

(1 Mark for writing the correct option)

15 Which of the following wireless transmission medium is best suited for MAN ? 1
(A) Microwave
(B) Radio Link
(C) Infrared
(D) Bluetooth

Ans (A) Microwave


OR
(B) Radio Link

(1 Mark for writing any one or both of the options)

16 Which of the following is/are immutable object types in Python ? 1


(A) List
(B) String
(C) Tuple
(D) Dictionary

Ans (B) String


(C) Tuple

(½ Mark for writing each correct option)

17 What shall be the output for the execution of the following Python Code ? 1
Cities = ['Delhi', 'Mumbai']
Cities[0], Cities[1] = Cities[1], Cities[0]
print(Cities)

Ans ['Mumbai', 'Delhi']

(1 Mark for writing the correct output)

[Sub Code: 083 Series: 3HKP3ɓ/C Paper Code:91] [Page #5/23]


18 Which of the following commands in SQL is used to add a new record into a table ? 1
(A) ADD
(B) INSERT
(C) UPDATE
(D) NEW

Ans (B) INSERT

(1 Mark for writing the correct option)

19 Which of the following is the correct expansion of DML in context of SQL ? 1


(A) Direct Machine Language
(B) Data Mixing Language
(C) Distributed Machine Language
(D) Data Manipulation Language

Ans (D) Data Manipulation Language

(1 Mark for writing the correct option)

20 Which of the following statements correctly explains the term Firewall in context of 1
Computer Network Society ?
(A) A device that protects the computer network from catching fire.
(B) A device/software that controls incoming and outgoing network traffic.
(C) Using abusive language on a social network site.
(D) Stealing someone’s text and submitting it as his/her own work.

Ans (B) A device/software that controls incoming and outgoing network traffic.

(1 Mark for writing the correct option)

21 Which of the following protocols allows use of HTML on the World Wide Web 1
(A) HTTP
(B) PPP
(C) FTP
(D) POP

Ans (A) HTTP

(1 Mark for writing the correct option)

[Sub Code: 083 Series: 3HKP3ɓ/C Paper Code:91] [Page #6/23]


Section II
Both the Case study based questions are compulsory. Attempt any 4 sub parts from each question.
Each question carries 1 mark

22 Anmol maintains that database of Medicines for his pharmacy using SQL to store the
data. The structure of the table PHARMA for the purpose is as follows:
● Name of the table - PHARMA
● The attributes of PHARMA are as follows:
MID - numeric
MNAME – character of size 20
PRICE - numeric
UNITS – numeric
EXPIRY - date

Table: PHARMA
MID MNAME PRICE UNITS EXPIRY
M1 PARACETAMOL 12 120 2022-12-25
M2 CETRIZINE 6 125 2022-10-12
M3 METFORMIN 14 150 2022-05-23
M4 VITAMIN B-6 12 120 2022-07-01
M5 VITAMIN D3 25 150 2022-06-30
M6 TELMISARTAN 22 115 2022-02-25

(a) Write the degree and cardinality of the table PHARMA. 1

Ans Degree = 5
Cardinality = 6

(½ Mark for writing correct value of Degree)


(½ Mark for writing correct value of Cardinality)

(b) Identify the attribute best suitable to be declared as a primary key. 1

Ans MID
OR
MNAME

(1 Mark for identifying correct Attribute Name as Primary Key)

(c) Anmol has received a new medicine to be added into his stock, but for which he does 1
not know the number of UNITS. So he decides to add the medicine without its value
for UNIT. The rest of the values are as follows:
MID MNAME PRICE EXPIRY
M7 SUCRALFATE 17 2022-03-20

Write the SQL command which Anmol should execute to perform the required task.

[Sub Code: 083 Series: 3HKP3ɓ/C Paper Code:91] [Page #7/23]


Ans INSERT INTO PHARMA (MID, MNAME, PRICE, EXPIRY)
VALUES ('M7', 'SUCRALFATE', 17,'2022-03-20');

(½ Mark for writing INSERT INTO PHARMA(MID, MNAME, PRICE, EXPIRY))


(½ Mark for writing VALUES('M7','SUCRALFATE',17,'2022-03-20'))

(d) Anmol wants to change the name of the attribute UNITS to QUANTITY in the table 1
PHARMA. Which of the following commands will he use for the purpose:
(i) UPDATE
(ii) DROP TABLE
(iii) CREATE TABLE
(iv) ALTER TABLE

Ans (iv) ALTER TABLE

(1 Mark for writing the correct option)

(e) Now Anmol wants to increase the PRICE of all medicines by 5. Which of the following 1
commands will he use for the purpose:
(i) UPDATE SET
(ii) INCREASE BY
(iii) ALTER TABLE
(iv) INSERT INTO

Ans (i) UPDATE SET

(1 Mark for writing the correct option)

23 Roshni of class 12 is writing a program in Python for her project work to create a csv
file "Teachers.csv" which will contain information for every teacher’s Identification
Number, Name for some entries. She has written the following code. However she is
unable to figure out the correct statements in a few lines of the code, hence she has
left them blank. Help her to write the statements correctly for the missing parts in
the code.

import _________ # Line 1


def addrec(Idno, Name): # to add record into the CSV file
f=open("Teachers.csv", _________) # Line 2
Filewriter = CSV.writer(f)
Filewriter.writerow([Idno,name])
f.close()
def readfile(): # to read the data from CSV file
f=open("Teachers.csv", ________) # Line 3
FileReader = CSV.________ (f) # Line 4
for row in FileReader:
print(row)
f._________ #Line 5

(a) Name the module she will import in Line 1. 1

[Sub Code: 083 Series: 3HKP3ɓ/C Paper Code:91] [Page #8/23]


Ans csv as CSV
OR
csv

(1 Mark for writing the correct module name)

(b) In which mode will she open the file to add data into the file in Line 2 ? 1

Ans a
OR
a+
OR
append

(1 Mark for writing the correct file mode)

(c) In which mode will she open the file to read the data from the file in Line 3 ? 1

Ans r
OR
r+
OR
read

(1 Mark for writing the correct file mode)

(d) File in the blank in Line 4 to read the data from a CSV file. 1

Ans reader
OR
Cannot interpret question

(1 Mark for writing the correct missing portion)


OR
(1 Mark if mentioned that the question could not be interpreted)

(e) Fill in the blank in Line 5 to close the file. 1

Ans close()

(1 Mark for writing the correct missing portion)

PART – B
Section I

24 Evaluate the following Python expressions: 2

(a) 2 * 3 + 4 ** 2 - 5 // 2

Ans 20

(1 Mark for writing the correct answer)

[Sub Code: 083 Series: 3HKP3ɓ/C Paper Code:91] [Page #9/23]


(b) 6<12 and not (20 > 15) or (10 > 5)

True

(1 Mark for writing the correct answer)

25 What are cookies in a web browser? Write one advantage and one disadvantage of 2
enabling cookies in a web browser.

Ans A cookie is a small piece of information that a server sends to a client. When we visit
a Web site with cookie capabilities, its server sends certain information about the
visited website to our browser, which is stored on our hard drive as a text file and is
called a cookie.
Advantage: When we visit the same website again, the browser recognises it and
makes browsing faster.
Disadvantage: The file stored as a cookie can be exploited by hackers in retrieving our
browsing habits and exploit it for their unlawful practices.

(1 Mark for writing the correct explanation of cookie)


(½ Mark for writing any one valid/correct advantage)
(½ Mark for writing any one valid/correct disadvantage)

OR
Differentiate between the terms Domain Name and URL in context of web services.
Also write one example of each to illustrate the difference.

Ans
Domain Name URL (Uniform Resource Locator)

Domain name is a textual form of an IP URL is the complete web address


address, which is easy to remember required to find a particular web page or
any page within the website.
It is the unique name that identifies an
Internet site. Domain name is a part of URL.

Domain Names always have 2 or more For example, in the URL


parts, separated by dots (or periods). “http://www.w3schools.com/html/defa
ult.asp”,
Example: the domain name is “w3schools.com”
w3schools.com,
microsoft.co.in

(1 Mark for writing any one valid difference between Domain Name & URL)
(½ Mark for writing the correct example of Domain Name)
(½ Mark for writing the correct example of a URL)

26 Expand the following terms in context of Computer Networks: 2


(a) PPP
(b) VoIP
(c) GSM
(d) WLL

[Sub Code: 083 Series: 3HKP3ɓ/C Paper Code:91] [Page #10/23]


Ans (a) PPP - Point-to-Point Protocol
(b) VoIP - Voice over Internet Protocol
(c) GSM - Global System for Mobile Communication
(d) WLL - Wireless Local Loop

(½ Mark for writing each correct expansion)

27 Explain the use of positional parameters in a Python function with the help of a 2
suitable example.

Ans In such parameters the values in the parameters of the function call are assigned in
the same sequence of the corresponding identifier(s) used in the parameter(s)/
argument(s) of the respective function’s definition (i.e. from left to right).
Example:

def LEqn(x,y,a):
return x+a*y
X1=int(input("X1:"))
Y1=int(input("Y1:"))
A1=int(input("A1:"))
print(LEqn(X1,A1,Y1))

In the above example:


value of X1 is passed to x, value of A1 is passed to y, value of
Y1 is passed to a due to their corresponding positions.

(2 mark for briefly explaining the concept of positional parameter with the help
of a suitable example)
OR
(1 mark if only the definition of positional parameter is written without any
suitable example)

OR
Explain the use of a default parameter in a Python function with the help of a
suitable example.

Ans Default parameter takes the default values when no argument/value is passed during
the function call.

Consider the following function definition and two function calls:

def FUN(A,B=2):
print('A=',A,'B=',B)

FUN(3,5) # Output will be: A=3 B=5


FUN(3) # Output will be: A=3 B=2

In the second call, when no value was passed for B, B takes its default value.

(2 mark for briefly explaining the concept of default parameter with the help of
a suitable example)
OR
(1 mark if only the definition of default parameter is written without any
suitable example)

[Sub Code: 083 Series: 3HKP3ɓ/C Paper Code:91] [Page #11/23]


28 Rewrite the following code in Python after removing all syntax error(s). 2
Underline each correction done in the code.

Runs = ( 10, 5, 0, 2, 4, 3 )
for I in Runs:
if I=0:
print (Maiden Over)
else
print(Not Maiden)

Ans Corrected Code:

Runs = (10, 5, 0, 2, 4, 3)
for I in Runs:
if I==0: # Correction 1
print('Maiden Over') # Correction 2
else : # Correction 3, 4
print('Not Maiden') # Correction 5
(½ mark each for any 4 correction)
(Deduct only ½ mark if the corrections are not underlined)

29 What possible outputs(s) are expected to be displayed on screen at the time of 2


execution of the program from the following code ? Also specify the maximum and
minimum value that can be assigned to the variable R when K is assigned value as 2.

import random

Signal = [ 'Stop', 'Wait', 'Go' ]


for K in range(2, 0, -1):
R = randrange(K)
print (Signal[R], end = ' # ')

(a) Stop # Wait # Go #


(b) Wait # Stop #
(c) Go # Wait #
(d) Go # Stop #

Ans (b) Wait # Stop #

Maximum value of R = 1
Minimum value of R = 0
OR
randrange() raises NameError

(1 Mark for writing the correct option)


(½ Mark for writing the correct Maximum value of R)
(½ Mark for writing the correct Minimum value of R)
OR
(Full 2 Marks for mentioning Error)

[Sub Code: 083 Series: 3HKP3ɓ/C Paper Code:91] [Page #12/23]


30 What are Tuples in a SQL Table? Write a suitable example with a SQL Table to illustrate 2
your answer.

Ans A tuple in a SQL table is a row of related data which represents or describes an item
(or record). It is a horizontal subset of the Table.
TNO NAME START END
T1 RAVI KUMAR DELHI MUMBAI
T2 NISHANT JAIN DELHI KOLKATA
T3 DEEPAK PRAKASH MUMBAI PUNE

In the above table, we have 3 Tuples:


T1, RAVI KUMAR, DELHI, MUMBAI
T2, NISHANT JAIN, DELHI, KOLKATA
T3, DEEPAK PRAKASH, MUMBAI, PUNE

(1 Mark for writing the correct explanation for Tuple)


(1 Mark for writing the correct example of Tuple)

31 For the following SQL Table named PASSENGERS in a database TRAVEL: 2


TNO NAME START END
T1 RAVI KUMAR DELHI MUMBAI
T2 NISHANT JAIN DELHI KOLKATA
T3 DEEPAK PRAKASH MUMBAI PUNE

A cursor named Cur is created in Python for a connection of a host which contains
the database TRAVEL. Write the output for the execution of the following Python
statements for the above SQL Table PASSENGERS:

Cur.execute('USE TRAVEL')
Cur.execute('SELECT * FROM PASSENGERS')
Recs=Cur.fetchall()
for R in Recs:
print(R[1])

Ans RAVI KUMAR


NISHANT JAIN
DEEPAK PRAKASH

(½ mark for each line of correct output)


(½ mark for displaying the 3 lines of output in different lines)

32 Write the names of any two constraints and their respective uses in SQL. 2

Ans (Any 2 from the following OR any other correct constraint name with usage)
PRIMARY KEY - Uniquely identifies each row/record in a database table.
UNIQUE - Ensures that all values in a column are different.
NOT NULL - Ensures that a column cannot have NULL value.
DEFAULT - Provides a default value for a column when none is specified.
CHECK - ensures that all the values in a column satisfies certain conditions.

[Sub Code: 083 Series: 3HKP3ɓ/C Paper Code:91] [Page #13/23]


(½ Mark for writing each of the two correct constraint names)
(½ Mark each for writing correct usage of the two constraints)

33 Write the output for the execution of the following Python code: 2

def change(A):
S=0
for i in range(len(A)//2):
S+=(A[i]*2)
return S
B = [10,11,12,30,32,34,35,38,40,2]
C = Change(B)
Print('Output is',C)

Ans Output is 190


OR
NameError for Change()
NameError for Print()

(2 Mark for writing the correct output)


OR
(2 Mark for mentioning Error)

Section II

34 Write the definition of a function Sum3(L) in Python, which accepts a list L of 3


integers and displays the sum of all such integers from the list L which end with the
digit 3.
For example, if the list L is passed
[ 123, 10, 13, 15, 23]
Then the function should display the sum of 123, 13, 23 i.e. 159 as follows:
Sum of integers ending with digit 3 = 159

Ans def Sum3(L):


Sum = 0
for I in L:
if I%10 == 3:
Sum += I
print('Sum of integers ending with digit 3 =', Sum)

(½ mark for the function header)


(½ mark for initialising the variable Sum (or similar))
(½ mark for the traversal loop)
(½ mark for checking the unit digit 3)
(½ mark for adding the correct number)
(½ mark for displaying the output)

[Sub Code: 083 Series: 3HKP3ɓ/C Paper Code:91] [Page #14/23]


35 Write the definition of a function ChangeGender() in Python , which reads the 3
contents of a text file “BIOPIC.TXT” and displays the content of the file with every
occurrence of the word ‘he’ replaced by ‘she’. For example, if the content of the file
“BIOPIC.TXT” is as follows:
Last time he went to Agra,
there was too much crowd, which he did not like.
So this time he decided to visit some hill station.

The function should read the file content and display the output as follows:
Last time she went to Agra,
there was too much crowd, which she did not like.
So this time she decided to visit some hill station.

Ans def ChangeGender():


f=open("BIOPIC.TXT",'r')
Text=f.read()
print(Text.replace(' he ',' she '))
f.close()

OR

def ChangeGender():
with open ('BIOPIC.TXT', 'r') as File:
Lines = File.readlines()
for L in Lines:
Words = L.split()
for W in Words:
if W == 'he' :
W = 'she'
print(W, end = ' ')
print()

(1 Mark for correctly opening the text file)


(1 Mark for correctly reading the file - Any method)
(½ Mark for correctly search and replace the word ‘he’ with ‘she’)
(½ Mark for correctly displaying the modified contents with the replacements)
OR
Write the definition of a function Count_Line() in Python, which should read each
line of a text file "SHIVAJI.TXT" and count total number of lines present in text
file. For example, if the content of the file "SHIVAJI.TXT" is as follows :

Shivaji was born in the family of Bhonsle.


He was devoted to his mother Jijabai.
India at that time was under Muslim rule.

The function should read the file content and display the output as follows :
Total number of lines : 3

[Sub Code: 083 Series: 3HKP3ɓ/C Paper Code:91] [Page #15/23]


Ans def Count_Line():
with open ('SHIVAJI.TXT', 'r') as File:
Lines = File.readlines()
print('Total number of lines :', len(Lines))
OR
def Count_Line():
f=open("SHIVAJI.TXT",'r')
Lines=f.readlines()
print('Total number of lines :',len(Lines))
f.close()

(1 Mark for correctly opening the text file)


(1 Mark for reading all lines from the file - Any method)
(1 Mark for correctly displaying the total number of lines)

36 Write the outputs of the SQL queries (i) to (iii) based on the relations CUSTOMER and 3
TRANSACTION given below:

Table : CUSTOMER
ACNO NAME GENDER BALANCE
C1 RISHABH M 15000
C2 AAKASH M 12500
C3 INDIRA F 9750
C4 TUSHAR M 14600
C5 ANKITA F 22000

Table : TRANSACTION
ACNO TDATE AMOUNT TYPE
C1 2020-07-21 1000 DEBIT
C5 2019-12-31 1500 CREDIT
C3 2020-01-01 2000 CREDIT

(i) SELECT MAX(BALANCE), MIN(BALANCE)FROM CUSTOMER


WHERE GENDER = 'M';

Ans MAX(BALANCE) MIN(BALANCE)


15000 12500

(½ Mark for writing each correct value - with or without column heading)

(ii) SELECT SUM(AMOUNT), TYPE FROM TRANSACTION


GROUP BY TYPE;

Ans SUM(AMOUNT) TYPE


3500 CREDIT
1000 DEBIT

[Sub Code: 083 Series: 3HKP3ɓ/C Paper Code:91] [Page #16/23]


(½ Mark for writing each correct line of output - with or without column heading)

(iii) SELECT NAME, TDATE, AMOUNT


FROM CUSTOMER C, TRANSACTION T
WHERE C.ACNO = T.ACNO AND TYPE = 'CREDIT';

Ans NAME TDATE AMOUNT


ANKITA 2019-12-31 1500
INDIRA 2020-01-01 2000

(½ Mark for writing each correct line of output - with or without column heading)

37 (a) Write the definition of a function POP_PUSH(LPop, LPush, N) in Python. The 3


function should Pop out the last N elements of the list LPop and Push them into the
list LPush. For example:
If the contents of the list LPop are [10, 15, 20, 30]
And value of N passed is 2,
then the function should create the list LPush as [30, 20]
And the list LPop should now contain [10, 15]
NOTE: If the value of N is more than the number of elements present in LPop, then
display the message “Pop not possible”.

Ans def POP_PUSH(LPop, LPush, N):


if len(LPop)<N:
print("Pop not possible")
else:
LPush.clear() # ignore
for i in range(N):
LPush.append(LPop.pop())

OR
def POP_PUSH(LPop, LPush, N) :
M = len(LPop)
if M < N :
print('Pop not possible')
else :
for I in range(N) :
P = LPop.pop(M-1-I)
LPush.append(P)

(½ mark for checking underflow and printing “Pop not possible” in case of
underflow)
(½ mark for the loop)
(1 mark for popping elements from LPop)
(1 mark for appending popped elements into LPush)

OR

[Sub Code: 083 Series: 3HKP3ɓ/C Paper Code:91] [Page #17/23]


(b) Write a function in Python POPSTACK(L) where L is a stack implemented by a 3
list of numbers. The function returns the value deleted from the stack.

Ans def POPSTACK(L):


if len(L)>0:
return L.pop()
else:
return None

OR

def POPSTACK(L):
return L.pop()

(1 Mark for writing the correct function header)


(1 Mark for popping out the last element from the list (Any method))
(1 Mark for returning the popped element)

Section - III

38 A school library is connecting computers in its units in a LAN. The library has 3 units as 5
shown in the diagram below:

The three units are providing the following services:


1. Teachers Unit : For access of the Library Books by teachers
2. Students Unit : For access of the Library Books by Students
3. Circulation Unit : For issue and return of books for teachers and students

Center to Center distances between the 3 units are as follows:


● Circulation Unit to Teachers Unit - 20 metres
● Circulation Unit to Students Unit - 30 metres
● Teachers Unit to Students Unit - 10 metres

Number of computers in each of the units is as follows:


● Circulation Unit 15
● Teachers Unit 10
● Students Unit 10

(a) Suggest the most suitable place (i.e. the Unit name) to install the server of this
Library with a suitable reason.

[Sub Code: 083 Series: 3HKP3ɓ/C Paper Code:91] [Page #18/23]


Ans Circulation Unit
Reason: It has maximum number of computers OR any other valid reason.

(½ Mark for writing the correct Unit Name)


(½ Mark for writing the correct reason)

(b) Suggest an ideal layout for connecting these Units for a wired connectivity.

Ans

OR

Suggesting any other valid cable layout

(1 Mark for suggesting the correct connectivity layout)

(c) Which device will you suggest to be installed and where should it be placed to provide
Internet connectivity to all the Units.

Ans Modem OR Router


Placement : Circulation Unit with the server

(½ Mark for writing the correct device name)


(½ Mark for writing the correct placement)

(d) Suggest the type of the most efficient and economical wired medium for connecting
all the computers in the network.

Ans CAT-6 Cable OR CAT-5 Cable OR Ethernet Cable

(1 Mark for suggesting any one efficient and economical wired medium)

(e) The university is planning to connect the Library with the School Principal’s computer
which is in his office at a distance of 50 metres. Which type of network out of LAN,
MAN, or WAN will be used for the network? Justify your answer.

Ans LAN
Justification: The office is located at a distance of merely 50 metres from the
Library, which is within the geographical limits of a local area network.

(½ Mark for writing the correct network type)


(½ Mark for writing the correct Justification)

[Sub Code: 083 Series: 3HKP3ɓ/C Paper Code:91] [Page #19/23]


39 Write SQL statements for the following queries (i) to (v) based on the relations 5
CUSTOMER and TRANSACTION given below:

Table : CUSTOMER
ACNO NAME GENDER BALANCE
C1 RISHABH M 15000
C2 AAKASH M 12500
C3 INDIRA F 9750
C4 TUSHAR M 14600
C5 ANKITA F 22000

Table : TRANSACTION
ACNO TDATE AMOUNT TYPE
C1 2020-07-21 1000 DEBIT
C5 2019-12-31 1500 CREDIT
C3 2020-01-01 2000 CREDIT

(a) To display all information about the CUSTOMERs whose NAME starts with ‘A’.
Ans SELECT * FROM CUSTOMER WHERE NAME LIKE 'A%';
(½ Mark for writing correct SELECT statement)
(½ Mark for writing correct WHERE clause)
(b) To display the NAME and BALANCE of Female CUSTOMERs (with GENDER as 'F') whose
TRANSACTION Date (TDATE) is in the year 2019.
Ans SELECT NAME, BALANCE FROM CUSTOMER C, TRANSACTION T
WHERE C.ACNO=T.ACNO
AND GENDER=’F’ AND TDATE LIKE '2019%';

OR

SELECT NAME, BALANCE FROM CUSTOMER C, TRANSACTION T


WHERE C.ACNO=T.ACNO
AND GENDER=’F’ AND TDATE>='2019-01-01' AND TDATE<='2019-12-31';

OR

SELECT NAME, BALANCE FROM CUSTOMER, TRANSACTION


WHERE CUSTOMER.ACNO=TRANSACTION.ACNO
AND GENDER=’F’ AND TDATE LIKE '2019%';

OR

SELECT NAME, BALANCE FROM CUSTOMER, TRANSACTION


WHERE CUSTOMER.ACNO=TRANSACTION.ACNO
AND GENDER=’F’ AND TDATE>='2019-01-01' AND TDATE<='2019-12-31';

[Sub Code: 083 Series: 3HKP3ɓ/C Paper Code:91] [Page #20/23]


(½ Mark for writing correct SELECT statement)
(½ Mark for writing correct WHERE clause)
(c) To display the total number of CUSTOMERs for each GENDER.
Ans SELECT GENDER, COUNT(*) FROM CUSTOMER GROUP BY GENDER;
(½ Mark for writing correct SELECT statement)
(½ Mark for writing correct GROUP BY clause)
(d) To display the CUSTOMER NAME and BALANCE in ascending order of GENDER.
Ans SELECT NAME, BALANCE FROM CUSTOMER
ORDER BY GENDER ;

OR

SELECT NAME, BALANCE FROM CUSTOMER


ORDER BY GENDER ASC;

(½ Mark for writing correct SELECT statement)


(½ Mark for writing correct ORDER BY clause)
(e) To display CUSTOMER NAME and their respective INTEREST for all CUSTOMERs where
INTEREST is calculated as 8% of BALANCE.
Ans SELECT NAME, 0.08 * BALANCE INTEREST FROM CUSTOMER;

OR

SELECT NAME, 0.08 * BALANCE AS INTEREST FROM CUSTOMER;


(½ Mark for writing correct SELECT statement)
(½ Mark for writing correct WHERE clause)
NOTE:
"INTEREST" may be written within quotes (single or double).
40 A binary file “PLANTS.dat” has structure (ID, NAME, PRICE). 5
● Write the definition of a function WRITEREC() in Python, to input data for records
from the user and write them to the file PLANTS.dat.
● Write the definition of a function SHOWHIGH() in Python, which reads the records
of PLANTS.dat and displays those records for which the PRICE is more than 500.

Ans import pickle


def WRITEREC():
f = open("PLANTS.dat","wb") # OR "ab"
data_log = []
while True:
ID = int(input("Enter ID:"))
NAME = input("Enter Name:")
PRICE = float(input("Enter Price:"))
data_log.append([ID,NAME,PRICE])
Choice=input("Do you want to add more? (Yes/No) : ")
if Choice[0].lower()=='n':
break
pickle.dump(data_log,f)
f.close()

[Sub Code: 083 Series: 3HKP3ɓ/C Paper Code:91] [Page #21/23]


def SHOWHIGH():
f = open("PLANTS.dat","rb")
try:
while True:
data= pickle.load(f)
for record in data:
if record[2]>500:
print("ID:",record[0])
print("Name:",record[1])
print("Price:",record[2])
print()
except:
f.close()

OR

import pickle
def WRITEREC() :
with open ('PLANTS.DAT', 'wb') as FW :
while True :
ID = input('Enter ID : ')
NAME = input('Enter NAME : ')
PRICE = input('Enter PRICE : ')
pickle.dump([ID, NAME, PRICE])
More = input('More records (Y/N) ? ')
if More in ['n', 'N'] :
break

def SHOWHIGH() :
with open ('PLANTS.DAT', 'rb') as FR :
CR = pickle.load(FR)
for R in CR:
if int(R[2]) > 500 :
print(R)

(½ Mark for correctly opening the PLANTS.dat file to write/append)


(½ Mark for correctly inputting data from the user)
(1 Mark for correctly writing the input data as a record into the file)
(½ Mark for writing correct loop to add more records till user wants )

(½ Mark for correctly opening the PLANTS.dat file to read)


(1 Mark for correctly loading the the file)
(½ Mark for correctly checking each record price > 500)
(½ Mark for displaying the validated record)

[Sub Code: 083 Series: 3HKP3ɓ/C Paper Code:91] [Page #22/23]


OR
A binary file “PATIENTS.dat” has structure (PID, NAME, DISEASE).
Write the definition of a function countrec() in Python that would read contents of
the file “PATIENTS.dat” and display the details of those patients who have the
DISEASE as ‘COVID-19’. The function should also display the total number of such
patients whose DISEASE is ‘COVID-19’.
Ans import pickle
def countrec():
with open ('PATIENTS.DAT', 'rb') as FR :
CR = pickle.load(FR)
N=0
for R in CR:
if (R[2]) == 'COVID-19' :
print(R)
N += 1
print('Total number of Covid-19 Patients = ', N)
OR
import pickle
def countrec():
f = open("PATIENTS.dat","rb")
N=0
try:
while True:
data= pickle.load(f)
for record in data:
if record[2]=='COVID-19':
print("PID:",record[0])
print("NAME:",record[1])
print("DISEASE:",record[2])
N += 1
except:
f.close()
print('Total number of Covid-19 Patients = ', N)
(½ mark for opening the file in correct mode )
(½ mark for initialising the Counter Identifier )
(1 mark for reading the binary file )
(1 mark for the traversal loop )
(½ mark for checking the COVID-19 condition )
(½ mark for displaying the matched records )
(½ mark for incrementing the Counter Identifier )
(½ mark for displaying the final value of the Counter Identifier )

[Sub Code: 083 Series: 3HKP3ɓ/C Paper Code:91] [Page #23/23]

You might also like