Skip to content

PR to main repository #116

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

Merged
merged 3 commits into from
May 21, 2018
Merged
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
3 changes: 2 additions & 1 deletion CONTRIBUTORS.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,4 +3,5 @@ Nicole Mazzuca
Marius Becker
Gathros
Jeremie Gillet (- Jie -)
Salim Khatib
Salim Khatib
Hitesh C
23 changes: 23 additions & 0 deletions chapters/sorting_searching/bubble/code/python/bubblesort.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
#!usr/bin/python3

#import section
import random


def bubble_sort(array):
len_array = len(array)
for i in range(len_array):
for j in range(len_array - i - 1):
if(array[j] > array[j+1]):
array[j], array[j+1] = array[j+1], array[j] #swap elements in the list


def main():
number = [random.randint(0, 10000) for _ in range(10)]
print("Before Sorting {}".format(number))
bubble_sort(number)
print("After Sorting {}".format(number))


if __name__ == "__main__":
main()