Code execution order? | Sololearn: Learn to code for FREE!

0

Code execution order?

Is python code executed from top to bottom or is it executed by block from top to bottom? Im a little confused what exactly defines as a block too if someone could clarify

3/31/2017 8:54:44 PM

Hunter Gregan

4 Answers

New Answer

+9

To be more precise, the code is *interpreted* top to bottom. So if you define a function or a class at the beginning of your program, it is interpreted but not executed until called. A block of code is a single semantic group of lines of code - a class definition, a for loop, an if statement - with all indented lines that come afterwards.

+4

By default code executes from top to bottom (After every spacing, etc). But there are special cases where it doesnt for a few lines in a code.

+1

top to bottom

0

Just adding is code contains a error (not syntax error) code is normal interpreted before the error line.