7th 8th and 9th Paper

Download as docx, pdf, or txt
Download as docx, pdf, or txt
You are on page 1of 34

SAMPLE PAPER SET – 7

CLASS – XII Subject: COMPUTER SCIENCE


Maximum Marks: 70 Time Allotted: 3 hours
General Instructions:
1. This question paper contains five sections, Section A to E.
2. All questions are compulsory.
3. Section A have 18 questions carrying 01 mark each.
4. Section B has 07 Very Short Answer type questions carrying 02 marks each.
5. Section C has 05 Short Answer type questions carrying 03 marks each.
6. Section D has 03 Long Answer type questions carrying 05 marks each.
7. Section E has 02 questions carrying 04 marks each.
8. All programming questions are to be answered using Python Language only.

SECTION – A
1. Python identifiers are case sensitive. 1
a) True
b) False
2. Find the invalid identifier from the following: 1
a) None
b) address
c) Name
d) Pass
3. Which is the correct form of declaration of dictionary? 1
a) Day={1:’Monday’,2:’Tuesday’,3:’Wednesday’}
b) Day={‘1:Monday’,’2:Tuesday’,’3:Wednesday’}
c) Day=(1:’Monday’,2:’Tuesday’,3:’Wednesday’)
d) Day=[1:’Monday’,2:’Tuesday’,3:’Wednesday’]
4. What is the output of ‘hello’+1+2+3? 1
a) hello123
b) hello6
c) Error
d) Hello+6
5. What will be the output for the following Python statement? T=(10,20, 1
[30,40,50],60,70)
T[2][1]=100
print(T)
a) (10,20,100,60,70)
b) (10,20,[30,100,50],60,70)
c) (10,20,[100,40,50],60,70)
d) None of these
6. Which of the following is not a correct Python statement to open a text file 1
“Notes.txt” to write content into it?
a) F=open(‘Notes.txt’,’w’)
b) F=open(‘Notes.txt’,’a’)
c) F=open(‘Notes.txt’,’A’)
d) F=open(‘Notes.txt’,’w+’)
7. Which command is used to add a new constraint in existing table in SQL. 1
a) insert into
b) alter table
c) add into
d) create table
8. Which SQL command is used to change some values in existing rows? 1
a) update
b) insert
c) alter
d) order
9. STRING=“WELCOME” Line1 1
NOTE= “ ” Line2
for S in range[0,8]: Line3
print(STRING[S]) Line4
print(S STRING) Line5

Which statement is wrong in above code:


a) Line3 and Line4
b) Line4 and Line5
c) Line2 and Line3
d) Line3 and Line5
10. Which of the following aggregate function ignore NULL value? 1
a) COUNT
b) MAX
c) AVERAGE
d) ALL OF THESE
11. Which of the following option is the correct Python statement to read and display 1
the first 10 characters of a text file “Notes.txt”?
a) F=open(“Notes.txt”); print(F.load(10))
b) F=open(“Notes.txt”); print(F.dump(10))
c) F=open(“Notes.txt”); print(F.read(10))
d) F=open(“Notes.txt”); print(F.write(10))
12. Consider the following statement: 1
SELECT * FROM PRODUCT ORDER BY RATE………, ITEM_NAME ………
Which of the following option should be used to display the rate from greater to
smaller and name in alphabetical order?
a) ASC, DESC
b) DESC, ASC
c) Descending, Ascending
d) Ascending, Descending
13. The function of a repeater is to take a weak signals and..................it. 1
a) Restore
b) Regenerate
c) Reroute
d) Drop
14. Evaluate the following expression and identify the correct answer: 1
16 – (4 + 2) * 5 + 2**3 * 4
a) 54
b) 46
c) 18
d) 32
15. In SQL, which command is use to display the structure of table stored in a database. 1
a) Describe
b) Display
c) Select
d) Alter
16. Which of the following is invalid method for fetching the records from database 1
within Python
a) fetchone()
b) fetchall()
c) fetchmany()
d) fetchmulti()
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): Built-in function are predefined in the language that are used 1
directly.
Reason (R): print() and input() are built-in funcitions
18. Assertion (A): Access mode ‘a’ opens a file for appending. 1
Reason (R): The file pointer is at the end of the file if the file exists.
SECTION – B
19. Rewrite the following code in python after removing all errors. Underline each 2
correction done in the code:

num=int(“Enter any value”)


for in range(0,11):
if num==i
print num+i
else:
Print num-i
20. Differentiate between web browser and web server. 2
OR
Identify the type of topology from the following:
a) Each node is connected with central switching through independent cable.
b) Each node is connected with the help of a single cable.
21. a) Given a Tuple 1
tup1=(10,20,30,40,50,60,70,80,90).
What will be the output of
print(tup1[3:7:2])?
b) Write the output of following code:
lst1=[10,15,20,25,30]
lst1.insert(3,4)
lst1.insert(2,3)
print(lis[-5]) 1
22 What do you mean by alternate key in a relation/table? Give a suitable example of 2
alternate key.
23 a) Which protocol helps us to browse web pages on browsers? 1
b) Write full form of the following:
i) IMAP
ii) POP 1
24 Write the output of the following Python program code: 2

Value = 100
def funvalue():
global Value
Value//=9
print(Value,end=” “)
Value-=10
print(Value,end=” “)
funvalue()
OR

TXT = ["10","20","30","5"]
CNT = 3
TOTAL = 0
for C in [7,5,4,6]:
T = TXT[CNT]
TOTAL = float (T) + C
print (TOTAL)
CNT-=1
25 What do you understand by GROUP BY in SQL? Explain the use of HAVING clause 2
with GROUP BY.
OR
Write the full form of DDL and DML also write any two commands of DML in SQL.
Section-C
26 a) 2+1
Table: GAMES
GCode GameName Number PrizeMoney ScheduleDate
101 Carom Board 2 5000 23-Jan-2004
102 Badminton 2 12000 12-Dec-2003
103 Table Tennis 4 8000 14-Feb-2004
105 Chess 2 9000 01-Jan-2004
108 Lawn Tennis 4 25000 19-Mar-2004

