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_week4 #84

Open
wants to merge 2 commits 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
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
hello
i
am
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
babe
hel
23 changes: 23 additions & 0 deletions Introduction-to-Data-Science/Week-4/Prajwal/reversing/reverse.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
file=open("input.txt",'r+')
last=file.seek(0,2)
lis=[0]
ctr=0
file.seek(0,0)
i=0
while i<last:
file.readline()
i=file.tell()
lis.append(i)
ctr+=1
f=open("output.txt",'w+')
dummy=ctr
for i in range(dummy,0,-1):
file.seek(lis[i-1],0)
print(file.readline(),end="")
# below code is for writing it on another file called output
file.seek(lis[i-1],0)
f.write(file.readline())

file.close()
f.close()

13 changes: 13 additions & 0 deletions Introduction-to-Data-Science/Week-4/Prajwal/theory5.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
ab+ mode opens the file for appending and reading in binary format.If the file exists , it opens in append mode and file pointer is at the end of the file. If the file does not exist, it creates a new file for reading and writing.

when a file is read, data is transferred to an intermediate buffer before it can be accessed by python, therefore buffer parameter signifies the size in bytes of the buffer used while reading. -ve value indicates default buffer size, 0 indicates no buffering.

try:
print(1/0)
except ZeroDivisionError:
print("Number cannot be divided by zero")
try:
print(1+"a")
except :
print("cannot combine different data type with + in print function")

12 changes: 12 additions & 0 deletions prajwalsb/Week-2/PrajwalSB/alternate.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
n= int(input("Enter: "))
lists=[]
for i in range(0,n):
x=int(input())
lists.append(x)
print(len(lists))
print("original list")
print(lists)
print("new list")
for i in range(1,n,2):
del lists[(i+1)//2]
print(lists)
18 changes: 18 additions & 0 deletions prajwalsb/Week-2/PrajwalSB/pattern.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
n= int(input("Enter: "))
for i in range(1,(n+1)):
for j in range(n,i,-1):
print(" ",end="")
for k in range(1,i):
print("* ",end="")
for l in range(0,i):
print("* ",end="")
print()

for i in range(n-1,0,-1):
for j in range(0,n-i):
print(" ",end="")
for k in range(1,(i*2)):
print("* ",end="")
print()


14 changes: 14 additions & 0 deletions prajwalsb/Week-2/PrajwalSB/sort.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
n= int(input("Enter: "))
lists=[]
for i in range(0,n):
x=int(input())
lists.append(x)

for i in range(0,n-1):
for j in range(0,n-1-i):
if lists[j] > lists[j+1]:
temp =lists[j]
lists[j]=lists[j+1]
lists[j+1]=temp

print(lists)
17 changes: 17 additions & 0 deletions prajwalsb/Week-2/PrajwalSB/theory.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
Pros of python--
easy to write the source code when compared with other languages.
easily readable and understandable for a non-programmer.
has a rich built-in and open source library
useful for asynchronous codes.

Cons of python---
since its an interpreted language, its slower than many other languages
it isn't used much in web browser and mobile computing
Because the language is dynamically typed, it requires more testing and has errors

The exponential operator has the highest priority in expression.

// is called floor division operator.division that results into whole number adjusted to the left in the number line
ex: 5//3 will give 1 , 5/3 will give 1.6666667
6//3 will give 2, 6/3 will give 2.0