81ebe (2)
81ebe (2)
of online class
• Keep your microphone and video on mute so that
there are no disturbances
• Please use chat to ask queries/ answer questions
when prompted
• As far as possible try to use laptop/pc
• The students must leave the group once the session
is over. Please do not use this platform for personal
chat/groups
DEEPSHIKHA SETHI ----XII COMPUTER SCIENCE ---- AIS MAYUR VIHAR
Handling delimited files using readlines()
Task: To use the same file and find the student having highest
marks f=open("Marks.txt",'r')
a=f.readlines()
a=a[1:]
print(a)
high=0
for i in a:
i=i.rstrip('\n')
i=i.split(',')
print(i)
marks=int(i[2])
print(marks)
if (marks>high): #Type error: '>' not supported between instances of 'int' and 'str'
high=marks
name=i[1]
print(name,high)
f.close()
2. os.path.abspath(filename) will give us the complete path name of the data file.
4. os.remove(<filename>) will delete the file. Here filename has to be the complete
path of file.
5. os.rename(“Old file name”,”New file name”) will change the name of filename1
with filename2.
DEEPSHIKHA SETHI ----XII COMPUTER SCIENCE ---- AIS MAYUR VIHAR
DEEPSHIKHA SETHI ----XII COMPUTER SCIENCE ---- AIS MAYUR VIHAR
Usage of Rename() and Remove () Method
count=count+1
Enter nameDeepak
12 Hazel 67.75
15 Jiya 78.5
16 Noor 68.9
17 Akshra 78.9
18 Naksh 78.0