Also, new to Python (Loving it).
We're doing exercises in class and I'm really finding this teacher useless.
The exercise is a bubble sort.
I'd love to learn by myself to help practice, but I need help and I know he's (teacher) not going to be able to provide.
Here it is:
Bubble sorting. Sort 5 characters alphanumerically.
In high school I was learning Visual Basic.
an array was easy.
example:
loop x = x + 1 my_array(x) = 4 + x end loopHow do I get a similar thing in Python?
Here's the algorithm for the actual exercise for those playing at home.
If you come up with a working solution, please don't post it, I want to work the bulk for myself.
sortList = [set of 5 characters] e.g. [1,10,15,3,56]
movedElement = true
while movedElement = true
movedElement = false
x = 0
while x <= 5
if sortList[x] >sortList[x+1]
temp = sortList[x]
sortList[x] = sortList[x+1]
sortList[x+1] = temp
movedElement = true
end if
x = x + 1
end while
display sortList


Sign In
Create Account

Back to top










