Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Assignment 4 #85

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
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
38 changes: 38 additions & 0 deletions Introduction-to-Data-Science/Week 4/Ramanan/Assignment4
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
A1)
ab+ 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.



A2)
In python, buffering is helpful when the retrieving data 4part takes more time than it is supposed to. Then, it is better to load of a huge packet of data into the buffer and retrieve data from it whenever needed.



A3)
try:
a = 1/0
c = '@'
print(a)
print(int(c))
except ValueError as e:
print("Error:",e)
except ZeroDivionError as e:
print("Error:",e)
finally:
print("This is the end")



A4)
f = open('text','r')
s = []
while True:
try:
s.append(f.readline())
except:
break
f.close()
p = open('output','w')
for i in range(len(s)-1,-1,-1):
p.write(s[i])
p.close()