Table: PLAYER
PCode Name Gcode
1 Nabi Ahmad 101
2 Ravi Sahai 108
3 Jatin 101
4 Nazneen 103

(i) SELECT COUNT(DISTINCT Number) FROM GAMES;


(ii) SELECT MAX(ScheduleDate),MIN(ScheduleDate) FROM GAMES GROUP
BY NUMBER HAVING COUNT(*)>2;
(iii) SELECT SUM(PrizeMoney) FROM GAMES;
(iv) SELECT AVG(PRIZEMONEY) FROM GAMES;

b) Define Equi join with a suitable example


27 Write a function in python to count the number of lowercase and uppercase 3
character in a text file “Story.txt”.
OR
Write a function to calculate the average word size in a text file “Report.txt” each
word is separated by a single space or full stop.
28 Write SQL commands for (a) to (d) and write output for (e) to (f) on the basis of 3
PRODUCTS table:
PRODUCT TABLE
PCODEPNAME COMPANY PRICE STOCK MANUFACTURE WARRANTY
P001 TV BPL 10000 200 12-JAN-2008 3
P002 TV SONY 12000 150 23-MAR-2007 4
P003 PC LENOVO 39000 100 09-APR-2008 2
P004 PC COMPAQ 38000 120 20-JUN-2009 2
P005 HANDYCAM SONY 18000 250 23-MAR-2007 3

a) To show details of all PCs with stock more than 110.


b) To list the company which gives warranty for more than 2 years.
c) To show number of products from each company.
d) To show the PRODUCT name which are within warranty as on date.
Give the output of following statements :-
e) Select COUNT(distinct company) from PRODUCT;
f) Select MAX(price) from PRODUCT where WARRANTY<=3;
29 Write a function in Shift(Lst), Which accept a List ‘Lst’ as argument and swaps the 3
elements of every even location with its odd location and store in different list
eg. if the array initially contains
2, 4, 1, 6, 5, 7, 9, 2, 3, 10
then it should contain
4, 2, 6, 1, 7, 5, 2, 9, 10, 3
30 Write a function in Python PUSH(A), where A is a list of numbers. From this list push 3
all even numbers into a stack implemented by using a list. Display the stack if it has
at least one element, otherwise display appropriate error message.
OR
Write a function in python Popstack(Lst), where Lst is a stack implemented by a list
of numbers. The function returns the value deleted from the stack.

SECTION-D
31 Rehaana Medicos Center has set up its new center in Dubai. It has four buildings as 5
shown in the diagram given below:

Accounts Research
Lab

Store Packaging
Unit
Shortest distance between various buildings
Accounts to Research Lab 55 m
Accounts to Store 150 m
Store to Packaging Unit 160 m
Packaging Unit to Research 60 m
Lab
Accounts to Packaging Unit 125 m
Store to Research Lab 180 m

No. of computers installed at various buildings are as follow:


Accounts 25
Research Lab 100
Store 15
Packaging Unit 60
As a network expert, provide the best possible answer for the following queries:

(i) Suggest a cable layout of connections between the buildings.


(ii) Suggest the most suitable place (i.e. buildings) to house the server of
this organization.
(iii) Suggest the placement of the following device with justification:

a) Repeater b) Hub/Switch

(iv) Suggest a system (hardware/software) to prevent unauthorized access


to or from the network.
(v) Which service/protocol will be most helpful to conduct live interactions
between the buildings?

32 a) Study the following program and select the possible output(s) from the options 2+3
(i) to (iv) following it.

import random
Ar=[20,30,40,50,60,70]
From = random.randint(1,3)
To = random.randint(2,4)
for K in range(From,To+1):
print(Ar[K],end="%")

(i) 10%40%70%
(ii) 30%40%50%
(iii) 50%60%70%
(iv) 40%50%60%

b) The code given below inserts the following record in the table Student:
Empno – integer
EName – string
Designation – integer
Salary – integer
Bonus - 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 Employee.
 The details (Empno, EName, Designation, Salary and Bonus) 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="Employee")
mycursor= #Statement 1
eno=int(input("Enter Employee Number: "))
Ename=input("Enter Employee Name: ")
designation=input("Enter Designation: "))
salary=int(input("Enter Salary: "))
bonus=int(input("Enter Bonus: "))
querry="insert into employee values({},'{}',{},{})".
format(eno,ename,designation,bonus)
#Statement 2
# Statement 3
print("Employee Data Added successfully")
OR
a) Write the output of the following Python program code:
def changedata(str1):
length=len(str1)
temp=""
for i in range(0, length):
if str1[i].islower():
temp=temp+str1[i].upper()
elif str1[i].isupper():
temp=temp+str1[i].lower()
elif str1[i].isdigit():
temp=temp+str(int(str1[i])+1)
else:
temp=temp+'@'
print(temp)
changedata("CbSe_exam@2023")

b) Consider the table Product with following structure:


P_ID, ProductName, Manufacture, Price.
Write python code to increase the price of all product by 50.

33 A binary file “Toy.dat” has structure [TID, Toy, Status, MRP]. 5


i. Write a user defined function CreateFile() to input data for a record and
add to Toy.dat.
ii. Write a function OnOffer() in Python to display the detail of those Toys,
which has status as “ON OFFER” from Toy.dat file.
OR
i. A binary file “ITEMS.DAT” has structure (ID, GIFT, Cost). Write a function to
write more items in ITEM.DAT
ii. Write a function Economic() in Python that would read contents of the file
“ITEMS.DAT” and display the details of those ITEMS whose cost is greater
then 2500.
SECTION-E
34 A music store MySports is considering to maintain their inventory using SQL to store 4
the data. The detail is as follow:
 Name of the database – MySports
 Name of the table – Sports
 The attributes of SPORTS are as follows:
 SCode – character
 SportName – character of size 20
 Noofplayers – numeric
 coachname – character of size 20
Table: SPORTS
SCode SportName No. of players Coachname
S001 Cricket 21 Rahul Dravid
S002 Football 25 Roshan Lal
S003 Hockey 40 Sardar Singh
S004 Cricket 19 Chetan Sharma
S005 Archery 12 Limbaram
S006 Shooting 17 Deepika Kumari

