Write a program to create a binary file with name and roll number. Search for a given roll
number and display the name, if not found display appropriate
message.
Answers
Answered by
2
Answer:
good night
Explanation:
have a peaceful and relaxing sleep
Answered by
9
Answer:
x={}
def make_file(x):
o=open("new_file.dat","wb")
import pickle as p
xx=int(input("How many values you want to input="))
for i in range(xx):
y=int(input("Enter roll_no="))
z=input("Enter name=")
x.update({y:z})
print()
p.dump(x,o)
o.close()
return x
def file_search():
o=open("new_file.dat","rb")
import pickle as p
k=p.load(o)
d=input("enter the roll no=")
if d not in k:
print("Invalid roll number")
else:
print(a[d])
a=make_file(x)
file_search()
Explanation:
This should do the trick,
Cs practical is a pain isn't it?
Similar questions