0 ratings0% found this document useful (0 votes) 494 views20 pagesComputer Science Sample Paper 2 - 122318
Computer Science Sample Paper 2
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content,
claim it here.
Available Formats
Download as PDF or read online on Scribd
CBSE Additional Practice Question Paper
Class: XIl Session: 2023-24
Computer Science (083)
Time allowed: 3 Hours Maximum Marks: 70
General Instructions:
Please check this question paper contains 35 questions.
‘The paper is divided into 5 Sections- A, B, C, D and E.
Section A, consists of 18 questions (1 to 18). Each question carries 1 Mark.
‘Section B, consists of 7 questions (19 to 25). Each question carries 2 Marks.
Section C, consists of 5 questions (26 to 30). Each question caries 3 Marks.
Section D, consists of 2 questions (31 to 32). Each question carties 4 Marks.
Section E, consists of 3 questions (33 to 35). Each question carries 5 Marks.
All programming questions are to be answered using Python Language only.
QNo. Questions Marks
Section-A (18 Marks)
i ‘Which of the following is an invalid identifier to be used in Python? 1
a, per%omarks
b._for
‘What is the correct way to add an element to the end of a list in] 1
Python?
a, listadd(element)
’b. list append(element)
¢. list.insert(element)
a. list.extend(element)
‘What will be the output of 1
print("Welcome To My Blog"[2:6] + "Welcome To My
Blog"[5:9])
a, Lcomme
b. Icomme T
cc. leomme To
d, comme
Which of the following statements is false? 1
a, A try-except block can have more than one except statement
1b. One block of except statement cannot handle multiple exceptions
¢. The finally block is always executed
4, When 1 == "I" is executed, no exception is raised
Which of the following statement(s) would give an error during the| 1
execution of the following code?
R = (‘pno':52,/pname’: Vira’, ‘expert’{/Badminton’, Tennis' sco
print(R) Statement 1
7,44))Rfexpert’][0]="Cricket’ ‘#Statement 2
Rfscore’][0}=50 +#Statement 3
Ripno'}=50 #Statement 4
a, Statement 1
+b. Statement 2
c. Statement 3
d. Statement 4
Which pickle module method is used to write a Python object to a
binary file?
a. save()
b, serialize()
c. store()
d. dump)
Given the following dictionaries
dict_student = {"rno" : "53", "name"
dict_marks = {"Accts" : 87, “English
"Rajveer Singh’}
: 65}
Which statement will append the contents of dict_marks in
dict_student?
a. dict_student + dict_marks
b. dict_student.add(dict_marks)
¢. dict_student.merge(dict_marks)
d. dict_student.update(dict_marks)
Which of the following is not a component of the math module in
Python?
a.ceil()
b. mean()
. fabs()
4. pi
What will be the output of the following code?
L=["One , Two", "Three", "Four"]
print(len(L)/2*1en(L[@]))
a.6.5
b. 13
e135
d.6.0
10
Expand the following terms:
@ PPP
Gi) VoIP
ll
Which SQL operator performs pattern matching?
a. BETWEEN operator
b. LIKE operator
¢. EXISTS operator
a=12
‘Which Python function is used for displaying only one result set from
SQL tabie in a database?
a. fetchl()
b, fetchno()
¢. fetchall()
d. fetchone()
13
Which of the following file opening mode in Python, generates an
error if the file does not exist?
aa
ber
cw
dwt
14
The correct syntax of seek() is:
a, file_object.seek(offset [, reference_point])
b. seek(offset [, reference_point])
c. seek(offset, file_object)
d, seck.file_object(offset)
15
Which of the following statements is false?
a, SMTP and POP protocols are used in email communication,
b. URL of a page is not always the same as its domain name,
cc. HTTPS is safer than HTTP.
4. Interlinking of collection of webpages is called Internet.
16
Fill in the blank:
protocol provides access to services hosted on a remote
computer.
a. FIP
b. PPP
c. Telnet
d. SMTP.
QI7 and 18 are ASSERTION AND REASONING based questions.
Mark the correct choice as
(a) Both A and R are true and the correct explanation for A
(b) Both A and R are true and R is not the correct explanation for A
(c) Ais Truc but R is False
(@) A is false but R is True
17
Assertion (A): For changes made to a variable defined within a
function to be visible outside the function, it should be declared as
global.
Reasoning (R): Variables defined within a function are local to that
function by default, unless explicitly specified with the global
keyword,
18
m (A): A binary file in python is used to store collection
and dictionaries that can be later retrieved in their
original form using pickle module.Reasoning (A): Binary files are just like normal text files and can be
read using a text editor like Notepad,
QNo.
Questions
Sectlon-B (14 Marks)
Marks
19
Write two advantages and two disadvantages of circuit switching
OR
Differentiate between Web server and web browser. Write the names
of any two web browsers.
20
Rewrite the following code in Python after removing all the syntax
errors. Underline each correction done in the code.
num, num2 = 10, 45
While numa % num2 == @
nunt+= 20
nuna+= 30
Else:
print(‘hello')
2
‘Write a function di spBook(BOOKS) in Python, that takes a dictionary
BOOKS as an argument and displays the names in uppercase of those
books whose name starts with a consonant,
For example, Consider the following dictionary
BOOKS = {1: "Python", 2:"Internet Fundamentals “, 3:"Networking ",
4:"Oracle sets", 5: "Understanding HTML"}
‘The output should be:
PYTHON
NETWORKING
OR
Write a Python Program containing a function FindWord(STRING,
SEARCH), that accepts two arguments : STRING and SEARCH, and
prints the count of occurrence of SEARCH in STRING. Write
appropriate statements to call the function,
For example, if STRING = “Learning history helps to know about
history with interest in history" and SEARCH = ‘history’, the function
should display
The word history occurs 3 times.
22
‘What will be the output of the following code?
L = [5,10,15,1]
Gea
def Change(X):
global G
Nzlen(X)
for i in range(N):
Xi] += 6
Change(L)
for i in L:
print(i,end="$")Write a suitable Python statement for each of the following tasks
using built-in functions/methods only:
i To delete an element Mumbai:50 from Dictionary D.
ii To display words in a string S in the form of a list
OR
Write a Python Program to display alternate characters of a string
my_str.
For example, if my_str = "Computer Science"
The output should be Cmue cec
Differentiate between % (percentage) and _(underscore) characters
used with the LIKE operator in SQL with appropriate examples.
OR
Differentiate between DROP and DELETE commands in SQL with
appropriate examples.
Consider the following two commands with reference to a table,
named Employee having a column named Department:
(a)Select count(Department) from Employee;
(b) Select count(*) from Employee;
If these two commands are producing different results,
() What may be the possible reason?
Gi) Which command (a) or (b) might be giving a higher value?
Questions
Section-C (15 Marks)
Marks
(a) Consider the table, BOOK and MEMBER given below:
TABLE : BOOK
CODE | BNAME TYPE
F101 | The priest Fiction
L102 | Easy Python Programming
C101 | Juman Ji Thriller
F102 __| Untold Story Fiction
102 War Stories Comic
Table: MEMBER
MNO | MNAME CODE [ISSUEDATE
Mi01__|SNEH SINHA |L102 | 2022-10-13
M103 |SARTHAK | F102 _| 2021-02-23
M102 |SARAKHAN |C101 | 2022-06-12
What will be the output of the following statement?
SELECT * FROM BOOK NATURAL JOIN MEMBER;
(b) Write the output of the queries (i) to (iv) based on the table
Table: Employee
EID [Name DOB DOJ Salary | Project
E01 | Ranjan | 1990-07-12 | 2015-01-21 | 150000 | P01
E02 [Akhtar | 1992-06-21 | 2015-02-01 | 125000 | Poa
E03 | Muneera | 1996-11-15 | 2018-08-19 | 135000 | PO1
£04 [Alex 1991-10-25 | 2018-10-19 | 75000 | PO2
E05 | Satyansh | 1993-12-16 | 2018-10-19 | 85000_| Poai SELECT NAME, PROJECT FROM EMPLOYEE ORDER BY NAME DESC;
ii SELECT NAME, SALARY FROM EMPLOYEE WHERE NAME LIKE 'A%";
iii SELECT NAME, DOJ FROM EMPLOYEE WHERE SALARY BETWEEN
100800 AND 200000;
iv SELECT + FROM EMPLOYEE WHERE PROJECT = 'PO1';
27
(a) _ Consider the following tables — FACULTY and COURSES :
Table: FACULTY
FID [FNAME |[LNAME | JOINDATE [SALARY
FO1|Anishma |Garq | 2000-12-14 | 32000
FO3[Bhumi [Goel | 2001-08-10 | 15000
FO4[Neha | Verma | 2000-05-17 [27000
F05[Meenu | Sharma | 2006-07-11_| 30000
Table: COURSES
C_ID | FID | CNAME FEES
Ci1_| F01 | Grid Computing 40000
C12_| F04 | Python 47000
C13 [F03 | C+ 8000
C14 | F04 | Computer Network | 15000
c15_[FO1 [HTML 42000
C16_| FOS | Data Science NULL
‘What will be the output of the following statement?
i SELECT FID, MIN(FEES), MAX(FEES) FROM COURSES GROUP BY
FID;
ii SELECT AVG(SALARY) FROM FACULTY WHERE FNAME LIKE "Xa";
iii SELECT FNAME, CNAME FROM FACULTY F, COURSES C WHERE
F.FID=C.FID AND COURSES.FID="FO4";
iv SELECT FNAME, CNAME , FEES FROM FACULTY F , COURSES C
WHERE F.FID = C.FID AND FEE>15000;
(b) _ Write the name of the command to display the structure of a
table in a database.
Write a function COUNT() in Python to read from a text file
‘Gratitude.txt' and display the count of the letter ‘e" in each
line
Example: If the file content is as follows:
Gratitude is a humble heart's radiant glow,
Atimeless gift that nurtures and bestows.
Its the appreciation for the love we're shown,
In moments big and small, it's truly known.
The COUNTO function should display the output as:
Line 1: 3
Line 2:4
Line 3: 6
Line 4:1
OR
Write a function Start_with_I() in Python, which should read a
text file 'Gratitude.txt' and then display lines starting with 'I*
Example: If the file content is as follows:
Gratitude is a humble heart's radiant glow,
Atimeless gift that nurtures and bestows.
I's the appreciation for the love we're shown,
In moments big and small it's truly known.
6Then the output should be
It's the appreciation for the love we're shown,
In moments big and small, it's truly known.
29
Navdeep creates a table RESULT with a set of records to maintain the
marks secured by students in Sem1, Sem2, Sem3, and their divisions.
After the creation of the table, he entered data of 7 students in the
table.
ADNO | ROLLNO | SNAME | SEM1 | SEM2_| DIVISION
123 [101 KARAN [366 [410 [I
245 | 402 NAMAN [300 |350__|1
428 | 403 ISHA [400/410 [1
129 [104 RENU [350 |357__|I
234 [405 ARPIT [100 | 75 WV
187__| 106 SABINA [100 [205 [Il
481407 NEELAM [470 [450 [I
Based on the data given above answer the following questions:
i Identify the columns which can be considered as candidate
keys?
ii If 2 more columns are added and 3 rows are deleted from the
table result, what will be the new degree and cardinality of the
above table?
iii Write a statement to increase the SEM2 marks by 3% for the
students securing marks between 70 to 100,
30
Given a Dictionary Stu_dict containing marks of students for three
test-series in the form Stu_ID:(7S1, 72, TS3) as key-value pairs.
‘Write a Python program with the following user-defined functions to
perform the specified operations on a stack named Stu_Stk
(i) Push_elements(Stu_Stk, Stu_dict) : It allows pushing
IDs of those students, from the dictionary Stu_dict into the stack
Stu_Stk, who have scored more than or equal to 80 marks in the TS3
Test.
Gi) Pop_elements(Stu_Stk): It removes all elements present
inside the stack in LIFO order and prints them. Also, the function
displays ‘Stack Empty’ when there are no elements in the stack.
Call both functions to execute queries.
For example:
If the dictionary Stu_dict contains the following data:
Stu_dict =(5:(87,68,89), 10:(57,54,61), 12:(71,67,98),
14: (66,81,80), 18:(80,48,91)}
After executing Push_elements(), Stk_ID should contain
[5,12,14,18]
After executing Pop_elements(), The output should be:
18
14
12
B
Stack EmptyQNo. Questions Marks
Section-D (8 Marks)
31 [Create a function maxsalary() in Python to read all the records) 4
from an already existing file record.csv which stores the records
of various employees working in a department. Data is stored under
various fields as shown below:
Ecode [E namo ‘Scale | Salary
‘AOA jesh Mehra__| S4 65400
B02 Vikram Goel | S3 60000
coo Suraj Mehta | S2 45300
Note: Assume that all employees have distinct salary.
32 |Consider a binary file "INVENTORY.DAT" that stores information] 4
about products using tuple with the structure (ProductID,
ProductName, Quantity, Price). Write a Python function
expensiveProducts() to read the contents of
“INVENTORY.DAT’ and display details of products with a price
higher than Rs. 1000. Additionally, calculate and display the total
count of such expensive products.
For example: If the file stores the following data in binary format
(1, ‘ABC’, 100, 5000)
(2, DEF, 250, 1000)
3, GHT, 300, 2000)
then the function should display
Product ID: 1
Product ID: 3
Total expensive products: 2
QNo. Questions Marks
Section-E (15 Marks)
33 |Fun Media Services Ltd is an event planning organization. It is 5
planning to set up its India campus in Mumbai with its head office in
Delhi. The Mumbai campus will have four blocks/buildings -
ADMIN, DECORATORS, FOOD, and MEDIA.
‘You as a network expert need to suggest the best network-related
solutions for them to resolve the issues/problems mentioned in points
() to (v), keeping in mind the distances between various
blocks/buildings and other given parameters.
‘MUMBAT
DELHIShortest distance between various buildings:
FROM ~ TO, DISTANCE.
‘ADMIN TO DECORATORS: ‘90 meters
‘ADMIN TO MEDIA 75 meters:
‘ADMIN TO FOOD ‘50 meters
DECORATORS TO FOOD. ‘65 meters
DECORATORS TO MEDIA 50 meters:
FOOD TO MEDIA ‘45 meters
DELHI Head Office to MUMBAI | 1475 KM
Campus.
The number of computers at various buildings is as follows:
iii.
iv.
BUILDING NUMBER OF COMPUTERS
‘ADMIN 110
DECORATORS _| 75
MEDIA 12
FOOD. 20
Suggest the most appropriate location of the server inside the
MUMBAI campus (out of the 4 buildings). Justify your answer.
Draw the cable layout to efficiently connect various buildings
within the MUMBAI campus.
Which hardware device will you suggest to connect all the
computers within each building?
Which of the following will you suggest to establish online
face-to-face communication between the people in the Admin
Office of the MUMBAI campus and the DELHI Head Office?
a, Cable TV
b. Email
c. Video Conferencing
d, Text Chat
What type of network (out of PAN, LAN, MAN, WAN) will
be set up in each of the following cases?
a. The Mumbai campus gets connected with the Head Quarter
in Delhi
b. The computers connected in the MUMBAI campus
Mention any two differences between seek() and tell(.
Consider a file FLIGHT . DAT containing multiple records. The
structure of each record is as shown below:
[Fno, FName, Fare, Source, Destination]
Write a function COPY_REC() in Python that copies all those
records from FLIGHT.DAT where the source is DELHT and the
destination is MUMBAT, into a new file RECORD.DAT
OR
Mention any two differences between binary files and csv files?
Consider a Binary file BOOK.DAT containing a dictionary
having multiple elements. Each element is in the form
BNO: [BNAME , BTYPE, PRICE] as key:value pair
where
BNO — Book Number
BNAME — Book Name
BTYPE - Book ‘Type
PRICE — Book price
243-5Write a user-defined function, FindBook(price), that accepts
price as parameter and displays all those records from the
binary file BOOK. DAT which has a book price more than or equal
to the price value passed as a parameter.
35
Define the term constraint with respect to RDBMS. Give a
suitable example.
ii. Sameera maintains a database named STORE which contains a
table named ITEM with the structure given below:
+ Ino(Item number )- integer
+ Iname(Item Name) - string
+ Price (Item Price) — float
+ Discount (Discount) — float
Note the following to establish connectivity between Python
and MySQL:
+ Username - root
+ Password - tiger
+ Host - localhost
Help her to remove the record from the table ITEM for a particular
value of item name input by the user.
import mysql.connector as mysql
conl= mysql.connect(host='localhost', user='root', password=
"_', database="STORE') #Statement-1
mycursor = Statement -2
iten_name = input("Enter the Item nane to remove the record :
query = #Statement -3
mycursor-execute (query)
cont.__ aStatement-4
print(‘Data Deleted successfully’)
cont.close()
With reference to the above code, answer the following questions
a) Complete statement 1 to establish the connection with the
database.
b) Write statement 2 to create the cursor object.
©) Complete statement 3 to remove the record from the table
ITEM based on the item name entered by the user
d) Complete statement 4 to save the changes in the table.
OR
i, Write one difference between the alternate key and the
candidate key.
ii, A table named ITEM is created in a database STORE. The table
contains multiple columns whose details are as shown below:
Ino(Item number )- integer
Iname(Item Name) — string
Price (Item Price) — float
Discount (Discount) — float
eeee
Note the following to establish connectivity between Python
and MySQL:
Username - root
Password - tiger
Host - localhost
However, the table is to be interfaced with Python to perform
certain tasks, The incomplete code is given below:
10Line 1
Tont= mysql.connect(host="localhost', user = ‘root', password =
‘tiger’, database="STORE)
nycursor = cont. Line 2
query = ‘SELECT > FROM ITEM where Price > {)'.format(__) #Line3
nycursor.execute(query)
data = mycursor.__ Line 4
for rec in data:
print (rec)
cond.close()
i. Complete line 1 to import the appropriate module.
Complete Line 2 to create the cursor object
Complete the query given in Line 3 to display details of all such
items from the table ITEMS whose price is more than 5000.
iv, Complete Line 4 to extract all the records.
ulCBSE Additional Practice Question Paper
Class: XII Session: 2023-24
Computer Science (083)
Marking Scheme
QNo. Answer Total
Marks
1 | a. persemarks 1
2 |b. list.append(element) 1
3 |b. comme T 1
4 _| b. One block of except statement cannot handle multiple exceptions 1
5__|¢. Statement 3 1
6 |d.dump 1
7 _| d. dict_student.update(dict_marks) 1
8 |b. meanQ) 1
9 |e13.5 1
10 | PPP— Point to Point Protocol 1
VoIP - Voice Over Internet Protocol
11 | b. LIKE operator 1
12 |. fetchone 1
13, |b 1
14 | a, file_object.seek(offset [, reference_point]) 1
15 _| d. Interlinking of collection of webpages is called Internet. 1
16 |e. TelNet 1
17. | a, Both A and R are true and Ris the correct explanation for A 1
18 | c, Ais True but R is False 1
19 | Advantages: 2
1) A dedicated communication channel increases the quality of
communication.
2) Suitable for long continuous communication.
Disadvantages:
1) Resources are not utilized fully.
2) The time required to establish the physical link between the two stations is
too long.
1 mark for each advantage and disadvantage
OR
Web browser
Purpose: Receives and displays web content.Function: Initiates requests to web servers, and receives and displays content
for users.
Web server
Purpose: Delivers web content to clients.
Function: Listens to incoming requests, processes them, and sends requested
content to the client.
Name of Web browsers: Google Chrome, Mozilla Firefox
I mark for any one correct difference and 1/2 mark for each two correct
examples
20
numt, num2 = 10, 45
while numt % num2 ==
—__numi+= 28
__num2+= 30
aise:
print(‘*hello")
% mark for while
mark for :
Y%; mark for correct indentation (inside the block of while)
Yamark for else
21
def dispBook(BOOKS):
for key in BOOKS:
if BOOKS[key][0] not in “AETOUaeiou":
print (BOOKS[ key] .upper())
BOOKS = {1:"Python",2:"Internet Fundamentals “,3: "Networking
",4:"Oracle sets",5:"Understanding HTML"}
dispBook (BOOKS)
% mark for for loop
I mark for if condition
% mark for display in upper case
OR
def FindwWord(STRING, SEARCH):
return (STRING . count (SEARCH) )
str = input(‘Enter String : ')
word = input(‘Enter word to search : ')
print(‘The word’, word, ‘occurs’, FindWord(str,word), ‘times')
% mark for input
% mark for print statement
I mark for counting the word and returning the value
22
9$14$19$5$
Ye mark for 98
Ye mark for 148
% mark for 19$
% mark for 58
23
i. del D[‘Mumbai’]
I mark for correct answerii, print(S.split)
J mark for correct answer
OR
my_str = "Computer Science"
alternate_chars = my_str[::2]
print(alternate_chars)
1.5 mark for logic of alternate characters
Ye mark for printing alternate characters
24
% (Percentage):
‘© Matches any sequence of characters (including empty sequence).
© Example: LIKE ‘T%' matches all those strings starting with the letter 'T
‘The string with just | character 'T' will also be considered.
_ (Underscore):
* Matches a single character.
© Example: LIKE '__T' on the other hand will search for a three letter
string, whose 3rd letter is 'T’, At first two places any two character can
appear.
I mark for one correct difference. 1/2 mark each for correct example of each.
OR
DROP is a DDL command in SQL and can be used to remove tables (or
database),
Example: DROP TABLE STUDENT; ' will remove the table STUDENT from
the database,
DELETE is a DML command used to remove or delete rows/records from a
table.
Example: ‘DELETE FROM STUDENT WHERE PER < 33;' will remove all
those records from the table STUDENT where the percentage is less than 33.
J mark for one correct difference. 1/2 mark each for correct example of each.
25
© COUNT(*) returns the count of all rows in the table, whereas COUNTO
is used with Column_Name passed as an argument and counts the number
of non-NULL values in a column that is given as an argument. Hence the
result may differ.
* The SQL command with COUNT(*) may have higher value as it count
all rows in the table,
I mark for suitable reason
J mark for mentioning correct command
26
@)
CODE[BNAME [TYPE MNO_| MNAME ISSUEDATE,
1102 | Easy Python _| Programming | M101_|[ SNEH SINHA | 2022-10-13,
F102_| Untold Story | Fiction M103. |SARTHAK __| 2021-02-23
C1O1_[Juman Ji__| Thriller M102_[ SARA KHAN _| 2022-06-12
1 mark for correct answer)
@
NAME __ | PROJECT
Satyansh | Pod
Ranjan POL
‘Muneera | POL
‘Alex Por
‘Akhtar Pod
%s mark for correct output,
Gi)
NAME __| SALARY
‘Akhtar [125000
Alex. 75000
Ys mark for correct output
Git)
NAME [DOr
Ranjan | 2015-01-21
‘Akhtar | 2015-02-01
Muneera | 2018-08-19
Ys mark for correct output
(iv)
Fid_[Name [DOB DoF Salary [Project
EOL | Rannja | 1990-07-12 | 2015-01-21 | 150000 | Pot
E03_| Muneera_| 1996-11-15 | 2018-08-19 | 135000_| POT
Yemark for correct output
27 |(a)
@
ID | MIN(FEES) | MAX(FEES)
FOI_| 12000 40000
FO4 15000 17000
Fos | 8000 000
‘FOS NULL NULL
4% mark for correct answer
Gi
AVG(SALARY)
29500.
Ys mark for correct answer
(iii)
FNAME | CNAME,
Neha | Python
‘Neha ‘Computer Network
th mark for correct answer
(iv)
FNAME. CNAME FEES
Anishma___| Grid Computing __| 40000
Neha. Python 17000,
Yamark for correct answer()
DESC or DESCRIBE command
I mark for correct answer
28
def Count():
pen( “Gratitude.txt")
‘TaF.meadlines()
Xel
for i in T:
print( ‘Line’ ,x,":',4-count(‘e'))
XeX#1
F.close()
Count ()
mark for function header
Y% mark for opening and closing the file
Y% mark for reading lines
Ye mark for loop
% mark for count function/or any other alternate correct statement{s)
Ye mark for counter
OR
def start_with_t():
Feopen( ‘Gratitude.txt')
‘TeF .readlines()
for i in T:
if ifo] in *ri":
print(i,end="")
F .close()
Start_with_t()
Y% mark for function header
Ye mark for opening and closing the file
Ye mark for reading lines
Ye mark for loop
1% mark for if condition
Y% mark for print statment
29
@ Candidate Keys : ADMNO, ROLLNO.
J mark for correctly writing both names of candidate keys. OR Y mark for
specifying any one candidate key correctly
(ii) Degree-8, Cardinality=4
% mark for degree and 42 mark for cardinality
Gi) Update result set SEM:
and 100;
EM2+.03*SEM2 where SEM2 between 70
mark for writing Update result set part correctly
Ys mark for writing SEM2=SEM2+.03*SEM2 where SEM2 between 70 and
100; correctly.
30
‘Stu_dict={5:(87,68,89), 10:(57,54,61), 12:(71,67,90),
14:(66,81,80), 18:(80,48,91)}Stu_stk=[]
def Push_elements(Stu_Stk, Stu_dict):
for Stu_ID, marks in Stu_dict.items():
if marks[2]>=80:
‘Stu_Stk.append(Stu_10)
def Pop_elements(Stu_Stk):
while len(Stu_Stk)>0:
print(Stu_Stk.pop())
if not Stu_stk:
print(‘Stack Empty’)
Push_elements(Stu_stk, Stu_dict)
Pop_elements(Stu_stk)
1.5 marks for correct implementation of Push_elements()
1.5 marks for correct implementation of Pop_elements()
31
import csv
def maxsalary():
fzopen(‘record.csv', 'r')
reader=csv.reader(F)
skip_header = True
max= 8
for row in reader:
if skip_header:
skip_header = False
els
if (int (row[3])>max):
maxeint (row[3])
recerow
print('Row with the highest salary : ', rec)
f.close()
maxsalary()
4% mark for importing module
%4 mark for function definition
44 mark for opening and closing file
YAfor reader object
1A for skipping first row (i.e. header)
J mark for calculating maximum salary
44 mark for displaying record having maximum salary
32
import pickle
def expensiverroducts():
with open(*INVENTORY.DAT', ‘rb') as File:
‘expensive_count = ©
while True:
try:
product_data = pickle-load(file)
product_id, product_name, quantity, price = product_data
Af price > 1600:
print(*Product 10:", product_id)
count += 1
print("Total expensive products: *, expensive_count)
‘expensiverroducts()
4% mark for function definition% mark for opening and closing file
4; mark for correct try and except block
1.5 mark identifying and displaying details of expensive products
1 mark for displaying count of expensive products
33,
i. The most appropriate location of the server inside the MUMBAI
campus is ADMIN building due to the maximum number of computers
init.
% mark for mentioning the branch and 4 mark for proper justification
ii, _ Cable Layout
Star Topology (Based on _| Bus Topology (Based on
server location) minimum distance between
_| branches) |
[Moxmar—____] (aunt ]
|
Ceca) |
1 mark for drawing any valid cable layout
DECORATORS
iii. Switch or Hub
Imark for suggesting the correct device
iv. c. Video Conferencing
J mark for correct answer
v.
(@) WAN
(b) LAN
% mark for mentioning WAN and 44 mark for mentioning LAN
34
seek() tell()
Purpose _| Repositions the file pointer toa | Returns the current
specific location within a file — | position of the file
pointer
Syntax seek(offset [reference point]) | tellQ
Parameters | Requires specifying the offset | Requires no
and an optional reference point_| parameters
2 marks for mentioning two correct differences.
OR
1 marks for mentioning only one correct differences.
ii.
import pickle
def COPY_REC():
In_file = open('FLIGHT.DAT' ,‘rb*)
out_file = open('RECORD.DAT', 'wb")
try:while True:
data = pickle.load(In_file)
if data[3] == ‘DELHI’ and data[4] == 'MUMBAT':
pickle.dump(data, out_file)
except:
In_file.close()
out_file.close()
COPY_REC()
"4 mark for function definion
% mark for correctly opening and closing file
’ mark for correct try and except block
1.5 marks for writing required data in RECORD.DAT
OR
i
Binary csv
1. pickle module to be used _| 1, csv module is used
2. Data is stored in binary 2. Data is stored in tabular
format(0s and 1s) and is not | fashion and comma
in human readable form using | separated by default. The
any plain text editor. file can be read by any
spreadsheet software or text
editor.
3. File extension dat/.pdi/.exe | 3. File extension .csv
ete.
2 marks for mentioning two correct differences.
oR
1 marks for mentioning only one correct differences.
ii,
import pickle
def #indBook(price):
with open("BOOK.DAT', 'rb*) as file:
while True:
try:
book_record = pickle.1oad(file)
for item in book_recor
book_price = book_record[item][2]
if book_price >= price:
print(item, book_record[item])
except EOFError:
break
FindBook(50)
' mark for function definion 20/22
44 mark for correctly opening and closing file
Ys mark for correct try and except block -
1.5 marks for displying required records
35,
@SQL constraints are used to specify rules for the data in a table. Constraints
are used to limit the type of data that can go into a table.
Constraints —
NOT NULL - Ensures that a column cannot have a NULL value
UNIQUE - Ensures that all values in a column are different
PRIMARY KEY - A combination of a NOT NULL and UNIQUE. Uniquely
identifies each row in a table
"2 mark for correct definition, 2 mark for correct example (anyone)
(ii)
a) password="tiger’
b) mycursor = conl.cursor()
©) query = ‘delete from ITEM where Iname = "(}" ‘format.(item_name)
d) conl.commit()
J mark for each correct statement
OR
@
Candidate Key: A candidate key is a set of attributes in a relation that can
uniquely identify each tuple (row). A relation can have multiple candidate
keys, but only one of them is chosen as the primary key.
Alternate Key: An alternate key is a candidate key that is not selected as the
primary key.
I mark for any one correct difference.
(ii)
a) import mysql.connector as mysql
b) mycursor = con] cursor()
©) query = ‘SELECT * FROM ITEM where Price > {}’.format(5000)
d) data = mycursor.fetchall()
1 mark for each correct statement