7th 8th and 9th Paper
7th 8th and 9th Paper
7th 8th and 9th Paper
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
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
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
a) Repeater b) Hub/Switch
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
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()
SECTION A
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:])
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.
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
(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
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:
OR
For example :
If the content of the file is
ME AND MY FRIENDS
ENSURE SAFETY AND SECURITY OF EVERYONE
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
7
P.TNO AND AGE BETWEEN 40 AND 50;
[“Danish”,80,”Maths”]
[“Hazik”,79,”CS”]
[“Parnik”,95,”Bio”]
[“Danish”,70,”CS”]
[“Sidhi”,99,”CS”]
[“Hazik”,”79”]
[“Sidhi”,”99”]
Stack Empty
OR
Employee ={"Sohan”:20000,”Mohan”:9000,”Rohan”:25000,”Aman”:5000}
The stack should contain
Mohan
Aman
Pediatrics Unit 40
Administrative Office 140
Neurology 50
Orthopedics Unit 80
ADMINSISTRATIVE OFFICE
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
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
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 = ' # ')
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
OR
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
(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’
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
(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
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.
OR
For example :
If the content of the file is
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
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]
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’]
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.
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:
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 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’
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.
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
11
takes a students details (rollnumber,name
import pickle
# Fill_Line 2
as fin: #Fill_Line 3
#Fill_Line 4
print(Rstu)
(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