WAP to create a student file with – rollno, name and total marks.
Read
the file and calculate result of the students and display the records as a
table on screen.
n = int( input (" How many student records you want to store :"))
fl = open("[Link]", "w" )
for i in range(n) :
rno = int(input("enter rollno :"))
nm = input("enter name :")
tot = float(input ("enter total marks :"))
rec = str(rno)+ " " + nm + " " + str (tot) + '\n'
[Link](rec)
[Link]()
fl = open( "[Link]" , "r")
rec = " "
print("Rno \t name \t\t total \t result ")
while rec :
rec = [Link]()
rt = [Link]() # create a list from record
if len(rt) != 0 :
if float(rt[2] ) >= 0 :
res = "Pass"
else :
res = “Fail”
print( rt[0] ,"\t" , rt[1], "\t\t", rt[2], "\t" , res)
[Link]()
output of the program :
Contents of the file :
Now write similar program for the text files created by you for
storing details of Books, Employees etc. in the class.
Please see the indentation of the blocks properly.