a) Identify the attribute best suitable to be declared as a primary key


b) Write the degree and cardinality of the SPORTS table
c) Insert the following data into the attributes SCode, SportName and No. of
players respectively in the given table SPORTS.
SCode = S007, SportName = “Kabbadi” and Noofplayers = 15
OR
d) Someone wants to delete the column coachname. Which command will he
use from the following:
i) DELETE Coachname FROM SPORTS;
ii) ALTER Coachname FROM SPORTS
iii) ALTER TABLE SPORTS DROP Coachname
iv) DELETE Coachname FROM SPORTS

35 Arjun of class 12 is writing a program to create a CSV file “user.csv” which will 4
contain user name and password for some entries. He has written the following
code. As a programmer, help him to successfully execute the given task.

import # Line 1
def addCsvFile(UserName,PassWord): # module to write data into a CSV file
f=open('user.csv','w')
newFileWriter = csv. (f) # Line 2
x=[UserName,PassWord]
newFileWriter. (x) # Line 3
f. () # Line 4
def readCsvFile(): # to read data from CSV file
with open(' user.csv', 'r') as newFile:
newFileReader = csv.reader(newFile)
for row in newFileReader:
print (row[0],row[1])
addCsvFile(“Arjun”,”123@456”)
addCsvFile(“Arunima”,”aru@nima”)
addCsvFile(“Frieda”,”myname@FRD”)
readCsvFile()

a) Name the module he should import in Line 1.


b) Fill in the blank in Line 2 to write data into a csv file.
c) Fill in the blank in Line 3 to write record into a csv file.
d) Fill in the blank in Line 4 to close the file.
SAMPLE PAPER SET – 8
CLASS – XII Subject: COMPUTER SCIENCE
Maximum Marks: 70 Time Allotted: 3 hours
General Instructions:
1. This question paper contains five sections, Section A to E.
2. All questions are compulsory.
3. Section A have 18 questions carrying 01 mark each.
4. Section B has 07 Very Short Answer type questions carrying 02 marks each.
5. Section C has 05 Short Answer type questions carrying 03 marks each.
6. Section D has 03 Long Answer type questions carrying 05 marks each.
7. Section E has 02 questions carrying 04 marks each. One internal choice is given in Q35 against
part c only.
8. All programming questions are to be answered using Python Language only.

SECTION A

1. Which of the following is an invalid identifier? 1


(a) true
(b) print
(c) 4ever
(d) While
2. Consider the following expression 1
5+2**6<9+2-16//8
Which of the following will be correct output if the given expression is evaluated?
(a) 127
(b) False
(c) True
(d) Invalid expression
3. State True or False 1
“ There is no conceptual limit to the size of a list.”
4. Which of the following options will not result in an error when performed on types in 1
python where tp = (5,2,7,0,3) ?
(a) tp[1] = 22
(b) tp.append(23)
(c) tp1 = tp+tp*2
(d) tp.sum()
5. Select the correct output of the code: 1
mystr = ‘Python programming is fun!’
mystr = mystr.partition(‘pro’)
mystr=’$’.join(mystr)
(a) Python $programming is fun!
(b) Python $pro$gramming is fun!
(c) Python$ pro$ gramming is fun!$
(d) P$ython $p$ro$gramming is $fun!
6. Which of the following commands is used to open a file “c:\test.txt” for reading and 1
writing data in binary format only.
(a) myfile = open(‘c:\\test.txt’,’rb+’)
(b) myfile = open(‘c:\test.txt\’,’wb’)

1
(c) myfile = open(‘c:\test.txt’,’w+’)
(d) myfile = open(‘c:\\test.txt’,’rb’)
7. Which of the following operators can take wild card characters for query condition? 1
(a) BETWEEN
(b) LIKE
(c) IN
(d) NOT
8. In SQL, which of the following will select only one copy of each set of duplicable rows 1
from a table?
(a) SELECT UNIQUE
(b) SELECT DISTINCT
(c) SELECT DIFFERENT
(d) All of these
9. Given tp = (1,2,3,4,5,6). Which of the following two statements will give the same 1
output?
1. print(tp[:-1])
2. print(tp[0:5])
3. print(tp[0:4])
4. print(tp[-4:])

(a) Statement 1 and 2


(b) Statement 2 and 4
(c) Statement 1 and 4
(d) Statement 1 and 3
10. The primary key is selected from the set of 1
(a) Composite keys
(b) Determinants
(c) Candidate keys
(d) Foreign keys
11. Which of the following functions do you use to write data in the binary format? 1
(a) write()
(b) output()
(c) dump()
(d) send()
12 In SQL, which command is used to change a table’s structure/characteristics? 1
(a) ALTER TABLE
(b) MODIFY TABLE
(c) CHANGE TABLE
(d) DESCRIBE TABLE
13. Your school has four branches spread across the city. A computer network created by 1
connecting the computers of computer labs of all the school branches, is an example
of .
(a) LAN
(b) MAN
(c) WAN
(d) PAN
14. What will be the following expression be evaluated to in Python? 1
print(5*2-5//9+2.0+bool(100))
(a) 11.0
(b) 13.0
(c) 112.0

2
(d) 100
15. Which clause is used with “aggregate functions” ? 1
(a) GROUP BY
(b) SELECT
(c) WHERE
(d) Both (a) and (c)
16. To fetch one record from the result set, you may use <cursor>. method: 1
(a) fetch()
(b) fetchone()
(c) fetchsingle()
(d) fetchtuple()
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); Binary file is faster than text file, so it is mostly used for storing data. 1

Reasoning (R): Text file stores less characters as compared to the binary file.
18. Assertion (A); A variable is still valid if it is not defined inside the function. The values 1
defined in global scope can be used.

Reasoning (R): Python used LEGB rule to resolve the scope of a variable.

SECTION B

19. Sumit is trying to write a program to find the factorial of a number passed to the 2
function and he has written the following code but it’s not working and producing
errors. Help Sumit to correct this and rewrite the corrected code. Also underline the
corrections made.

