Write a python program to sort a list using Bubble Sort

Tech Programmer
1

WRITE A PYTHON PROGRAM TO PERFORM BUBBLE SORT TO SORT A DEFINED LIST


CODE FOR THE ABOVE  PYTHON  PROGRAM :


def bubbleSort(list):
    for i in range(len(list)-1,0,-1):
        for i in range(i):
            if list[i]>list[i+1]:
                temp = list[i]
                list[i] = list[i+1]
                list[i+1] = temp

list = [69,76,13,52,98,22,56]
bubbleSort(list)
print("\n The new Sorted list is : ",list,"\n")


WRITTEN CODE FOR THE ABOVE PROGRAM :


def bubbleSort(list):

    for i in range(len(list)-1,0,-1):

        for i in range(i):

            if list[i]>list[i+1]:

                temp = list[i]

                list[i] = list[i+1]

                list[i+1] = temp


list = [69,76,13,52,98,22,56]

bubbleSort(list)

print("\n The new Sorted list is : ",list,"\n")


OUTPUT :



Post a Comment

1Comments
  1. my class teacher gave me this topic, this program really helped me to complete my work thank you.

    ReplyDelete
Post a Comment

Featured Highlighted Categories

You'll discover all of the most up-to-date bring innovative here.

Python List theory with List Programs
Get complete python lists theory and list basic and insane programs for your practice.
CBSE SAMPLE PAPERS
Get CBSE sample and question papers of last 7 years with answers to get best practice for your Board Exams
Python String theory and String Programs
Python strings complete theory with illustrations and practice programs for free