Run Code
|
API
|
Code Wall
|
Misc
|
Feedback
|
Login
|
Theme
|
Privacy
|
Patreon
HW Descending order
#python 3.5.2 print ("Hello, world!") def bubbleSort(alist): length = len(alist) for passnumber in range(0, length): # number of passes = N - 1 print ('Passnumber: ', passnumber) for i in range((length-1) ,0,-1 ): # loop for bubbles print ('Possible values for i:',i) if alist[i] > alist[i-1]: temp = alist[i] # temp = 89 alist[i] = alist[i-1] # 89 with 5 alist[i-1] = temp # 89 => 5 print (i,'-->',alist) print () print ('------------------------------------------------') return alist sampleList = [1, 5, 89, 8, 23, 1] sortedList = bubbleSort(sampleList) print (sortedList)
run
|
edit
|
history
|
help
0
pythonic way (V2)
Ваня и забор
24jan py
Name
Sir, You Are Being Hunted secret message
GMK output
S
Python: Functions I : Functions with messages.
Omirp
salarysms