Skip to content

Commit

Permalink
Merge pull request ambujraj#30 from ahmadjaved97/master
Browse files Browse the repository at this point in the history
Added bubble_sort.py
  • Loading branch information
ambujraj authored Oct 1, 2018
2 parents 35f6856 + 13a8b55 commit 4c6a27d
Show file tree
Hide file tree
Showing 2 changed files with 34 additions and 0 deletions.
16 changes: 16 additions & 0 deletions fibonacci/fibonacci.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
print('Enter the number of terms: ')
num = int(input())

alist = []

for i in range(0, num):
if(i == 0):
alist.append(0)
elif(i == 1):
alist.append(1)
else:
alist.append(alist[i - 1] + alist[i - 2])

print('The fibonnaci series is: ')
for i in range(num):
print(alist[i], end = ' ')
18 changes: 18 additions & 0 deletions sorting/bubble_sort.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
def bubbleSort(alist):
for passnum in range(len(alist)-1, 0, -1):
for i in range(passnum):
if alist[i] > alist[i+ 1]:
alist[i], alist[i+1] = alist[i+1], alist[i]


alist = []
print('Enter the elements to be sorted: ')
alist = list(map(int,input().split()))

bubbleSort(alist)

print('Sorted list is: ')

for i in range(len(alist)):
print(alist[i], end = ' ')

0 comments on commit 4c6a27d

Please sign in to comment.