Def prime (num):


factorial = 1
if num < 0:
print("Sorry, factorial does not exist for negative numbers")
else num == 0
print("The factorial of 0 is 1")
else:
for i in range(1,num + 1):
factorial = factorial*i
print("The factorial of",num,"is",factorial)
20. What is the difference between a hub and a switch? 2
OR
Differentiate between Bus Topology and Star Topology of Networks. What are the
advantages and disadvantages of Star Topology over Bus Topology ?
21. (a) Convert the following for loop into while loop: 2

name = ‘ Karim Benzema’


for index in range(len(name)):
print(name[index].upper(),end=’’)

3
(b) Write the output of the following code given below:

Marks = {‘Sidhi’:65,’Prakul’:62,’Suchitra’:64,’Prashant’:50}
newMarks = {‘Suchitra’:66,’Arun’:55,’Prashant’:49}
Marks.update(newMarks)
for key,value in Marks.items():
print(key,’scored’,value,’marks in Pre Board’,end= ‘ ‘)
if(value<55):
print(‘and needs imporovement’end=’.’)

print()
22. Explain Referential Integrity in a Relational Database Management System. Why DBMS 2
is better than File System.
23. (a) Write full forms of the following: 2
(i) SMTP
(ii) IMAP
(b) What is MAC address?
24. Predict the output of the Python code given below: 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)

OR

Data = ["P",20,"R",10,"S",30]
Times = 0
Alpha = ""
Add = 0
for C in range(1,6,2):
Times = Times + C
Alpha = Alpha + Data[C-1]+"$"
Add = Add + Data[C]
print (Times,Add,Alpha)
25. What is the difference between CHAR and VARCHAR ? Write 2-3 differences. 2
OR
Differentiate between a Candidate Key and Alternate Key.

SECTION C

26. (a) Consider the following tables CUSTOMER and TRANSACTION: 1+2
Table: CUSTOMER
ACNO NAME GENDER BALANCE
C1 RISHABH M 15000
C2 AAKASH M 12500
C3 INDIRA F 9750

4
Table: TRANSACTIONS
ACNO TDATE AMOUNT TYPE
C1 2022-07-21 1000 DEBIT
C2 2022-08-31 1500 CREDIT
C3 2022-09-15 2000 CREDIT

What will be the output of the following statement?

SELECT NAME, TDATE, AMOUNT FROM CUSTOMER C, TRANSACTION T WHERE C.ACNO


= T.ACNO AND TYPE = 'CREDIT';

(b) Write the output of the queries (i) to (iv) based on the tables, ACCOUNT
and TRANSACT given below:

Table: ACCOUNT
ANO ANAME ADDRESS
101 Nirja Singh Bangalore
102 Rohan Gupta Chennai
103 Ali Reza Hyderabad
104 Rishabh Jain Chennai
105 Simran Kaur Chandigarh

Table: TRANSACT
TRNO ANO AMOUNT TYPE DOT
T001 101 2500 Withdraw 2017-12-21
T002 103 3000 Deposit 2017-06-01
T003 102 2000 Withdraw 2017-05-12
T004 103 1000 Deposit 2017-10-22
T005 101 12000 Deposit 2017-11-06

(i) SELECT ANO, ANAME FROM ACCOUNT WHERE ADDRESS NOT IN


('CHENNAI', 'BANGALORE');
(ii) SELECT DISTINCT ANO FROM TRANSACT;
(iii) SELECT ANO, COUNT(*), MIN(AMOUNT) FROM TRANSACT GROUP BY
ANO HAVING COUNT(*)> 1;
(iv) SELECT COUNT(*), SUM(AMOUNT) FROM TRANSACT WHERE DOT <=
'2017-06-01';
27. Write the definition of a function ChangeGender() in Python, which reads the contents 3
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 :

5
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.

OR

Write a method/function BIGWORDS() in Python to read contents from a text file


CODE.TXT, to count and display the occurrence of those words, which are having 5 or
more alphabets.

For example :
If the content of the file is
ME AND MY FRIENDS
ENSURE SAFETY AND SECURITY OF EVERYONE

The method/function should display


Count of big words is 5
28. (a) Write the outputs of the SQL queries (i) to (iv) based on the relations TRAINS and 3
PASSANGERS given below:

Table: TRAINS
TNO TNAME START END
11096 Ahimsa Express Pune Junction Ahmedabad Junction
12015 Ajmer Shatabdi New Delhi Ajmer Junction
1651 Pune Hbj Special Pune Junction Habibganj
13005 Amritsar Mail Howrah Junction Amritsar Junction
12002 Bhopal Shatabdi New Delhi Habibganj
12417 Prayag Raj Express Allahabad Junction New Delhi

Table: PASSANGERS
PNR TNO PNAME GENDER AGE TRAVELDATE
P001 13005 R N AGRAWAL MALE 45 2018-12-25
P002 12015 P TIWARY MALE 28 2018-11-10
P003 12015 S TIWARY FEMALE 22 2018-11-10
P004 12030 S K SAXENA MALE 42 2018-10-12
P005 12030 S SAXENA FEMALE 35 2018-10-12
P006 12030 P SAXENA FEMALE 12 2018-10-12

(i) SELECT DISTINCT TRAVELDATE FROM PASSENGERS;


(ii) SELECT MIN (TRAVELDATE), MAX (TRAVELDATE) FROM PASSENGERS
WHERE GENDER = 'MALE';
(iii) SELECT START, COUNT(*) FROM TRAINS GROUP BY START HAVING COUNT
(*)>1;
6
(iv) SELECT TNAME, PNAME FROM TRAINS T, PASSENGERS P WHERE T.TNO =

7
P.TNO AND AGE BETWEEN 40 AND 50;

(b) Write a query/command to display the structure of a table.


