From 42c6b97062133615720140f4d221dce6c28be32a Mon Sep 17 00:00:00 2001 From: PShivani07 <31812153+PShivani07@users.noreply.github.com> Date: Thu, 24 May 2018 02:42:55 +0530 Subject: [PATCH] Create assignment_4 --- .../Week-4/ShivaniP/assignment_4 | 35 +++++++++++++++++++ 1 file changed, 35 insertions(+) create mode 100644 Introduction-to-Data-Science/Week-4/ShivaniP/assignment_4 diff --git a/Introduction-to-Data-Science/Week-4/ShivaniP/assignment_4 b/Introduction-to-Data-Science/Week-4/ShivaniP/assignment_4 new file mode 100644 index 0000000..92682f5 --- /dev/null +++ b/Introduction-to-Data-Science/Week-4/ShivaniP/assignment_4 @@ -0,0 +1,35 @@ +1.ab+ mode opens a file for appending and reading in binary format.The file pointer is at the end of the file. + +2.While reading the file, the data in the file is transfered in an intermediate buffer before it is accessed by +python.This buffer signifies the size of the buffer used. + +3. + try: + a=1/0 #ZeroDivisionError + fh=open("python.txt",r) + fh.readline() #IOError + b=12 + if(b>0) + print("greater than zero") #IndentationError + if(c>b) + print("c greater than b") #NameError + except IOError: + print("file not found!!!") + except ZeroDivisionError: + print("division by zero!!") + except NameError: + print("identifier not found!!!") + +4. +file=open("file.txt",r+) +list=[] +file.seek(0,2) +pos=file.tell() +k=0 +file.seek(0,0) +while k!=pos: + list.append(file.readline()) + k=file.tell() +file.close() +for i in range(len(list),0,-1): + print(list[i])