0% found this document useful (0 votes)
33 views1 page

Student 1

The document contains Python code to add and display student records stored in a binary file using pickle. The code prompts the user to input student details and stores them as a list that is pickled and written to a file. It then reads the pickled data from the file and displays the student records.

Uploaded by

PREJAN RAJA
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as TXT, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
33 views1 page

Student 1

The document contains Python code to add and display student records stored in a binary file using pickle. The code prompts the user to input student details and stores them as a list that is pickled and written to a file. It then reads the pickled data from the file and displays the student records.

Uploaded by

PREJAN RAJA
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as TXT, PDF, TXT or read online on Scribd
You are on page 1/ 1

import pickle

def get_input():
with open("Student_details.dat",'wb') as f:
print("Opened file - Student details")
for i in range(100):
print("-",end="")
print()
choice=""
choice=str(input("Do you want to add details? y/n : "))
while choice=="y" :
ID=int(input("Enter student ID : "))
name=str(input("Enter student name : "))
DOB=str(input("Enter date of birth : "))
gender=str(input("Enter gender : "))
dept=str(input("Enter department : "))
fname=str(input("Enter Father's name : "))
mname=str(input("Enter Mother's name : "))
bg=str(input("Enter Blood Group : "))
aadhar=int(input("Enter Aadhar number : "))
address=str(input("Enter Address : "))
contact=int(input("Enter Phone number : "))
rec=[ID,name,DOB,gender,dept,fname,mname,bg,aadhar,address,contact]
pickle.dump(rec,f)
print("Record inserted successfully.....")
choice=str(input("Do you want to add details? y/n : "))
def display_output():
L1=[]
f1=open("Student_details.dat",'rb')
while True:
try:
data=pickle.load(f1)
print(data)
except EOFError:
break
f1.close()
def line():
for i in range(100):
print("-",end="")
print()

#Main Program
get_input()
line()
display_output()
line()
print("Thank you.......")
7:09 PM 15-Sep-21

You might also like

pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy