Python Tutorial 9: Bubble Sort

preview_player
Показать описание

Рекомендации по теме
Комментарии
Автор

thanks for this tutorial, the basic one is really helpful as a lot of the time its just interpreting the bubble sort with different situations that I get stuck on, remembering the basic layout really helped

salsaontop
Автор

Hello RaspberryPy, Ignore the haters. Your program, sir, is correct. There is no need for a dummy variable nor for you state where you got your computing/computer science degree from. They simply made a #Tracebackerror themselves

tracebackerror
Автор

Thanks Bob. Sounds like it's treating the numbers as strings. I guess I introduced a bug by not converting the input to int or float.

RaspberryPy
Автор

The bubble sort in the second half of the video does not properly sort number greater than or equal to 10. For instance, if your inputs for choice 2  are 3, 7, 10, 13, 20 it will sort then as 10, 13, 2, 20, 3, 7.

BOB
Автор

You could use break, but I made the while loop condition stop the loop if ans is 'q'. If you prefer to use a break here, you could use "while True:" instead.

RaspberryPy
Автор

Hi. No, I'm afraid I am on my PC for the videos. I tried making them on the Pi, but I was having some problems with ffmpeg, so for now it's this way!

RaspberryPy
Автор

Question: How are you splitting the temp variable when it's an int or float, without converting it to a string?

Colstonewall
Автор

Sorry I still haven't got round to fixing this. I will look at it this weekend.

RaspberryPy
Автор

Might be a stupid question but, are you using your rasberry pi for these tutorials. I wondered because of puppy linux. That would be really cool though.

russell
Автор

Hi guys. Can someone explain to me the reason for having a >continue< statement after ans == 'q' . Isn't it make sense to use >break< statement instead ? Thank you

Автор

You also wouldn't need to set ans to None. So actually, I think your suggestion is better.

RaspberryPy
Автор

By the way, the bug is in the get_list() function. My function doesn't actually return a list of floats. You could create a new list:

nums =[]
and put something like this in the try:
nums.append(float(item))
Then make nums the return value.
Sorry for this noobish error.

RaspberryPy
Автор

Cheers man!! For some reason if i had a number with more than one digit within my list then the algorithm would only compare the first digit... I was stuck on this for hours until I found this video and noticed you weren't using quotes when creating your list. www.pastebin.com/TMCgLqR3

REAL-kopuzz
Автор

You missed out on a dummy variable, so the program is not actually fit for its purpose. Could you please state where you received your computer science degree. Thank you.

billzahkm
join shbcf.ru