29. Define a function ZeroEnding(SCORES) to add all those values in the list of SCORES, 3
which are ending with zero (0) and display the sum.
For example :
If the SCORES contain [200, 456, 300, 100, 234, 678]
The sum should be displayed as 600
30. A list contains following record of a student: 3
[student_name, marks, subject]
Write the following user defined functions to perform given operations on the stack
named ‘status’:
(i) Push_element() - To Push an object containing name and marks of a student who
scored more than 75 marks in ‘CS’ to the stack
(ii) Pop_element() - To Pop the objects from the stack and display them. Also, display
“Stack Empty” when there are no elements in the stack.
For example:
If the lists of customer details are:

[“Danish”,80,”Maths”]
[“Hazik”,79,”CS”]
[“Parnik”,95,”Bio”]
[“Danish”,70,”CS”]
[“Sidhi”,99,”CS”]

The stack should contain


[“Hazik”,”79”]
[“Sidhi”,”99”]

The output should be:

[“Hazik”,”79”]
[“Sidhi”,”99”]
Stack Empty
OR

Write a function in Python, Push(emp) where , emp is a dictionary containing the


details of employees – {empname:salary}.
The function should push the names of those employees in the stack who have salary
less than 15000. Also display the count of elements pushed into the stack.
For example:

If the dictionary contains the following data:

Employee ={"Sohan”:20000,”Mohan”:9000,”Rohan”:25000,”Aman”:5000}
The stack should contain
Mohan
Aman

The output should be:


The count of elements in the stack is 2
SECTION D
8
9
31. Ayurveda Training Educational Institute is setting up its centre in Hyderabad with four 5
specialised departments for Orthopedics, Neurology and Pediatrics along with an
administrative office in separate buildings. The physical distances between these
department buildings and the number of computers to be installed in these
departments and administrative office are given as follows.
You, as a network expert, have to answer the queries as raised by them in (i) to (iv).

Shortest distances between various locations in metres :

Administrative Office to Orthopedics Unit 55


Neurology Unit to Administrative Office 30
Orthopedics Unit to Neurology Unit 70
Pediatrics Unit to Neurology Unit 50
Pediatrics Unit to Administrative Office 40
Pediatrics Unit to Orthopedics Unit 110

Number of Computers installed at various locations are as follows

Pediatrics Unit 40
Administrative Office 140
Neurology 50
Orthopedics Unit 80

ADMINSISTRATIVE OFFICE

ORTHOPEDICS OFFICE PEDIATRICS UNIT

NEUROLOGY UNIT

(i) Suggest the most suitable location to install the main server of this
institution to get efficient connectivity.
(ii) Suggest the best cable layout for effective network connectivity of the
building having server with all the other buildings.
(iii) Suggest the devices to be installed in each of these buildings for connecting
computers installed within the building out of the following:
• Switch
• Gateway

(iv) Suggest a device/software to be installed in the given network to take care of


data security.
(v) Suggest an efficient as well as economic wired medium to be used within each
unit for connecting computer systems out of the following network cable :

10
Co-axial Cable, Ethernet Cable, Single Pair Telephone Cable.
32. (a) Write the output of the code given below: 2+3

def myfunction(str1):
rstr1 = ‘’
index = len(str1)
while index>0:
if str1[index-1].isalpha():
rstr1+=str1[index-1]
index = index-1
return rstr1
print(myfunction(‘1234abcd’))

(b)
The code given below updates the record of table EMP by increasing salary by
1000Rs. of all those employees who are getting less than 80000Rs.

empno – integer
empname – string
salary – float

Note the following to establish connectivity between Python and MYSQL:


Username is root
Password is admin
The table exists in a MYSQL database named abcinfo.

Write the following missing statements to complete the code:


Statement 1 – to form the cursor object
Statement 2 – to update the records as mentioned in the question
Statement 3- to add the record permanently in the database

import mysql.connector as ms
db1 = ms.connect(host=’localhost’,user=’root’,passwd=’admin’,database=’abcinfo’)
cur = #Statement 1
sql = ‘UPDATE ’ #Statement 2
#Statement 3
print(‘Data Updated successfully’)
OR
(a) What possible output(s) is/are expected to be displayed on the screen at the
time of 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 = random.randrange(K)
print (Signal[R], end = ' # ')

(a) Stop # Wait # Go #


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

11
(b) The code given below inserts the following record in the table employee:
empID – integer
empName – string
salary – float
dept – sting
Note the following to establish connectivity between Python and MYSQL:
 Username is root
 Password is admin
 The table exists in a MYSQL database named empdata.
 The details (empID, empName, salary and dept) 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
Student.
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="admin",
database="empdata")
mycursor= #Statement 1
empID =int(input("Enter employee ID :: "))
empName=input("Enter employee name :: ")
salary =float(input("Enter salary :: "))
dept= input("Enter department :: ")
querry="insert into employee
values({},'{}',{},{})".format(empID,empName,salary,dept)
#Statement 2
# Statement 3
print("Data Added successfully")
33. What is the full form of CSV? 5
Write a Program in Python that defines and calls the following user defined functions:
A csv file "PLANTS.csv" has structure [ID, NAME, PRICE].
 WRITEREC() - to input data for records from the user and write them to the file
PLANTS.csv. Each record consists of a list with field elements as ID, NAME and
PRICE to store plant id, plant name and price respectively
 SHOWHIGH() - To read the records of PLANTS.csv and displays those records
for which the PRICE is more than 500.

OR

What is the difference between a text file and a binary file?


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

A csv file "PATIENTS.csv" has structure [PID, NAME, DISEASE].


Write the definition of a function countrec()in Python that would read contents
of the file "PATIENTS.csv" 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'.
SECTION E
34. Pravesh is a database administrator for a company and has created the following 1+1+2
table:
12
13
Table: MOVIEDETAILS
MOVIEID TITLE LANGUAGE RATING PLATFORM
M001 Minari Korean 5 Netflix
M004 MGR Magar Tamil 4 Hotstar
M010 Kaagaz Hindi 3 Zee 5
M011 Harry Potter English 4 Prime Video
M015 Uri Hindi 5 Zee5
M020 Avengers: English 4 Hotstar
Endgame

(a) Identify the degree and cardinality of the table.


