Class 12th CBSE
Create a binary file with name and roll number of student and display the data by reading the file.
Solution: –
import pickle def writedata( ): list =[ ] while True: roll = input("Enter student Roll No:") sname = input("Enter student Name :") student = {"roll":roll,"name":sname} list.append(student) choice= input("Want to add more record(y/n) :") if(choice=='n'): break file = open("student.dat","wb") pickle.dump(list,file) file.close( ) def readdata( ): file = open("student.dat", "rb") list = pickle.load(file) print(list) file.close( ) print("Press-1 to write data and Press-2 to read data") choice=int(input( )) if choice==1: writedata( ) elif choice==2: readdata( ) else: print("You entered invalid value")

Fun & Easy to follow

Works on all devices

Your own Pace

Super Affordable
Popular Videos

UX for Teams
Learn the basics and a bit beyond to improve your backend dev skills.

Chris Matthews
Designer

SEO & Instagram
Learn the basics and a bit beyond to improve your backend dev skills.

Chris Matthews
Designer