Write a function in PYTHON to search for the details (Number and Calls) of those mobile phones which have more than 1000 calls from a binary file “mobile.dat”. Assuming that this binary file contains records of the following type:(Number,calls)
Answers
Answered by
3
Language:
Python
Program:
def search():
import pickle
file=open('mobile.dat', 'br')
read=pickle.load(file)
pno=int(input("Enter the ph0ne number: "))
found=0
for i in read:
if i[0]>100:
print(i)
found=1
else:
found=0
if found==0:
print("No such record found.")
file.close()
search()
Explanation:
- pickle performs functions on binary files load method from there read files.
- And search for the records that satisfy the given conditions and print their details on the screen.
Similar questions
Math,
4 months ago
Social Sciences,
4 months ago
Biology,
4 months ago
Computer Science,
9 months ago
Social Sciences,
1 year ago