(b) Which field should be made the primary key? Justify your answer.
(c) Write the statements to:
(i) Delete the Records where the rating is less than 4
(ii) Update the rating of Movie having ID as M020 to 5.
OR
(c) Write the statements to
(i) Add another column called Recommended having default value of
‘Recommended’.
(ii) Increase the ratings of all Hindi movies by 1.
35. Aaruni Shah is learning to work with Binary files in python using a process knows as 4
pickling/de-pickling. Her teacher has given her the following incomplete code, which is
creating a binary file namely Mydata.dat and then opens , reads and displays the
content of the created files.
#Fill_Line 1
sqlist = list()
for k in range(10):
sqlist.append(k*k)
fout = ‘ #Fill_Line2A
#Fill_Line3
fout.close()
fin = #Fill_Line2B
#Fill_Line4
fin.close()
print(“Data from file:”,mylist)

Help her complete the above code as per the instructions given below:

(a) Complete Fill_Line1 so that the required Python library becomes available to
the program.
(b) Complete Fill_Line2A so that the above mentioned binary file is opened for
writing in the file object fout.
Similarly, complete Fill_Line2B, which will open the same binary file for reading
in the file object fin.
(c) Complete Fill_Line3 so that the list created in the code, namely Sqlist is written
in the open file.
(d) Complete Fill_Line4 so that the contents of the open file in the file handle fin
are read in a list namely mylist.

14
SAMPLE PAPER SET – 9
CLASS – XII Subject: COMPUTER SCIENCE
Maximum Marks: 70 Time Allotted: 3 hours
General Instructions:
1. This question paper contains five sections, Section A to E.
2. All questions are compulsory.
3. Section A have 18 questions carrying 01 mark each.
4. Section B has 07 Very Short Answer type questions carrying 02 marks each.
5. Section C has 05 Short Answer type questions carrying 03 marks each.
6. Section D has 03 Long Answer type questions carrying 05 marks each.
7. Section E has 02 questions carrying 04 marks each. One internal choice is given in Q35 against
part c only.
8. All programming questions are to be answered using Python Language only.

SECTION A

1. State weather True or False: 1


“ The expression 2**2**3 is evaluated as (2**2)**3.
2. Evaluate the following expression and identify the correct answer. 1
16 - (4 + 2) * 5 + 2**3 * 4
a. 54
b. 46
c. 18
d. 32
3. What gets printed when the following code is executed? 1
names = [‘Hasan’,’Balwant’,’Sean’,’Dia’]
print(names[-1][-1])

(a) h
(b) n
(c) a
(d) Dia
4. Which among the following operators has the highest precedence? a) 1
+
b)%
c)|
d)**
5. Which of the following is not a valid identifier ? 1
a) ABC
b) _num
c) Prints
d)4map
6. To use randint(a,b) which of the following module should be imported ? 1
a)math
b)random
c)CSV
d)randinteger()

1
7. What will be the output when the following code is executed? 1
L= [1,3,5,4,8,9]
print(L[-1:-5])
8. Central computer which is powerful than other computers in the network is called 1
a) Hub
b) Sender
c) Switch
d) Server
9. Method used to force python to write the contents of file buffer on to storage file is 1
a) count()
b) read()
c) flush()
d) True
10. In a range function, which of the following argument is mandatory to pass: 1
a) Start
b) Stop
c) Step
d) All of these
11. Fill in the blank: 1
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
12 Which of the following is a DDL command? 1
a) SELECT
b) ALTER
c) INSERT
d) UPDATE
13. Which of the following is not a function / method of csv module in Python? 1
a. read()
b. reader()
c. writer()
d. writerow()
14. Syntax of seek function in Python is myfile.seek(offset, reference_point) where 1
myfile is the file object. What is the default value of reference_point?
a. 0
b. 1
c. 2
d. 3
15. Which of the following character acts as default delimiter in a csv file? 1
a. (colon) :
b. (hyphen) -
c. (comma) ,
d. (vertical line) |
16. Fill in the blank: 1
is the method used in python while interfacing the SQL with Python to
save the changes permanently to the database while inserting or modifying the
records.
(a) save() (b) commit() (c) final() (d) lock()

2
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): When passing a mutable sequence as an argument, function modifies 1
the original copy of the sequence.
Reasoning (R): Function can alter mutable sequences passes to it.
18. Assertion (A): with statement can be used to open a file and should be preferred 1
over other ways to open a file.
Reasoning (R): with statement is a block of statement that makes sure the file is
closed in case of any run-time error and buffer is cleared to avoid data loss.

SECTION B

19. Consider the following code written by a programming student. The student is a 2
beginner and has made few errors in the code. You are required to rewrite the code
after correcting it and underline the corrections.
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 are cookies in a web browser ? Write one advantage and one disadvantage of 2
enabling cookies in a web browser.
OR
What is the difference between client side and server side scripting?
21. (a) Consider the given Python string declaration: 2
mystring = ‘Programming is Fun’

Write the output of: print(mystring[-50:10:2].swapcase())

(b) Write the output of the code given below:

a,b,c,d = (1,2,3,4)
mytuple = (a,b,c,d)*2+(5**2,)
print(len(mytuple)+2)
22. What do you mean by DDL and DML commands in DBMS? Write examples of each. 2
23. (a) Write the full forms of the following: 2
(i) WLAN
(ii) WWW
(b) What is a hub? What are its types?
24. Predict the output of the following code: 2

3
def my_func(var1=100, var2=200):
var1+=10
var2 = var2 - 10
return var1+var2
print(my_func(50),my_func())

OR

value = 50
def display(N):
global value
value = 25
if N%7==0:
value = value + N
else:
value = value - N
print(value, end="#")
display(20)
print(value)
25. Differentiate between a PRIMARY KEY and UNIQUE constraint in SQL with 2
appropriate example.

OR

What is the difference between WHERE and HAVING clause? Can we use them
together in a query?

SECTION C

26. (a) Consider the following tables STORE and SUPPLIERS: 1+2

