0% found this document useful (0 votes)
4 views2 pages

File Program

The document provides a Python program to create a student file containing roll number, name, and total marks. It reads the file, calculates the result for each student, and displays the records in a tabular format. The program also suggests creating similar programs for other entities like Books and Employees.
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
4 views2 pages

File Program

The document provides a Python program to create a student file containing roll number, name, and total marks. It reads the file, calculates the result for each student, and displays the records in a tabular format. The program also suggests creating similar programs for other entities like Books and Employees.
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd

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.

You might also like