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

session5 #94

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
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
11 changes: 11 additions & 0 deletions Introduction-to-Data-Science/Session-5/aakash_singh/q3.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
try:
n=int(input('enter a number: '))
except ValueError:
print('please try again and input a number')
exit()

try:
print(100/n)
except ZeroDivisionError:
print('cant divide by zero')
exit()
12 changes: 12 additions & 0 deletions Introduction-to-Data-Science/Session-5/aakash_singh/q4.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
import sys

try:
file = open(sys.argv[1],'r')
except:
print('file doesnt exist')
exit()

lines=file.read().split('\n')
file.close()
for line in lines[::-1]:
print(line.strip())
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
q1:
ab+ mode expands to append binary read and write.
The file at default opens with cursor at EOF in binary mode and can be read or written to.

q2.
buffering means that python is not directly interfacing with the OS's representation of a file or its file system.
Instead only a chunk of data is read from the raw OS filestream into a buffer.