Write a program in a create a binary file
“[Link]” having four field
(empid, empname, salary, age) and contain
following data.
E01 ROHIT 50000 34
E02 MANAS 60000 27
E04 VINAY 65000 40
import pickle
r=[]
n=int(input(“Enter number of employee”))
for I in range(n):
empid=input("Enter Emp id")
empname=input("Enter name")
salary=int(input("Enter salary"))
age=int(input("enter age"))
data=[empid,empname,salary,age]
[Link](data)
f=open("[Link]","wb")
[Link](r,f)
print("Record added")
[Link]()
Write a program to display the record of
those employee from the binary file
“[Link]” whose name is starting
with ‘M’.
import pickle
f=open("[Link]","rb")
s=[Link](f)
found=0
for R in s:
if R[1][0]=='M':
print(R[0],R[1],R[2],R[3])
found+=1
if found==0:
print(“Not found")
[Link]()
Write a program to increase the salary by
10% for those employee whose salary is
more than 58000 from a binary file
“[Link]”.
import pickle
f=open("[Link]","rb")
s=[Link](f)
found=0
for R in s:
if R[2]>=58000 :
R[2]=1.1*R[2]
found+=1
[Link]()
f=open("[Link]",“wb")
if found>0:
[Link](0)
[Link](s,f)
print("salary updated")
[Link]()
Write a program to delete those record of
employee from a binary file “[Link]”
whose salary is less than 55000.
import pickle
f=open("[Link]","rb")
s=[Link](f)
found=0
for R in s:
if R[2]>55000:
[Link](R)
found+=1
f=open("[Link]",“wb")
if found>0:
[Link](0)
[Link](s,f)
print(“Record deleted")
[Link]()