+ 1

How can we see each ine of Python code works?

I mean, do you know, can i see 'What does each line of python code do?', i mean like, a code like this: a = 1 ---> defines new variable and insert it's value print(a) ---> prints out the value of a a = 3 ---> change the value of 'a' variable If you know, thank you so much.

13th Feb 2018, 7:58 AM
Fajar Kurniawan
5 Respuestas
+ 2
thanks
13th Feb 2018, 8:43 AM
Fajar Kurniawan
+ 1
i've try the interpreter many months ago, but i just want to know, what does each line of this code do? def bubble_sort(nlist): for passnum in range(len(nlist)-1,0,-1): for j in range(passnum): if nlist[j]>nlist[j+1]: nlist[j], nlist[j+1] = nlist[j+1], nlist[j] nlist = [14,46,43,27,57,41,45,21,70] bubble_sort(nlist) print(nlist)
13th Feb 2018, 8:24 AM
Fajar Kurniawan
0
you can try a python interpreter it processes the code as you enter not exactly what you want but still its interesting check it out
13th Feb 2018, 8:10 AM
‎ ‏‏‎Anonymous Guy
0
def .. -> declaration of function for passnum .. -> starts from len(nlist)-1 till its 0 and reduce 1 every time for j .. -> loop from 0 till passnum nlist[j] .. -> checks if element in j position is greater than next element nlist[j] .. -> if yes then swap their places nlist .. -> the list bub .. -> calling function with nlist as arguement print (nlist) .. -> prints sorted nlist
13th Feb 2018, 8:37 AM
‎ ‏‏‎Anonymous Guy
0
np :)
13th Feb 2018, 9:06 AM
‎ ‏‏‎Anonymous Guy