Table: STORE
ItemNo Item Scode Qty Rate LastBuy
2005 Sharpner 23 60 8 31-Jun-
Classic 09
2003 Ball Pen 0.25 22 50 25 01-Feb-
10
2002 Gel Pen 21 150 12 24-Feb-
Premium 10
2006 Gel Pen 21 250 20 11-Mar-
Classic 09
2001 Eraser Small 22 220 6 19-Jan-
09
2004 Eraser Big 22 110 8 02-Dec-
09
2009 Ball Pen 0.5 31 180 18 03-Nov-
09

4
Table: SUPPLIERS
Scode Sname
21 Premium Stationers
23 Soft Plastics
22 Tetra Supply

What will be the output of the following statement?

SELECT * FROM STORE JOIN SUPPLIERS ON STORE.Scode = SUPPLIERS.Scode;

(b) Write the output of the queries (i) to (iv) based on the tables, ITEM and
CUSTOMER given below:

Table: ITEM
I_ID ItemName Manufacturer Price
PC01 Personal ABC 35000
Computer
LC05 Laptop ABC 55000
PC03 Personal XYZ 32000
Computer
PC06 Personal COMP 37000
Computer
LC03 Laptop PQR 57000

Table: CUSTOMER
C_ID CustomerName City I_ID
01 N Roy Delhi LC03
06 H Singh Mumbai PC03
12 R Pandey Delhi PC06
15 C Sarma Delhi LC03
16 K Agarwal Bangalore PC01

(i) SELECT DISTINCT City FROM Customer;


(ii) SELECT ItemName, MAX(Price), Count(*) FROM Item GROUP BY
ItemName;
(iii) SELECT CustomerName, Manufacturer FROM Item,Customer WHERE
Item.I_ID = Customer.I_ID;
(iv) SELECT ItemName,Price*100 FROM Item WHERE Manufacturer =
‘ABC’;
27. Write a method in python to read lines from a text file INDIA.TXT, to find and 3
display the occurrence of the word “INDIA” or “India”.
For example:
If the content of the file is

5
INDIA is a famous country all over the world.
Geographically, India is located to the
south of Asia continent. India is a high
population country and well protected
from all directions naturally.
India is a famous country for
its great cultural and traditional
values all across the world.

The output should be 4

OR

Write a method/function BIGLINES() in Python to read lines from a text file


CONTENT.TXT, and display those lines, which are bigger than 20 characters.

For example :
If the content of the file is

Stay positive and happy


Work hard and dont give up hope
Be open to criticism and keep learning
Surround yourself with happy, warm and genuine people

The method/function should display

Be open to criticism and keep learning


Surround yourself with happy, warm and genuine people
28. a) Write the outputs of the SQL queries (i) to (iv) based on the relations SENDER and 3
RECIPIENT below:

Table: SENDER
SenderID SenderName SenderAddress SenderCity
ND01 R Jain 2, ABC Appts New Delhi
MU02 H Sinha 12, Newtown Mumbai
MU15 S Jha 27/A, Park Street Mumbai
ND50 T Prashad 122-K, SDA New Delhi

Table: RECIPIENT
RecID SenderID RecName RecAddress RecCity
KO05 ND01 R Bajpayee 5, Central Avenue Kolkata
ND08 MU02 S Mahajan 116, A Vihar New Delhi
MU19 ND01 H Singh 2A, Andheri West Mumbai
MU32 MU15 P K Swamy B5, C S Terminus Mumbai
ND48 ND50 S Tripathy 13, B1 D, Mayur Vihar New Delhi

(i) SELECT DISTINCT SenderCity FROM Sender;

