PYTHON | WRITE TO DATA FILE | STORE STUDENT IN BINARY FILE.

n=int(input("How many records you want to enter: "))
fout = open(r"D:\Marks.dat","w")

for i in range(n):
    print("Enter details of student-",i+1,"below")
    rollno=int(input("Roll No.:"))
    name=input("Name:")
    marks=float(input("Marks:"))
    rec=str(rollno)+","+name+","+str(marks)+"\n"
    fout.write(rec)
fout.close()
print("Data saved to file successfully....")

No comments

Post your comments

Powered by Blogger.