Python.

Bubble Sort Code

my_list = [9,65,5,12,13,8,45,62,34,67]
def bubble():
swapped=True
l=len(my_list)
while swapped == True:
swapped=False
for n in range(l-1):
print(n, l, my_list,swapped)
if my_list[n] > my_list[n+1]:
temp=my_list[n]
my_list[n]=my_list[n+1]
my_list[n+1]=temp
swapped = True
bubble()
print (my_list)

 

 

Bubble Sort Flowchart.


 

 

 

 

 

 

 

 

 

 

 

 

 


 

Set  Swapped flag to True.

 Bubble Sort Procedure
 

 

 

 

 

Teaching Ideas.
Agbonline Teaching Exercises.
Using python.com
20 code Challenges( complete for GCSE 9-1 )
Python Exercises.
Introduction to Python
Python exercises