0% found this document useful (0 votes)
3 views3 pages

Program 2

The document contains two Python programs. The first program allows users to create, display, and update student records using pickle for serialization. The second program generates and prints Fibonacci numbers based on user input for the number of elements.

Uploaded by

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

Program 2

The document contains two Python programs. The first program allows users to create, display, and update student records using pickle for serialization. The second program generates and prints Fibonacci numbers based on user input for the number of elements.

Uploaded by

nirupamasivarama
Copyright
© All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd

REG NO.

20638000
#PROGRAM 1
import pickle
def create():
f=open(r"C:\Users\CSC LAB-27\Downloads\[Link]","wb")
n=int(input("Enter no. of records to be added:"))
l=[]
for i in range(n):
name=input("Enter name:")
rollno=int(input("Enter roll number:"))
mark=int(input("Enter marks:"))
rec=[name,rollno,mark]
[Link](rec)
[Link](l,f)
[Link]()

def display():
f=open(r"C:\Users\CSC LAB-27\Downloads\[Link]","rb")
try:
while True:
a=[Link](f)
for i in a:
print(i)
except:
[Link]()

def update():
f=open(r"C:\Users\CSC LAB-27\Downloads\[Link]","rb+")
n=int(input("Enter roll no. to be updated:"))
found=0
try:
while True:
a=[Link](f)
for i in a :
if i[1]==n:
found=1
i[2]=i[2]+10
if found == 0:
print("Not found")
else:
[Link](0)
[Link](a,f)
except:
[Link]()
create()
display()
update()
display()

OUTPUT:
=== RESTART: C:/Users/CSC LAB-27/Downloads/[Link] ===
Enter no. of records to be added:3
Enter name:GOKUL
Enter roll number:01
Enter marks:90
Enter name:SANJAY
Enter roll number:02
Enter marks:87
Enter name:ARJUN
Enter roll number:03
Enter marks:96
['GOKUL', 1, 90]
['SANJAY', 2, 87]
['ARJUN', 3, 96]
Enter roll no. to be updated:01
['GOKUL', 1, 100]
['SANJAY', 2, 87]
['ARJUN', 3, 96]

#PROGRAM 2
n=int(input("Enter no of elements:"))
a=0
b=1
print(a,b,end=" ")
for i in range (n):
t=a+b
print(t,end=" ")
a=b
b=t

OUTPUT:
=== RESTART: C:/Users/CSC LAB-27/Downloads/[Link] ===
Enter no of elements:10
0 1 1 2 3 5 8 13 21 34 55 89

You might also like