6
(ii) SELECT A.SenderName, B.RecName FROM Sender A, Recipient B WHERE
A.SenderID = B.SenderID AND B.RecCity = 'Mumbai';
(iii) SELECT RecName, RecAddress FROM Recipient WHERE RecCity NOT IN
("Mumbai', 'Kolkata');
(iv) SELECT RecID, RecName FROM Recipient WHERE SenderID = 'MU02' OR
SenderID = 'ND50';
29. Write a Python function SwitchOver(Val) to swap the even and odd positions of the 3
values in the list Val.

Note : Assuming that the list has even number of values in it.

For example :
If the list Numbers contain
[25,17,19,13,12,15]

After swapping the list content should be displayed as


[17,25,13,19,15,12]
30. Write the definition of a user defined function PushNV(N) which accepts a list of 3
strings in the parameters N and pushes all strings which have no vowels present in it,
into a list named NoVowel.

Write a program in python to input 5 words and push them one by one into a list
named All.

The program should then use the function PushNV() to create a stack of words in the
list NoVowel so that it stores only those words which do not have any vowels in it,
from the list All.

Thereafter , pop each word from the list NoVowel and display the message
“EmptyStack”

For example:

If the words accepted and pushed into the list All are

[‘DRY’,’LIKE’,’RHYTHM’,’WORK’,’GYM’]

Then the stack NoVowel should store


[‘DRY’,’RHYTHM’,’GYM’]

And the output should be displayed as

GYM RHYTHM DRY EmptyStack

OR

Write the definition of a user defined function Push3_5(N) which accepts a list of
integers in a parameter N and pushes all those integers which are divisible by 3 or

7
divisible by 5 from the list N into a list named Only3_5.

Write a program in Python to input 5 integers into a list named NUM.

The program should then use the function Push 3_5() to create the stack of the list
Only3_5. Thereafter pop each integer from the list Only3 5 and display the popped
value. When the list is empty, display the message "StackEmpty".

For example:

If the integers input into the list NUM are:

[10, 6, 14, 18, 301

Then the stack Only3 5 should store

[10, 6, 18, 301

And the output should be displayed as

30 18 6 10 StackEmpty

31. Piccadily Design and Training Institute is setting up its centre in Jodhpur with four 5
specialised units for Design, Media, HR and Training in separate buildings. The
physical distances between these units and the number of computers to be installed
in these units are given as follows.
You as a network expert, have to answer the queries as raised by the administrator
as given in (i) to (iv).
Shortest distances between various locations in metres :

Design Unit to Media Unit 60


Design Unit to HR Unit 40
Design Unit to Training Unit 60
Media Unit to Training Unit 100
Media Unit to HR Unit 50
Training Unit to HR Unit 60
Number of computers installed at various locations are as follows :

Design Unit 40
Media Unit 50
HR Unit 110
Training Unit 40

8
i) Suggest the most suitable location to install the main server of this institution to
get efficient connectivity.
(ii) Suggest by drawing the best cable layout for effective network connectivity of the
building having server with all the other units.
(iii) Suggest the devices to be installed in each of these buildings for connecting
computers installed within each of the units out of the following :
Modem, Switch, Gateway, Router
(iv) Suggest an efficient as well as economic wired medium to be used within each
unit for connecting computer systems out of the following network cable :
Co-axial Cable, Ethernet Cable, Single Pair Telephone Cable.
(v) Suggest a protocol that shall be needed to provide Video Conferencing solution
between Jodhpur and HQ which is situated in Delhi.

32. (a) Write the output of the code given below: 2+3

def ChangeVal(M,N):
for i in range(N):
if M[i]%5 == 0:
M[i] //= 5
if M[i]%3 == 0:
M[i] //= 3
L=[25,8,75,12]
ChangeVal(L,4)
for i in L :
print(i, end='#')

(b) The code given below is trying to delete the record of table category of
database items that have the name = ‘Stockable’

Note the following to establish connectivity between Python and MYSQL:


Username is learner
Password is fast

Write the following missing statements to complete the code:


Statement 1 – to form the cursor object
Statement 2 – to delete the records as mentioned in the question
Statement 3- to save the changes permanently in the database

import mysql.connector as ms

9
db1 =
ms.connect(host=’localhost’,user=’learner’,passwd=’fast’,database=’items’)
cur = _ #Statement 1
sql = ‘DELETE ’ #Statement 2
cur.execute(sql)
#Statement 3
print(‘Data Updated successfully’)

OR
(a) Find the output of the following code:

Name="PythoN3.1"
R=""
for x in range(len(Name)):
if Name[x].isupper():
R=R+Name[x].lower()
elif Name[x].islower():
R=R+Name[x].upper()
elif Name[x].isdigit():
R=R+Name[x-1]
else:
R=R+"#"
print(R)

(b) The code given below reads the following record from the table named
teacher and displays only those records whose year of retirement is in 2022.

empcode – integer
Name – string
post – integer
dateofretire – integer
Note the following to establish connectivity between Python and MYSQL:
Username is root
Password is kvs
The table exists in a MYSQL database named school.

Write the following missing statements to complete the code:


Statement 1 – to import the required modules and give alias as ms
Statement 2 – to execute the query that extracts records of those teachers whose
year of retirement is 2022. Consider the date format to be ‘YYYY-MM-DD’
Statement 3- to fetch all the data from the cursor instance

import as #Statement 1
con1=ms.connect(host="localhost",user="root",password="kvs", database="school")
mycursor= con1.cursor()
print("Teachers about to retire in 2022 are: ")
#Statement 2
data= #Statement 3
for i in data:
print(i)
print()
33. What is the difference between ‘w’ and ‘a’ file modes used in the open() function? 5
Write a program in python that defines and calls the following user defined

10
functions:
(I) addCsvFile(UserName,Password) – To accept and add the login details of a
user into the CSV file ‘login.csv’. Each record consist of a list with field
elements as [id,pass] to store Username and password respectively.
(II) checkDetails(username,pass) – To check the login details passed to the
finction from the file. If the details are correct the function returns True
otherwise it returns False.

OR

Name the methods used to read and write the data in a binary file.

Write a program in python that defines and calls the following user defined
functions:
(i) insertData() – To accept and add data of a customer and add it to a csv file
‘customerData.csv’. Each record should contain a list consisting
customername,mobileno,dateofPurchase,itempurchased.
(ii) frequency (name) – To accept the name of a customer and search how
many times the customer has purchased any item. The count and return
the number.
SECTION E
34 Consider the following table HOSPITAL. Answer the questions that follows the table:

Table: HOSPITAL
No. Name Age Department Dateofadm Charges Sex
1 Arpit 62 Surgery 21/01/98 3000 M
2 Zarina 22 ENT 12/12/97 2000 F
3 Kareem 32 Orthopaedic 19/02/98 1500 M
4 Arun 12 Surgery 11/01/98 3000 M
5 Zubin 30 ENT 12/01/98 1500 F
6 Ketaki 16 ENT 24/02/98 2000 M
7 Ankita 29 Cardiology 20/02/98 10000 F
8 Zareen 45 Cardiology 14/07/99 1400 F
9 Kushi 19 Gynaecology 20/01/22 1800 F
10 Shilpa 23 Nuclear 19/05/22 2500 F
Medicine

Based on the data given above answer the following questions:


(i) Identify the columns which can be considered as candidate keys.
(ii) What is the degree and cardinality of the above table.
(iii) Write the statements to:
(a) Delete the record where the Name starts with ‘Z’
(b) Modify the Charges of Ankita from 10000 to 1000.
OR
(iii) Write the statements to:
(a) To check the structure of the given table.
(b) To increase the age of everyone by 2 years.
35 Sunil is a Python programmer. He has written the following incomplete code, which

11
takes a students details (rollnumber,name

import pickle

sturno = int(input("Enter roll number :"))


stuname = input("Enter name:")
stumarks = float(input("Enter marks :"))
Stul = {"RollNo. ":sturno, "Name": stuname, "Marks":stumarks}

with as fh: # Fill_Line 1

# Fill_Line 2

as fin: #Fill_Line 3

#Fill_Line 4
print(Rstu)

if Rstu["Marks"] >= 85:


print("Eligible for merit certificate")
else:
print("Not eligible for merit certificate")

Help Sunil to complete the code as per the following instructions.

(a) Complete Fill_Line1 so that the mentioned binary file is opened for writing in
fh object using a with statement.
(b) Complete Fill Line2 so that the dictionary Stul's contents are written on the
file opened in step (a).
(c) Complete Fill_Line3 so that the earlier created binary file is opened for
reading in a file object namely fin, using a with statement.
(d) Complete Fill_Line4 so that the contents of open file in fin are read into a
dictionary namely Rstu.

12

You might also like