# #71 Python Tutorial for Beginners | Selection Sort using Python

///#71 Python Tutorial for Beginners | Selection Sort using Python

## #71 Python Tutorial for Beginners | Selection Sort using Python

Python Tutorial to learn Python programming with examples
Complete Python Tutorial for Beginners Playlist :
Python Tutorial in Hindi :

Github :-

Check out our website:

Telusko :
Navin Reddy :

Subscribe to our other channel:
Navin Reddy :
Telusko Hindi :

Editing Monitors :

Donation:
PayPal Id : navinreddy20
Patreon : navinreddy20

source

By |2019-11-17T00:00:12+00:00November 17th, 2019|Python Video Tutorials|44 Comments

1. Ayisha Siddiquah November 17, 2019 at 12:00 am - Reply

Sir how come without an return type u are executing the code.???๐๐ค

2. Deathvoltaje November 17, 2019 at 12:00 am - Reply

I wrote two selection sort in phyton, trying to figure it out on my own first, and succeded, is not that difficult, now I come here to see how professionals have done it, and I find in this video a simpler version, BUT, why the heck my two original, novice versions are 2.5 times FASTER than this simpler version, can someone say explain it to me XD?

3. Nandyala Naveen Reddy November 17, 2019 at 12:00 am - Reply

You helped me a lot sir

4. Hasib Khan November 17, 2019 at 12:00 am - Reply

for i in range(10):
print("At the end to watching all the video, I want to say, take my salam inside my heart. Thank you so much Navin Reddy Sir.God bless you.")

5. Pankaj Patidar November 17, 2019 at 12:00 am - Reply

nice sir.

6. Kaushit November 17, 2019 at 12:00 am - Reply

logic

for i in range( len(array)-1 ):
for j in range( i+1, len(array) ):
if( array [ j ] < array [ i ] ):
array[ i ], array[ j ] = array[ j ], array[ i ]

print(array)

7. Learn IT November 17, 2019 at 12:00 am - Reply

Thanks for the video man ๐ i understand how it works but I don't know how it works the swapping

8. raj mohammed November 17, 2019 at 12:00 am - Reply

Thank you, Sir, you have explained in an easy way.

9. Abhishek kumar singh November 17, 2019 at 12:00 am - Reply

10. Abhishek kumar singh November 17, 2019 at 12:00 am - Reply

YOUR CODE IS RUNNING BUT MINE CODE IS NOT RUNNING
def sort(lst):

for i in range(5):

minpos=i

for j in range(i,6):

if lst[j] < lst[minpos]:

minpos=j

(lst[i],lst[minpos])=(lst[minpos],lst[i])

lst=[35,15,25,45,55]

sort(lst)

print(lst)

11. Abhishek kumar singh November 17, 2019 at 12:00 am - Reply

def sort(lst):

for i in range(5):

minpos=i

for j in range(i,6):

if lst[j] < lst[minpos]:

minpos=j

(lst[i],lst[minpos])=(lst[minpos],lst[i])

lst=[35,15,25,45,55]

sort(lst)

print(lst)

YOUR CODE IS RUNNING THEN WHY NOT MINE

Thank you sir so much, now we are able to refined the code up to somehow it' s by watching your videos. So i would like to share the script that took me almost 2 hours and get me succeed in it.
def selct(x):

for i in range(len(x)):

#minIndex=i (No need of this)

for k in range(i, len(x)):

if x[k] < x[i]:

(x[k],x[i])=(x[i],x[k])

print(x)

x=[2,4,5,1000,7,8,1,99]

selct(x)

13. Abhishek Jaiswar November 17, 2019 at 12:00 am - Reply

def sort(num):

for i in range(len(num)):

for j in range(i,len(num)):

if num[j]<num[i]:

temp =num[i]

num[i]=num[j]

num[j]=temp

num=[4,5,3,7,1,6]

sort(num)

print(num)

sir this also works. Thank you to help us by your video and technique

14. aman singh November 17, 2019 at 12:00 am - Reply

It says object list is no callable
How to fix this

15. Saurav Garg November 17, 2019 at 12:00 am - Reply

use i+1 to reduce one iteration

16. krishnarajan lakshanya November 17, 2019 at 12:00 am - Reply

why you didn't do video in python for quick,merge sort

