Program 13
Program 13
import pickle
def createfile():
f=open(“Book.dat”, “wb”)
while True:
num=int(input (“Enter book numbers:-”))
name=input (“Enter book name:-”)
aut=input (“Enter author:-”)
pri=float (input (“Enter price of book:-”))
list=[num,name,aut,pri]
pickle.dump(lst,f)
choice=input (“for exit (Enter exit):-”)
Print ()
if choice==“exit” or choice==“Exit”:
print (“Thank you ”)
print ()
break
f.close()
def count Rec():
f=open(“Book.dat” , “rb”)
count=0
try:
while True:
data=pickle.load(f)
if data [2]==aut:
count+=1
except EOFError:
f.close()
Print (“Number of book with author name” , aut,“=”,count)
Create file()
Print (“for searching-”)
aut =input (“Enter Author:-”)
countRec(aut)
OUTPUT:
PROGRAM 10:
Ques10: write a function in python to create the text
file