Code execution


Hiya Stetim (I know you'll be the one to reply :smiley: )

Having learned about 'while' loops now, I was wondering in what order does code execute?

So it goes from the top of the module down to the bottom, then it encounters the 'while' loop. It loops through it once (it will loop through it again because the condition for it to stop hasn't been fulfilled yet). But before that, does it execute whatever comes after the 'while' loop?


foobar = 1
while foobar <= 10:
    foobar = foobar + 1

# Some other pretend code

Does '# Some other pretend code' get executed in-between each 'while' loop or not?


you saw i was online?

no, the while loop needs to finish first. Then the some other pretend code gets executed


no, the while loop really just executes the while loop, it interrupts the normal flow (from top to bottom) until all iterations of the loop are completed.


well, python automatically manages memory for you:


I have coded a little bit in C, where you have to manually manage the memory, which can make your program really efficient if the memory management is done right, but that is tricky

your program often had what is known as memory leaks, you forgot to clear the memory and give it back to the computer, so the data would stay stored in RAM, even after the program finishes.


honestly? I don't know, and i don't want to know. I am happy that python does, i am sure you can find into great detail how this is achieved, but its a tough read and even tougher to understand :stuck_out_tongue:

i would advise against going there at this point


This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.