Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
1. Opens a file for both appending and reading in binary format. The file pointer is at the end of the file if the file exists. The file opens in the append mode. If the file does not exist, it creates a new file for reading and writing.
2. While reading the file, the data in the file is transfered in an intermediate buffer before it is accessed by python.This buffer parameter signifies the size of the buffer used.
12 changes: 12 additions & 0 deletions Introduction-to-Data-Science/Week-3/Animesh Kumar/error.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
try:
print("Hi")
a=1/0
f= open("text1.txt",'r')
print(f.readline())
t='s'+1
except ZeroDivisionError:
print("Zero Error")
except TypeError:
print("Type Error")
except NameError:
print("Name Error")
18 changes: 18 additions & 0 deletions Introduction-to-Data-Science/Week-3/Animesh Kumar/reverse_file.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
import os
f= open("text1.txt",'w+')
f.write("Hello\nI\nAm playing")
f.seek(0,0)
print(f.readlines())
f.close()
fp= open("text1.txt",'r')
k= fp.readlines()
fp.close()
k=k[::-1]
k[0]=k[0]+"\n"
k[-1]=k[-1][:-1]
fm= open("text1.txt",'w+')
for t in k:
fm.write(t)
fm.seek(0,0)
print(fm.readlines())
fm.close()