Python Program for Bubble Sort

Bubble sort is one of the simplest sorting technique to sort the data items.

#Python Bubble Sort Program using Function
def bubble(arr):
    length=len(arr)
    for i in range(length):
        for j in range(0,length-i-1):
            if arr[j]>arr[j+1]:
                temp=arr[j]
                arr[j]=arr[j+1]
                arr[j+1]=temp

arr=[50,40,30,10,60]
bubble(arr)
print("the sorted list is:")
for i in range(len(arr)):
    print(arr[i])
Output

the sorted list is:
10
30
40
50
60




About the Author



Silan Software is one of the India's leading provider of offline & online training for Java, Python, AI (Machine Learning, Deep Learning), Data Science, Software Development & many more emerging Technologies.

We provide Academic Training || Industrial Training || Corporate Training || Internship || Java || Python || AI using Python || Data Science etc






 PreviousNext