17. krishnarajan lakshanya November 17, 2019 at 12:00 am - Reply

amazing explanaition

18. Sarat Chan November 17, 2019 at 12:00 am - Reply

Hi Navin, You are a great teacher, I gained lot of knowledge from your python series. Can share us separate series dedicated to algorithm and data structures?

19. Be Bold November 17, 2019 at 12:00 am - Reply

if don't know how many numbers in your list how you choose the range..why didn't took dynamical range in this lecture

20. Arunaa GT November 17, 2019 at 12:00 am - Reply

THANK YOU SO MUCH SIR

21. Parth Agarwal November 17, 2019 at 12:00 am - Reply

The last three iterations did not bring about a change. Can we compare the iterations to see if they are same and if they are, the loop breaks. With this the loop iterates only when necessary which then saves the processing power by not iterating the last three times? So in short, can we check if the iterations produced are the same and then break if they are?

22. Harsh Raj November 17, 2019 at 12:00 am - Reply

23. Harsh Raj November 17, 2019 at 12:00 am - Reply

Hey in python
I think we do not need a temporaray variable to swap
Here how it you can do it

>> num[ยก], num[minpos] = num[minpos], num[ยก]

If there is something wrong please tell me
I am a student of class 11.

24. Ram Niki November 17, 2019 at 12:00 am - Reply

Thanks sir very usefull this program

25. Hey H llo November 17, 2019 at 12:00 am - Reply

Can u write the program to know how many swaps occurred. ..

26. Sai Swaroop Maram November 17, 2019 at 12:00 am - Reply

At 3:47 what does that mean u have to reach till 4?

In case i want to take the list from the user as an input. How can i take that. Please help

28. deepak tiwari November 17, 2019 at 12:00 am - Reply

thank you so much ..Can you please upload the data structures like (linked list,stack,queue,tree,graphs) implementation in python as well ..your explanation is always to the point …You are a great teacher..Respect

29. Bimbo Faggins November 17, 2019 at 12:00 am - Reply

I did it slightly different, not sure it has problems. Please don't be too harsh its my first self written Python code ๐

def sort(n):

for k in range(len(n)):

for i in range(len(n)-1,k,-1):

if n[i]==min(n[k:len(n)]):

temp=n[k]

n[k]=n[i]

n[i]=temp

n=[454,346,68,679679,7,658,7796,8,9767,334]

sort(n)

print(n)
—–
[7, 8, 68, 334, 346, 454, 658, 7796, 9767, 679679]

Process finished with exit code 0

30. John Dermon November 17, 2019 at 12:00 am - Reply

Why not in line 6 for j in range(i+1,6): otherwise you always begin each loop by comparing an element to itself

Where the hell are you man?? ๐ค

32. Sudeep Dhakal November 17, 2019 at 12:00 am - Reply

isnt that the bubble sort? selection sort is supposed to sort unsorted list and add it into a new array. i am confused

33. Mudassir Farooq November 17, 2019 at 12:00 am - Reply

Very nice bro, I am really impressed…

34. Kanagavel Kaliaperumal November 17, 2019 at 12:00 am - Reply

Sir don't u teach algorithm and flowchart for a program….sir plss teach that also sir

35. Saila Pellakuru November 17, 2019 at 12:00 am - Reply

37. siddhant Goyal November 17, 2019 at 12:00 am - Reply

38. ankit kumar November 17, 2019 at 12:00 am - Reply

Sir python ka kitna lecture aur aayega

39. Abhijeet Singh November 17, 2019 at 12:00 am - Reply

thank you sir : )
is this end of this series???

40. Md Tanzin Islam November 17, 2019 at 12:00 am - Reply

Plz help

41. Md Tanzin Islam November 17, 2019 at 12:00 am - Reply

I watched your java vedio and python now what should i doshould i start project or start making app

42. Anil Kumar November 17, 2019 at 12:00 am - Reply

Can we use=> list.sort(reverse=True/False) in order to sort directly in ascending or descending order?

43. DIY November 17, 2019 at 12:00 am - Reply

Can you also start tkinter or any other python GUI tutorial please as it helps in many projects. PLEASE REPLY TO MY COMMENT ๐

44. msprabhu.sudhi526@gmail.com msp November 17, 2019 at 12:00 am - Reply

Sir, can you please do videos on data structures in python