PYQs On Binary File Qs 23 March
PYQs On Binary File Qs 23 March
https://www.youtube.com/@TECHQueenLovejeetArora
Follow for more
Explanation of this Lecture Binary File PYQs
https://www.youtube.com/watch?v=ByIbaVHSxvM
import pickle
def Write():
File1=open("Sport.dat","wb")
NestedList=[]
while True:
SportName=input("Enter Sport Name")
TeamName=input("Enter Team Name")
No_Players=int(input("Enter No of Players"))
List=[SportName,TeamName,No_Players]
NestedList.append(List)
Ch=input("For More Enter y or Y")
if Ch not in "Yy":
break
pickle.dump(NestedList,File1)
File1.close()
#Write()
def CopyData():
File1=open("Sport.dat","rb")
File2=open("Basket.dat","wb")
Data=pickle.load(File1)
Count=0
for i in Data:
if i[0]=="BasketBall":
pickle.dump(i,File2)
Count+=1
return Count
#print("Total No of Copies",CopyData())
def Read():
File=open("Basket.dat","rb")
try:
while True:
Data=pickle.load(File)
print(Data)
except:
File.close()
Read()
Binary File PYQs
https://www.youtube.com/@TECHQueenLovejeetArora
Follow for more
Explanation of this Lecture Binary File PYQs
https://www.youtube.com/watch?v=ByIbaVHSxvM
import pickle
def Write():
File=open("BiFile.dat","wb")
Dict={}
while True:
MNO=int(input("Enter Movie No."))
MNAME=input("Movie Name")
MType=input("Movie")
Dict[MNO]=[MNAME,MType]
Ch=input("Enter More Y/y")
if Ch not in "Yy":
break
pickle.dump(Dict,File)
File.close()
def Read():
File=open("BiFile.dat","rb")
Data=pickle.load(File)
for i in Data:
print(Data[i][1])
#Write()
Read()
Binary File PYQs
https://www.youtube.com/@TECHQueenLovejeetArora
Follow for more
Explanation of this Lecture Binary File PYQs
https://www.youtube.com/watch?v=ByIbaVHSxvM
import pickle
def WriteRec():
File=open("BiFile.dat","wb")
#ID,Name,Price
while True:
ID=int(input("Enter ID"))
Name=input("Enter Name")
Price=int(input("Enter Price"))
List=[ID,Name,Price]
pickle.dump(List,File)
ch=input("Enter Y/y for Data -")
if ch not in "Yy":
break
File.close()
def ShowHigh():
File=open("BiFile.dat","rb")
try:
while True:
Data=pickle.load(File)
if Data[2]>500:
print(Data)
except:
File.close()
WriteRec()
ShowHigh()